Datum postgis_geos_version(PG_FUNCTION_ARGS);
Datum centroid(PG_FUNCTION_ARGS);
Datum polygonize_garray(PG_FUNCTION_ARGS);
+Datum linemerge(PG_FUNCTION_ARGS);
extern JTSGeometry *JTSGetGeometryN(JTSGeometry *g1, int n);
extern JTSGeometry *JTSGetExteriorRing(JTSGeometry *g1);
extern JTSGeometry *JTSGetInteriorRingN(JTSGeometry *g1,int n);
-extern JTSGeometry *JTSpolygonize(JTSGeometry **geoms, unsigned int ngeoms);
+extern JTSGeometry *JTSPolygonize(JTSGeometry **geoms, unsigned int ngeoms);
+extern JTSGeometry *JTSLineMerge(JTSGeometry *geoms);
extern int JTSGetNumInteriorRings(JTSGeometry *g1);
extern int JTSGetSRID(JTSGeometry *g1);
extern int JTSGetNumGeometries(JTSGeometry *g1);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, result);
+ profreport("jts",geom1, geom2, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, result);
+ profreport("jts",geom1, geom2, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, NULL, result);
+ profreport("jts",geom1, NULL, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, NULL, result);
+ profreport("jts",geom1, NULL, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, NULL, result);
+ profreport("jts",geom1, NULL, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, result);
+ profreport("jts",geom1, geom2, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, result);
+ profreport("jts",geom1, geom2, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, NULL, result);
+ profreport("jts",geom1, NULL, result);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom, NULL, result);
+ profreport("jts",geom, NULL, result);
#endif
PG_FREE_IF_COPY(geom, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, NULL, NULL);
+ profreport("jts",geom1, NULL, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom1, geom2, NULL);
+ profreport("jts",geom1, geom2, NULL);
#endif
PG_FREE_IF_COPY(geom1, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom, NULL, NULL);
+ profreport("jts",geom, NULL, NULL);
#endif
PG_FREE_IF_COPY(geom, 0);
#ifdef PROFILE
profstop(PROF_QRUN);
- profreport("geos",geom, NULL, NULL);
+ profreport("jts",geom, NULL, NULL);
#endif
PG_FREE_IF_COPY(geom, 0);
elog(NOTICE, "polygonize_garray: invoking JTSpolygonize");
#endif
- geos_result = JTSpolygonize(vgeoms, nelems);
+ geos_result = JTSPolygonize(vgeoms, nelems);
#ifdef PGIS_DEBUG
elog(NOTICE, "polygonize_garray: JTSpolygonize returned");
#endif
}
+PG_FUNCTION_INFO_V1(linemerge);
+Datum linemerge(PG_FUNCTION_ARGS)
+{
+ PG_LWGEOM *geom1;
+ double size;
+ JTSGeometry *g1,*g3;
+ PG_LWGEOM *result;
+ int quadsegs = 8; // the default
+
+#ifdef PROFILE
+ profstart(PROF_QRUN);
+#endif
+
+ geom1 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
+ initJTS(lwnotice);
+
+#ifdef PROFILE
+ profstart(PROF_P2G1);
+#endif
+ g1 = POSTGIS2JTS(geom1);
+#ifdef PROFILE
+ profstop(PROF_P2G1);
+#endif
+
+#ifdef PROFILE
+ profstart(PROF_GRUN);
+#endif
+ g3 = JTSLineMerge(g1);
+#ifdef PROFILE
+ profstop(PROF_GRUN);
+#endif
+
+ if (g3 == NULL)
+ {
+ elog(ERROR,"JTS LineMerge() threw an error!");
+ PG_RETURN_NULL(); //never get here
+ }
+
+
+// elog(NOTICE,"result: %s", GEOSasText(g3) ) ;
+
+ JTSSetSRID(g3, pglwgeom_getSRID(geom1));
+
+#ifdef PROFILE
+ profstart(PROF_G2P);
+#endif
+ result = JTS2POSTGIS(g3, TYPE_NDIMS(geom1->type) > 2);
+#ifdef PROFILE
+ profstop(PROF_G2P);
+#endif
+ if (result == NULL)
+ {
+ elog(ERROR,"JTS LineMerge() threw an error (result postgis geometry formation)!");
+ PG_RETURN_NULL(); //never get here
+ }
+
+ //compressType(result); // convert multi* to single item if appropriate
+
+#ifdef PROFILE
+ profstop(PROF_QRUN);
+ profreport("jts",geom1, NULL, result);
+#endif
+
+ PG_FREE_IF_COPY(geom1, 0);
+
+ PG_RETURN_POINTER(result);
+}
+
Datum GEOSnoop(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(GEOSnoop);
Datum GEOSnoop(PG_FUNCTION_ARGS)