Permalink
Browse files

Implementation of RFC 94: Shape Smoothing.

  • Loading branch information...
1 parent 250ca81 commit 47ed3cf91957e3683c855fd811590a6be5506842 Alan Boudreault committed Sep 21, 2012
Showing with 3,276 additions and 2,775 deletions.
  1. +1 −1 CMakeLists.txt
  2. +1 −1 Makefile.vc
  3. +13 −7 mapcontour.c
  4. +3 −3 mapdraw.c
  5. +1 −1 mapfile.c
  6. +9 −1 mapgeomtransform.c
  7. +3 −0 maplayer.c
  8. +2,212 −2,164 maplexer.c
  9. +6 −1 maplexer.l
  10. +644 −518 mapparser.c
  11. +16 −73 mapparser.h
  12. +48 −2 mapparser.y
  13. +12 −3 mapserver.h
  14. +307 −0 mapsmoothing.c
View
@@ -202,7 +202,7 @@ mapogcfiltercommon.c maprendering.c mapwcs20.c mapgd.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
-mapogr.cpp mapcontour.c ${REGEX_SOURCES})
+mapogr.cpp mapcontour.c mapsmoothing.c ${REGEX_SOURCES})
add_library(mapserver SHARED ${mapserver_SOURCES} ${agg_SOURCES})
set_target_properties( mapserver PROPERTIES
View
@@ -48,7 +48,7 @@ MS_OBJS = mapbits.obj maphash.obj mapshape.obj mapxbase.obj \
mapoglrenderer.obj mapoglcontext.obj mapogl.obj \
maptile.obj $(EPPL_OBJ) $(REGEX_OBJ) mapgeomtransform.obj mapunion.obj \
mapkmlrenderer.obj mapkml.obj mapdummyrenderer.obj mapgeomutil.obj mapquantization.obj \
- mapogcfiltercommon.obj mapcluster.obj mapuvraster.obj mapcontour.obj mapservutil.obj $(AGG_OBJ)
+ mapogcfiltercommon.obj mapcluster.obj mapuvraster.obj mapcontour.obj mapsmoothing.obj mapservutil.obj $(AGG_OBJ)
MS_HDRS = mapserver.h mapfile.h
View
@@ -4,6 +4,7 @@
* Project: MapServer
* Purpose: Contour Layer
* Author: Alan Boudreault (aboudreault@mapgears.com)
+ * Author: Daniel Morissette (dmorissette@mapgears.com)
*
**********************************************************************
* Copyright (c) 2011, Alan Boudreault, MapGears
@@ -55,6 +56,7 @@ typedef struct {
double *buffer; /* memory dataset buffer */
rectObj extent; /* original dataset extent */
OGRDataSourceH hOGRDS;
+ double cellsize;
} contourLayerInfo;
@@ -101,7 +103,6 @@ static void msContourLayerInfoInitialize(layerObj *layer)
clinfo->extent.maxx = -1.0;
clinfo->extent.maxy = -1.0;
-
initLayer(&clinfo->ogrLayer, layer->map);
clinfo->ogrLayer.type = layer->type;
clinfo->ogrLayer.debug = layer->debug;
@@ -149,8 +150,7 @@ static int msContourLayerReadRaster(layerObj *layer, rectObj rect)
if (clinfo == NULL || clinfo->hOrigDS == NULL) {
msSetError(MS_MISCERR, "Assertion failed: Contour layer not opened!!!",
"msContourLayerReadRaster()");
- return MS_FAILURE;
-
+ return MS_FAILURE;
}
bands = CSLTokenizeStringComplex(
@@ -233,7 +233,6 @@ static int msContourLayerReadRaster(layerObj *layer, rectObj rect)
mapRect = rect;
map_cellsize_x = map_cellsize_y = map->cellsize;
-
#ifdef USE_PROJ
/* if necessary, project the searchrect to source coords */
if (msProjectionsDiffer( &(map->projection), &(layer->projection))) {
@@ -316,7 +315,6 @@ static int msContourLayerReadRaster(layerObj *layer, rectObj rect)
copyRect.minx = GEO_TRANS(adfGeoTransform,0,src_ysize);
if (copyRect.maxx > GEO_TRANS(adfGeoTransform,src_xsize,0))
copyRect.maxx = GEO_TRANS(adfGeoTransform,src_xsize,0);
-
if (copyRect.miny < GEO_TRANS(adfGeoTransform+3,0,src_ysize))
copyRect.miny = GEO_TRANS(adfGeoTransform+3,0,src_ysize);
if (copyRect.maxy > GEO_TRANS(adfGeoTransform+3,src_xsize,0))
@@ -433,6 +431,13 @@ static int msContourLayerReadRaster(layerObj *layer, rectObj rect)
adfGeoTransform[4] = 0;
adfGeoTransform[5] = -dst_cellsize_y;
+ clinfo->cellsize = MAX(dst_cellsize_x, dst_cellsize_y);
+ {
+ char buf[64];
+ sprintf(buf, "%lf", clinfo->cellsize);
+ msInsertHashTable(&layer->metadata, "__data_cellsize__", buf);
+ }
+
GDALSetGeoTransform(clinfo->hDS, adfGeoTransform);
return MS_SUCCESS;
}
@@ -672,15 +677,16 @@ int msContourLayerClose(layerObj *layer)
}
msContourLayerInfoFree(layer);
- }
+ }
+
return MS_SUCCESS;
}
int msContourLayerGetItems(layerObj *layer)
{
contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo;
-
+
if (clinfo == NULL) {
msSetError(MS_MISCERR, "Assertion failed: Contour layer not opened!!!",
"msContourLayerGetItems()");
View
@@ -34,7 +34,6 @@
#include "mapcopy.h"
-
#ifdef USE_GD
/*
* Functions to reset any pen (color index) values previously set. Used primarily to reset things when
@@ -1044,7 +1043,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image)
if (layer->type == MS_LAYER_LINE && msLayerGetProcessingKey(layer, "POLYLINE_NO_CLIP")) {
drawmode |= MS_DRAWMODE_UNCLIPPEDLINES;
}
-
+
if (cache) {
styleObj *pStyle = layer->class[shape.classindex]->styles[0];
colorObj tmp;
@@ -1097,7 +1096,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image)
retcode = MS_FAILURE;
break;
}
-
+
if(shape.numlines == 0) { /* once clipped the shape didn't need to be drawn */
msFreeShape(&shape);
continue;
@@ -1111,6 +1110,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image)
}
maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles);
+
msFreeShape(&shape);
}
View
@@ -4596,7 +4596,7 @@ static void writeLayer(FILE *stream, int indent, layerObj *layer)
writeString(stream, indent, "CLASSITEM", NULL, layer->classitem);
writeCluster(stream, indent, &(layer->cluster));
writeString(stream, indent, "CONNECTION", NULL, layer->connection);
- writeKeyword(stream, indent, "CONNECTIONTYPE", layer->connectiontype, 11, MS_SDE, "SDE", MS_OGR, "OGR", MS_POSTGIS, "POSTGIS", MS_WMS, "WMS", MS_ORACLESPATIAL, "ORACLESPATIAL", MS_WFS, "WFS", MS_PLUGIN, "PLUGIN", MS_UNION, "UNION", MS_UVRASTER, "UVRASTER", MS_CONTOUR, "CONTOUR");
+ writeKeyword(stream, indent, "CONNECTIONTYPE", layer->connectiontype, 10, MS_SDE, "SDE", MS_OGR, "OGR", MS_POSTGIS, "POSTGIS", MS_WMS, "WMS", MS_ORACLESPATIAL, "ORACLESPATIAL", MS_WFS, "WFS", MS_PLUGIN, "PLUGIN", MS_UNION, "UNION", MS_UVRASTER, "UVRASTER", MS_CONTOUR, "CONTOUR");
writeString(stream, indent, "DATA", NULL, layer->data);
writeNumber(stream, indent, "DEBUG", 0, layer->debug); /* is this right? see loadLayer() */
writeExtent(stream, indent, "EXTENT", layer->extent);
View
@@ -234,7 +234,15 @@ int msGeomTransformShape(mapObj *map, layerObj *layer, shapeObj *shape)
p.expr->curtoken = p.expr->tokens; /* reset */
p.type = MS_PARSE_TYPE_SHAPE;
p.dblval = map->cellsize * (msInchesPerUnit(map->units,0)/msInchesPerUnit(layer->units,0));
-
+ p.dblval2 = 0;
+ /* data_cellsize is only set with contour layer */
+ if (layer->connectiontype == MS_CONTOUR)
+ {
+ char *value = msLookupHashTable(&layer->metadata, "__data_cellsize__");
+ if (value)
+ p.dblval2 = atof(value);
+ }
+
status = yyparse(&p);
if (status != 0) {
msSetError(MS_PARSEERR, "Failed to process shape expression: %s", "msGeomTransformShape()", e->string);
View
@@ -535,6 +535,9 @@ int msTokenizeExpression(expressionObj *expression, char **list, int *listsize)
break;
case MS_TOKEN_BINDING_MAP_CELLSIZE:
node->token = token;
+ break;
+ case MS_TOKEN_BINDING_DATA_CELLSIZE:
+ node->token = token;
break;
case MS_TOKEN_FUNCTION_FROMTEXT: /* we want to process a shape from WKT once and not for every feature being evaluated */
if((token = msyylex()) != 40) { /* ( */
Oops, something went wrong.

0 comments on commit 47ed3cf

Please sign in to comment.