Re: MonetDB: geo - MakePolygon/Polygon implmentation. Works only for...
Thanks! purely out of curiosity: - are there checks & warnings/ error messages in place for not (trying) to use it for polygons with holes, as well as a (configure) check whether the geos library provides the required functionality? - are the changes to the geos module documented (at least as "diff" with reference to which code version it applies), or have these changes even been send "up-stream" to have them by default included in a future version of the library? Thanks! Stefan ----- Original Message -----
Changeset: 4d4c6ce1a817 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4d4c6ce1a817 Modified Files: geom/monetdb5/geom.c geom/monetdb5/geom.mal geom/sql/40_geom.sql Branch: geo Log Message:
MakePolygon/Polygon implmentation. Works only for polygons without holes. Changes to geos library were necessary so, it will not work with standard geos library.
diffs (80 lines):
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -600,7 +600,7 @@ str geom_2_geom(wkb** resWKB, wkb **valu int valueType = 0;
int valueSRID = (*valueWKB)->srid; -//fprintf(stderr, "in geom_2_geom\n"); + /* get the geosGeometry from the wkb */ geosGeometry = wkb2geos(*valueWKB); /* get the number of coordinates the geometry has */ @@ -784,7 +784,7 @@ wkb* geos2wkb(const GEOSGeometry* geosGe geomWKB->srid = GEOSGetSRID(geosGeometry); memcpy(&geomWKB->data, w, wkbLen); GEOSFree(w); - + return geomWKB; }
@@ -1944,13 +1944,13 @@ str wkbMakePolygon(wkb** out, wkb** exte }
externalGeometry = wkb2geos(*external); - if ((GEOSGeomTypeId(externalGeometry)+1) != wkbLineString) { + if ((GEOSGeomTypeId(externalGeometry)+1) != wkbLinearRing) { *out = wkb_nil; GEOSGeom_destroy(externalGeometry); - throw(MAL, "geom.Polygon", "Geometries should be LineStrings"); + throw(MAL, "geom.Polygon", "Geometries should be LinearRings"); }
- if(internalBAT_id == NULL) { + if(*internalBAT_id == 0) { geosGeometry = GEOSGeom_createPolygon(externalGeometry, NULL, 0); if(geosGeometry == NULL) { GEOSGeom_destroy(externalGeometry); diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal --- a/geom/monetdb5/geom.mal +++ b/geom/monetdb5/geom.mal @@ -289,14 +289,14 @@ function MakeEnvelope(xmin:dbl, ymin:dbl return x; end MakeEnvelope;
-#function MakePolygon(external:wkb) :wkb; -# x := Polygon(external, NULL, 0); -# return x; -#end MakePolygon; -#function MakePolygon(external:wkb, srid:int) :wkb; -# x := Polygon(external, NULL, srid); -# return x; -#end MakePolygon; +function MakePolygon(external:wkb) :wkb; + x := Polygon(external, nil:bat, 0); + return x; +end MakePolygon; +function MakePolygon(external:wkb, srid:int) :wkb; + x := Polygon(external, nil:bat, srid); + return x; +end MakePolygon; #function MakePolygon(external:wkb, internal:bat[:oid,:wkb]) :wkb; # x := Polygon(external, internal, 0); # return x; diff --git a/geom/sql/40_geom.sql b/geom/sql/40_geom.sql --- a/geom/sql/40_geom.sql +++ b/geom/sql/40_geom.sql @@ -4070,9 +4070,9 @@ CREATE FUNCTION ST_MakePointM(x double, --CREATE FUNCTION ST_LineFromMultiPoint(pointGeom Geometry) RETURNS Geometry external name geom."LineFromMultiPoint"; --gets mutlipoint returns linestring CREATE FUNCTION ST_MakeEnvelope(xmin double, ymin double, xmax double, ymax double, srid integer) RETURNS Geometry external name geom."MakeEnvelope"; CREATE FUNCTION ST_MakeEnvelope(xmin double, ymin double, xmax double, ymax double) RETURNS Geometry external name geom."MakeEnvelope"; ---CREATE FUNCTION ST_MakePolygon(geom Geometry) RETURNS Geometry external name geom."MakePolygon"; --gets linestring ---CREATE FUNCTION ST_MakePolygon(outerGeom Geometry, interiorGeoms Geometry[]) RETURNS Geometry external name geom."MakePolygon"; --gets linestrings ---CREATE FUNCTION ST_Polygon(geom Geometry, srid integer) RETURNS Geometry external name geom."MakePolygon"; --gets linestring +CREATE FUNCTION ST_MakePolygon(geom Geometry) RETURNS Geometry external name geom."MakePolygon"; --gets linestring +--CREATE FUNCTION ST_MakePolygon(outerGeom Geometry, interiorGeoms table(g Geometry)) RETURNS Geometry external name geom."MakePolygon"; --gets linestrings +CREATE FUNCTION ST_Polygon(geom Geometry, srid integer) RETURNS Geometry external name geom."MakePolygon"; --gets linestring CREATE FUNCTION ST_MakeBox2D(lowLeftPointGeom Geometry, upRightPointGeom Geometry) RETURNS mbr external name geom."MakeBox2D"; --gets 2d points --CREATE FUNCTION ST_3DMakeBox(lowLeftPointGeom Geometry, upRightPointGeom Geometry) RETURNS mbr external name geom."MakeBox3D"; --gets 3d points
_______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
participants (1)
-
Stefan Manegold