Changeset: 099f60388f21 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=099f60388f21 Modified Files: geom/monetdb5/geom.c geom/monetdb5/geom.h geom/monetdb5/geom.mal Branch: sfcgal Log Message:
Add another aggregation function, subUnion. Fix a bug in BATgroupWKBWKBtoWKB. diffs (90 lines): diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -4741,6 +4741,54 @@ wkbUnionCascade(wkb **outWKB, bat *inBAT } str +wkbsubUnion(bat *outBAT_id, bat* bBAT_id, bat *gBAT_id, bat *eBAT_id, bit* flag) { + (void) flag; + int skip_nils = 1, i = 0; + const char *msg = MAL_SUCCEED; + str err; + BAT *b = NULL, *g = NULL, *e = NULL; + oid min, max; + BUN ngrp; + BUN start, end, cnt; + wkb **empty_geoms = NULL; + const oid *cand = NULL, *candend = NULL; + + if ((b = BATdescriptor(*bBAT_id)) == NULL) { + throw(MAL, "geom.wkbCollect", RUNTIME_OBJECT_MISSING); + } + if ((g = BATdescriptor(*gBAT_id)) == NULL) { + BBPunfix(b->batCacheid); + throw(MAL, "geom.wkbCollect", RUNTIME_OBJECT_MISSING); + } + if ((e = BATdescriptor(*eBAT_id)) == NULL) { + BBPunfix(b->batCacheid); + BBPunfix(g->batCacheid); + throw(MAL, "geom.wkbCollect", RUNTIME_OBJECT_MISSING); + } + + if ((msg = BATgroupaggrinit(b, g, e, NULL, &min, &max, &ngrp, + &start, &end, &cnt, + &cand, &candend)) != NULL) { + throw(MAL, "BATgroupCollect: %s\n", msg); + } + + /*Create the empty geoms*/ + empty_geoms = (wkb**) GDKmalloc(sizeof(wkb*)*ngrp); + for (i = 0; i < ngrp; i++) + empty_geoms[i] = geos2wkb(GEOSGeom_createEmptyPolygon()); + + err = BATgroupWKBWKBtoWKB(outBAT_id, b, g, e, skip_nils, min, max, ngrp, start, end, empty_geoms, wkbUnion, "wkbUnion"); + BBPkeepref(*outBAT_id); + + GDKfree(empty_geoms); + BBPunfix(b->batCacheid); + BBPunfix(g->batCacheid); + BBPunfix(e->batCacheid); + + return err; +} + +str wkbCollect(wkb **out, wkb **geom1WKB, wkb **geom2WKB) { GEOSGeom outGeometry, geom1Geometry, geom2Geometry, geomGeometries[2]; @@ -5028,7 +5076,6 @@ BATgroupWKBWKBtoWKB(bat *outBAT_id, BAT if (!outWKBs[gid]) outWKBs[gid] = aWKBs[gid]; } else { - nils = 1; if (empty_geoms) aWKBs[gid] = empty_geoms[gid]; diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h --- a/geom/monetdb5/geom.h +++ b/geom/monetdb5/geom.h @@ -224,7 +224,7 @@ geom_export str wkbIntersection_bat_s(ba geom_export str wkbUnion(wkb **out, wkb **a, wkb **b); geom_export str wkbUnionAggr(wkb** outWKB, bat* inBAT_id); geom_export str wkbUnionCascade(wkb** outWKB, bat* inBAT_id); -geom_export str wkbsubUnion(bat *outBAT_id, bat* bBAT_id, bat *gBAT_id, bat *eBAT_id, bit* fla); +geom_export str wkbsubUnion(bat *outBAT_id, bat* bBAT_id, bat *gBAT_id, bat *eBAT_id, bit* flag); geom_export str wkbCollect(wkb **out, wkb **a, wkb **b); geom_export str wkbCollectCascade(wkb** outWKB, bat* inBAT_id); geom_export str wkbsubCollect(bat *outBAT_id, bat* bBAT_id, bat *gBAT_id, bat *eBAT_id, bit* flag); diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal --- a/geom/monetdb5/geom.mal +++ b/geom/monetdb5/geom.mal @@ -289,7 +289,7 @@ command Union(a:wkb, b:wkb) :wkb address comment "Returns a geometry that represents the point set union of the Geometries a, b"; command Union(a:bat[:oid,:wkb]) :wkb address wkbUnionCascade comment "Gets a BAT with geometries and returns their union"; -command subUnion(a:bat[:oid,:wkb], g:bat[:oid], e:bat[:oid], :bit) :bat[:wkb] address wkbsubUnion +command subUnion(b:bat[:wkb], g:bat[:oid], e:bat[:oid], :bit) :bat[:wkb] address wkbsubUnion comment "Gets a BAT with geometries, candidate group list and returns the union of each group element."; command Collect(a:wkb, b:wkb) :wkb address wkbCollect _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list