Changeset: 6d5cc4e1be82 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6d5cc4e1be82
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.h
geom/monetdb5/geom.mal
geom/monetdb5/geomBulk.c
Branch: sfcgal
Log Message:
Bulk version for Segmentize
diffs (216 lines):
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -3354,7 +3354,7 @@ wkbBasicInt(int *out, wkb *geom, int (*f
}
if ((geosGeometry = wkb2geos(geom)) == NULL)
- throw(MAL, name, "wkb2geos failed");
+ throw(MAL, name, "%s: wkb2geos failed", name);
*out = (*func) (geosGeometry);
@@ -3488,7 +3488,7 @@ wkbBasic(wkb **out, wkb **geom, GEOSGeom
}
if ((geosGeometry = wkb2geos(*geom)) == NULL) {
*out = NULL;
- throw(MAL, name, "wkb2geos failed");
+ throw(MAL, name, "%s: wkb2geos failed", name);
}
if ((outGeometry = (*func) (geosGeometry)) == NULL) {
@@ -3858,7 +3858,7 @@ wkbBorderPoint(wkb **out, wkb **geom, GE
*out = NULL;
geosGeometry = wkb2geos(*geom);
if (geosGeometry == NULL) {
- throw(MAL, name, "wkb2geos failed");
+ throw(MAL, name, "%s: wkb2geos failed", name);
}
if (GEOSGeomTypeId(geosGeometry) != GEOS_LINESTRING) {
@@ -4709,7 +4709,7 @@ wkbanalysis(wkb **out, wkb **geom1WKB, w
GEOSGeom_destroy(geom1Geometry);
if (geom2Geometry)
GEOSGeom_destroy(geom2Geometry);
- throw(MAL, name, "wkb2geos failed");
+ throw(MAL, name, "%s: wkb2geos failed", name);
}
srid = GEOSGetSRID(geom1Geometry);
@@ -5628,7 +5628,7 @@ wkbspatialXYZ(bit *out, wkb **geomWKB_a,
geosGeometry_a = wkb2geos(*geomWKB_a);
if (geosGeometry_a == NULL) {
- throw(MAL, name, "wkb2geos failed");
+ throw(MAL, name, "%s: wkb2geos failed", name);
}
/*Build Geometry b*/
@@ -7573,10 +7573,12 @@ Intersectssubjoin_intern(bat *lres, bat
rBAT_iter = bat_iterator(br);
/*Get the Geometry for the inner BAT*/
- rGeometries = (GEOSGeom*) GDKmalloc(sizeof(GEOSGeom) * BATcount(br));
+ rGeometries = (GEOSGeom*) GDKzalloc(sizeof(GEOSGeom) * BATcount(br));
BATloop(br, pr, qr) {
wkb *rWKB = (wkb *) BUNtail(rBAT_iter, pr);
- rGeometries[j] = wkb2geos(rWKB);
+ rGeometries[pr] = wkb2geos(rWKB);
+ if ( !rGeometries[pr] )
+ throw(MAL, "algebra.instersects", "wkb2geos failed");
}
lo = bl->hseqbase;
@@ -7589,6 +7591,8 @@ Intersectssubjoin_intern(bat *lres, bat
lWKB = (wkb *) BUNtail(lBAT_iter, pl);
lGeometry = wkb2geos(lWKB);
+ if ( !lGeometry )
+ throw(MAL, "algebra.instersects", "wkb2geos failed");
lMBR = mbrFromGeos(lGeometry);
if (lMBR == NULL || mbr_isnil(lMBR)) {
@@ -7612,7 +7616,7 @@ Intersectssubjoin_intern(bat *lres, bat
BBPunfix(*rid);
BBPunfix(xl->batCacheid);
BBPunfix(xr->batCacheid);
- throw(MAL, "geom.Intersects", "wkb2geos failed");
+ throw(MAL, "geom.Intersects", "One of the geometries is NULL");
}
if (GEOSGetSRID(lGeometry) != GEOSGetSRID(rGeometry)) {
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -249,6 +249,7 @@ geom_export str wkbPointOnSurface(wkb**,
geom_export str wkbForceDim(wkb**, wkb**, const int*);
geom_export str wkbForceDim_bat(bat *outBAT_id, bat *inBAT_id, const int*);
geom_export str wkbSegmentize(wkb**, wkb**, dbl*);
+geom_export str wkbSegmentize_bat(bat *outBAT_id, bat *inBAT_id, double *flag);
geom_export str wkbDump(bat* idBAT_id, bat* geomBAT_id, wkb**);
geom_export str wkbDumpP(bat* partentBAT_id, bat* idBAT_id, bat* geomBAT_id,
wkb**, int* parent);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -695,6 +695,9 @@ function Z(w:bat[:wkb]) :bat[:dbl];
return c;
end Z;
+command Segmentize(g:bat[:wkb], sz:dbl) :wkb address wkbSegmentize_bat
+comment "It creates a new geometry with all segments on it smaller or equal to
sz";
+
command ForceDimensions(g:bat[:wkb], d:int) :bat[:wkb] address wkbForceDim_bat
comment "Removes or Adds additional coordinates in the geometry to make it d
dimensions";
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -587,6 +587,107 @@ wkbForceDim_bat(bat *outBAT_id, bat *inB
{
return WKBtoWKBflagINT_bat(outBAT_id, inBAT_id, flag, wkbForceDim,
"batgeom.wkbForceDim");
}
+
+/**************************************************************************************/
+/************************* IN: wkb - OUT: wkb - flag: dbl
*****************************/
+/**************************************************************************************/
+
+static str
+WKBtoWKBflagDBL_bat(bat *outBAT_id, bat *inBAT_id, double *flag, str (*func)
(wkb **, wkb **, double *), const char *name)
+{
+ BAT *outBAT = NULL, *inBAT = NULL;
+ BUN p = 0, q = 0;
+ BATiter inBAT_iter;
+ wkb **outs = NULL;
+ str msg = MAL_SUCCEED;
+#ifdef GEOMBULK_DEBUG
+ static struct timeval start, stop;
+ unsigned long long t;
+#endif
+
+ //get the descriptor of the BAT
+ if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
+ throw(MAL, name, RUNTIME_OBJECT_MISSING);
+ }
+
+ //create a new for the output BAT
+ if ((outBAT = COLnew(inBAT->hseqbase, ATOMindex("wkb"),
BATcount(inBAT), TRANSIENT)) == NULL) {
+ BBPunfix(inBAT->batCacheid);
+ throw(MAL, name, MAL_MALLOC_FAIL);
+ }
+
+ //iterator over the input BAT
+ inBAT_iter = bat_iterator(inBAT);
+
+ omp_set_dynamic(OPENCL_DYNAMIC); // Explicitly disable dynamic teams
+ omp_set_num_threads(OPENCL_THREADS);
+ q = BUNlast(inBAT);
+#ifdef GEOMBULK_DEBUG
+ fprintf(stdout, "%s %d %d\n", name, p, q);
+ gettimeofday(&start, NULL);
+#endif
+ outs = (wkb**) GDKmalloc(sizeof(wkb*) * BATcount(inBAT));
+ //BATloop(inBAT, p, q) { //iterate over all valid elements
+ #pragma omp parallel for
+ for (p = 0; p < q; p++) {
+ str err = NULL;
+ wkb *outSingle;
+ wkb *inWKB = NULL;
+
+ inWKB = (wkb *) BUNtail(inBAT_iter, p);
+ if ((err = (*func) (&outSingle, &inWKB, flag)) != MAL_SUCCEED) {
+ msg = err;
+ #pragma omp cancelregion
+ }
+ outs[p] = outSingle;
+ //BUNappend(outBAT, outSingle, TRUE); //add the result to the
new BAT
+ //GDKfree(outSingle);
+ //outSingle = NULL;
+ }
+#ifdef GEOMBULK_DEBUG
+ gettimeofday(&stop, NULL);
+ t = 1000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) /
1000;
+ fprintf(stdout, "%s %llu ms\n", name, t);
+#endif
+
+ BBPunfix(inBAT->batCacheid);
+
+ if (msg != MAL_SUCCEED) {
+ BBPunfix(outBAT->batCacheid);
+ return msg;
+ }
+
+#ifdef GEOMBULK_DEBUG
+ gettimeofday(&start, NULL);
+#endif
+ for (p = 0; p < q; p++) {
+ BUNappend(outBAT, outs[p], TRUE); //add the point to the
new BAT
+ GDKfree(outs[p]);
+ outs[p] = NULL;
+ }
+
+ if (outs)
+ GDKfree(outs);
+#ifdef GEOMBULK_DEBUG
+ gettimeofday(&stop, NULL);
+ t = 1000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) /
1000;
+ fprintf(stdout, "batcalc.wkb BUNappend %llu ms\n", t);
+#endif
+
+ //BATsetcount(outBAT, BATcount(inBAT));
+ //BATrmprops(outBAT)
+ //BATsettrivprop(outBAT);
+ BBPkeepref(*outBAT_id = outBAT->batCacheid);
+
+ return MAL_SUCCEED;
+}
+
+str
+wkbSegmentize_bat(bat *outBAT_id, bat *inBAT_id, double *flag)
+{
+ return WKBtoWKBflagDBL_bat(outBAT_id, inBAT_id, flag, wkbSegmentize,
"batgeom.wkbSegmentize");
+}
+
/***************************************************************************/
/*************************** IN: wkb - OUT: bit ****************************/
/***************************************************************************/
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list