<funcdef>geometry <function>ST_ForceSFS</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
</funcprototype>
+ <funcprototype>
+ <funcdef>geometry <function>ST_ForceSFS</function></funcdef>
+ <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+ <paramdef><type>text </type> <parameter>version</parameter></paramdef>
+ </funcprototype>
</funcsynopsis>
</refsynopsisdiv>
char *tmp;
g = lwgeom_from_wkt(in, LW_PARSER_CHECK_NONE);
- h = lwgeom_force_sfs(g);
+ h = lwgeom_force_sfs(g, 110);
tmp = lwgeom_to_ewkt(h);
if (strcmp(tmp, out))
fprintf(stderr, "\nIn: %s\nOut: %s\nExp: %s\n",
LWGEOM *g, *h;
g = lwgeom_from_wkt(in, LW_PARSER_CHECK_NONE);
- h = lwgeom_force_sfs(g);
+ h = lwgeom_force_sfs(g, 110);
if(h->type != type)
fprintf(stderr, "\nIn: %s\nOut: %s\nExp: %s\n",
in, lwtype_name(h->type), lwtype_name(type));
* Force to use SFS 1.1 geometry type
* (rather than SFS 1.2 and/or SQL/MM)
*/
-extern LWGEOM* lwgeom_force_sfs(LWGEOM *geom);
+extern LWGEOM* lwgeom_force_sfs(LWGEOM *geom, int version);
/*--------------------------------------------------------
}
LWGEOM*
-lwgeom_force_sfs(LWGEOM *geom)
+lwgeom_force_sfs(LWGEOM *geom, int version)
{
LWCOLLECTION *col;
int i;
LWGEOM *g;
+ /* SFS 1.2 version */
+ if (version == 120)
+ {
+ switch(geom->type)
+ {
+ /* SQL/MM types */
+ case CIRCSTRINGTYPE:
+ case COMPOUNDTYPE:
+ case CURVEPOLYTYPE:
+ case MULTICURVETYPE:
+ case MULTISURFACETYPE:
+ return lwgeom_segmentize(geom, 32);
+
+ case COLLECTIONTYPE:
+ col = (LWCOLLECTION*)geom;
+ for ( i = 0; i < col->ngeoms; i++ )
+ col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
+
+ return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
+
+ default:
+ return (LWGEOM *)geom;
+ }
+ }
+
+ /* SFS 1.1 version */
switch(geom->type)
{
/* SQL/MM types */
case COLLECTIONTYPE:
col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
- col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i]);
+ col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
GSERIALIZED *result;
LWGEOM *lwgeom;
LWGEOM *ogeom;
+ text * ver;
+ int version = 110; /* default version is SFS 1.1 */
POSTGIS_DEBUG(2, "LWGEOM_force_sfs called");
+ /* If user specified version, respect it */
+ if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
+ {
+ ver = PG_GETARG_TEXT_P(1);
+
+ if ( ! strncmp(VARDATA(ver), "1.2", 3))
+ {
+ version = 120;
+ }
+ }
+
lwgeom = lwgeom_from_gserialized(geom);
- ogeom = lwgeom_force_sfs(lwgeom);
+ ogeom = lwgeom_force_sfs(lwgeom, version);
result = geometry_serialize(ogeom);
AS 'MODULE_PATHNAME', 'LWGEOM_force_sfs'
LANGUAGE 'c' IMMUTABLE STRICT;
+-- Availability: 2.1.0
+CREATE OR REPLACE FUNCTION ST_ForceSFS(geometry, version text)
+ RETURNS geometry
+ AS 'MODULE_PATHNAME', 'LWGEOM_force_sfs'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Expand(box3d,float8)
RETURNS box3d