Skip to content

Commit

Permalink
RFC93: UTFGrid Implementation (#4765)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdesj authored and tbonfort committed Sep 28, 2013
1 parent a09f2ae commit f0a45de
Show file tree
Hide file tree
Showing 19 changed files with 3,467 additions and 2,204 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ option(WITH_SDE_PLUGIN "include ArcSDE support as a plugin (must specify SDE_INC
option(WITH_SDE "include ArcSDE support. Add -DSDE_VERSION=91 to use 9.1 arcSDE version" OFF)
option(WITH_EXEMPI "include xmp output metadata support" OFF)
option(WITH_XMLMAPFILE "include native xml mapfile support (requires libxslt/libexslt)" OFF)
option(WITH_AGG_ALIASED "turn off antialising on AGG" OFF)

option(BUILD_STATIC "Also build a static version of mapserver" OFF)
option(LINK_STATIC_LIBMAPSERVER "Link to static version of libmapserver (also for mapscripts)" OFF)
Expand Down Expand Up @@ -200,7 +201,7 @@ mapwcs.c maperror.c mapogcfilter.c mapregex.c mapwcs11.c mapfile.c
mapogcfiltercommon.c maprendering.c mapwcs20.c mapogcsld.c
mapresample.c mapwfs.c mapgdal.c mapogcsos.c mapscale.c mapwfs11.c
mapgeomtransform.c mapogroutput.c mapsde.c mapwfslayer.c mapagg.cpp mapkml.cpp
mapgeomutil.cpp mapkmlrenderer.cpp fontcache.c textlayout.c
mapgeomutil.cpp mapkmlrenderer.cpp fontcache.c textlayout.c maputfgrid.cpp
mapogr.cpp mapcontour.c mapsmoothing.c mapv8.cpp ${REGEX_SOURCES})

if(BUILD_DYNAMIC)
Expand Down Expand Up @@ -341,6 +342,10 @@ if(WITH_ICONV)
endif(ICONV_FOUND)
endif (WITH_ICONV)

if(WITH_AGG_ALIASED)
set (AGG_ALIASED_ENABLED 1)
endif(WITH_AGG_ALIASED)

if(WITH_GENERIC_NINT)
set(USE_GENERIC_MS_NINT 1)
endif(WITH_GENERIC_NINT)
Expand Down Expand Up @@ -862,6 +867,7 @@ status_optional_feature("WCS SERVER" "${USE_WCS_SVR}")
status_optional_feature("SOS SERVER" "${USE_SOS_SVR}")
status_optional_feature("WMS CLIENT" "${USE_WMS_LYR}")
status_optional_feature("WFS CLIENT" "${USE_WFS_LYR}")
status_optional_feature("AGG ALISING" "${AGG_ALIASED_ENABLED}")
status_optional_feature("ICONV" "${USE_ICONV}")
status_optional_feature("Thread-safety support" "${USE_THREAD}")
status_optional_feature("KML output" "${USE_KML}")
Expand Down
139 changes: 12 additions & 127 deletions mapagg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "mapserver.h"
#include "fontcache.h"
#include "mapagg.h"
#include "mapaggcommon.h"
#include <assert.h>
#include "renderers/agg/include/agg_color_rgba.h"
#include "renderers/agg/include/agg_pixfmt_rgba.h"
Expand All @@ -47,7 +49,6 @@
#include "renderers/agg/include/agg_image_accessors.h"
#include "renderers/agg/include/agg_conv_stroke.h"
#include "renderers/agg/include/agg_conv_dash.h"
#include "renderers/agg/include/agg_path_storage.h"
#include "renderers/agg/include/agg_font_freetype.h"
#include "renderers/agg/include/agg_conv_contour.h"
#include "renderers/agg/include/agg_ellipse.h"
Expand Down Expand Up @@ -112,123 +113,6 @@ fontMetrics rasterfont_sizes[] = {
{7,mapserver::mcs7x12_mono_high[0]}
};

/*
* interface to a shapeObj representing lines, providing the functions
* needed by the agg rasterizer. treats shapeObjs with multiple linestrings.
*/
class line_adaptor
{
public:
line_adaptor(shapeObj *shape):s(shape) {
m_line=s->line; /*first line*/
m_point=m_line->point; /*current vertex is first vertex of first line*/
m_lend=&(s->line[s->numlines]); /*pointer to after last line*/
m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of first line*/
}

/* a class with virtual functions should also provide a virtual destructor */
virtual ~line_adaptor() {}

void rewind(unsigned) {
m_line=s->line; /*first line*/
m_point=m_line->point; /*current vertex is first vertex of first line*/
m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of first line*/
}

virtual unsigned vertex(double* x, double* y) {
if(m_point < m_pend) {
/*here we treat the case where a real vertex is returned*/
bool first = m_point == m_line->point; /*is this the first vertex of a line*/
*x = m_point->x;
*y = m_point->y;
m_point++;
return first ? mapserver::path_cmd_move_to : mapserver::path_cmd_line_to;
}
/*if here, we're at the end of a line*/
m_line++;
*x = *y = 0.0;
if(m_line>=m_lend) /*is this the last line of the shapObj. normally,
(m_line==m_lend) should be a sufficient test, as the caller should not call
this function if a previous call returned path_cmd_stop.*/
return mapserver::path_cmd_stop; /*no more points to process*/

/*if here, there are more lines in the shapeObj, continue with next one*/
m_point=m_line->point; /*pointer to first point of next line*/
m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last point of next line*/

return vertex(x,y); /*this will return the first point of the next line*/
}
private:
shapeObj *s;
lineObj *m_line, /*current line pointer*/
*m_lend; /*points to after the last line*/
pointObj *m_point, /*current point*/
*m_pend; /*points to after last point of current line*/
};

class polygon_adaptor
{
public:
polygon_adaptor(shapeObj *shape):s(shape),m_stop(false) {
m_line=s->line; /*first lines*/
m_point=m_line->point; /*first vertex of first line*/
m_lend=&(s->line[s->numlines]); /*pointer to after last line*/
m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of first line*/
}

/* a class with virtual functions should also provide a virtual destructor */
virtual ~polygon_adaptor() {}

void rewind(unsigned) {
/*reset pointers*/
m_stop=false;
m_line=s->line;
m_point=m_line->point;
m_pend=&(m_line->point[m_line->numpoints]);
}

virtual unsigned vertex(double* x, double* y) {
if(m_point < m_pend) {
/*if here, we have a real vertex*/
bool first = m_point == m_line->point;
*x = m_point->x;
*y = m_point->y;
m_point++;
return first ? mapserver::path_cmd_move_to : mapserver::path_cmd_line_to;
}
*x = *y = 0.0;
if(!m_stop) {
/*if here, we're after the last vertex of the current line
* we return the command to close the current polygon*/
m_line++;
if(m_line>=m_lend) {
/*if here, we've finished all the vertexes of the shape.
* we still return the command to close the current polygon,
* but set m_stop so the subsequent call to vertex() will return
* the stop command*/
m_stop=true;
return mapserver::path_cmd_end_poly;
}
/*if here, there's another line in the shape, so we set the pointers accordingly
* and return the command to close the current polygon*/
m_point=m_line->point; /*first vertex of next line*/
m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of next line*/
return mapserver::path_cmd_end_poly;
}
/*if here, a previous call to vertex informed us that we'd consumed all the vertexes
* of the shape. return the command to stop processing this shape*/
return mapserver::path_cmd_stop;
}
private:
shapeObj *s;
double ox,oy;
lineObj *m_line, /*pointer to current line*/
*m_lend; /*pointer to after last line of the shape*/
pointObj *m_point, /*pointer to current vertex*/
*m_pend; /*pointer to after last vertex of current line*/
bool m_stop; /*should next call return stop command*/
};

#define aggColor(c) mapserver::rgba8_pre((c)->red, (c)->green, (c)->blue, (c)->alpha)

class aggRendererCache
Expand Down Expand Up @@ -796,17 +680,19 @@ int getBitmapGlyphMetrics(int size, unsigned int unicode, glyph_metrics *bounds)
return MS_SUCCESS;
}

static mapserver::path_storage imageVectorSymbolAGG(symbolObj *symbol)
mapserver::path_storage imageVectorSymbol(symbolObj *symbol)
{
mapserver::path_storage path;
bool is_new=true;
int is_new=1;

for(int i=0; i < symbol->numpoints; i++) {
if((symbol->points[i].x == -99) && (symbol->points[i].y == -99)) { // (PENUP)
is_new=true;
} else {
if((symbol->points[i].x == -99) && (symbol->points[i].y == -99))
is_new=1;

else {
if(is_new) {
path.move_to(symbol->points[i].x,symbol->points[i].y);
is_new=false;
is_new=0;
} else {
path.line_to(symbol->points[i].x,symbol->points[i].y);
}
Expand All @@ -815,15 +701,14 @@ static mapserver::path_storage imageVectorSymbolAGG(symbolObj *symbol)
return path;
}


int agg2RenderVectorSymbol(imageObj *img, double x, double y,
symbolObj *symbol, symbolStyleObj * style)
{
AGG2Renderer *r = AGG_RENDERER(img);
double ox = symbol->sizex * 0.5;
double oy = symbol->sizey * 0.5;

mapserver::path_storage path = imageVectorSymbolAGG(symbol);
mapserver::path_storage path = imageVectorSymbol(symbol);
mapserver::trans_affine mtx;
mtx *= mapserver::trans_affine_translation(-ox,-oy);
mtx *= mapserver::trans_affine_scaling(style->scale);
Expand Down Expand Up @@ -1049,7 +934,7 @@ imageObj *agg2CreateImage(int width, int height, outputFormatObj *format, colorO

int agg2SaveImage(imageObj *img, mapObj* map, FILE *fp, outputFormatObj * format)
{
msSetError(MS_MISCERR, "AGG2 does not support direct image saving", "agg2SaveImage()");


return MS_FAILURE;
}
Expand Down
Loading

0 comments on commit f0a45de

Please sign in to comment.