[mapserver-commits] r7235 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Jan 2 11:47:19 EST 2008


Author: tomkralidis
Date: 2008-01-02 11:47:18 -0500 (Wed, 02 Jan 2008)
New Revision: 7235

Modified:
   trunk/mapserver/mapgeos.c
Log:
set shapeObj bounds from WKT (#2087)


Modified: trunk/mapserver/mapgeos.c
===================================================================
--- trunk/mapserver/mapgeos.c	2008-01-01 20:18:12 UTC (rev 7234)
+++ trunk/mapserver/mapgeos.c	2008-01-02 16:47:18 UTC (rev 7235)
@@ -65,6 +65,29 @@
 }
 
 /*
+** utility functions
+*/
+
+/*
+** msGEOSEnvelope: utility function to derive the envelope
+of a GEOSGeom and set shapeObj.bounds
+*/
+static void msGEOSEnvelope(GEOSGeom g, shapeObj *shape)
+{
+  GEOSCoordSeq coords;
+  GEOSGeom ring;
+  GEOSGeom envelope;
+
+  envelope = (GEOSGeom) GEOSEnvelope(g);
+  ring = (GEOSGeom) GEOSGetExteriorRing(envelope);
+  coords = (GEOSCoordSeq) GEOSGeom_getCoordSeq(ring);
+  GEOSCoordSeq_getX(coords, 0, &(shape->bounds.minx));
+  GEOSCoordSeq_getY(coords, 0, &(shape->bounds.miny));
+  GEOSCoordSeq_getX(coords, 2, &(shape->bounds.maxx));
+  GEOSCoordSeq_getY(coords, 2, &(shape->bounds.maxy));
+}
+
+/*
 ** Translation functions
 */
 static GEOSGeom msGEOSShape2Geometry_point(pointObj *point)
@@ -302,6 +325,9 @@
   GEOSCoordSeq_getX(coords, 0, &(shape->line[0].point[0].x));
   GEOSCoordSeq_getY(coords, 0, &(shape->line[0].point[0].y));
   /* GEOSCoordSeq_getZ(coords, 0, &(shape->line[0].point[0].z)); */
+
+  shape->bounds.minx = shape->bounds.maxx = shape->line[0].point[0].x;
+  shape->bounds.miny = shape->bounds.maxy = shape->line[0].point[0].y;
  
   return shape;
 }
@@ -337,6 +363,8 @@
     /* GEOSCoordSeq_getZ(coords, 0, &(shape->line[0].point[i].z)); */
   }
   
+  msGEOSEnvelope(g, shape);
+
   return shape;
 }
 
@@ -368,6 +396,8 @@
     /* GEOSCoordSeq_getZ(coords, i, &(shape->line[0].point[i].z)); */
   }
 
+  msGEOSEnvelope(g, shape);
+
   return shape;
 }
 
@@ -407,6 +437,8 @@
     msAddLineDirectly(shape, &line);
   }
 
+  msGEOSEnvelope(g, shape);
+
   return shape;
 }
 
@@ -462,6 +494,8 @@
     msAddLineDirectly(shape, &line);
   }
 
+  msGEOSEnvelope(g, shape);
+
   return shape;
 }
 
@@ -523,6 +557,8 @@
     }
   } /* next polygon */
 
+  msGEOSEnvelope(g, shape);
+
   return shape; 
 }
 



More information about the mapserver-commits mailing list