[ TAINING ]
GeometryN(geometry,integer) *LWG*
InteriorRingN(geometry,integer) *LWG*
- simplify(geometry, float8) *SRL* *EXP*
+ simplify(geometry, float8) *SRL* (*EXP*)
#### could use WHEN_SIMPLE
#### translating and transforming an eventually present
* Evaluate with an heuristic if the provided PG_LWGEOM is worth
* caching a bbox
*/
-char is_worth_caching_pglwgeom_bbox(PG_LWGEOM *);
-char is_worth_caching_lwgeom_bbox(LWGEOM *);
+char is_worth_caching_pglwgeom_bbox(const PG_LWGEOM *);
+char is_worth_caching_serialized_bbox(const char *);
+char is_worth_caching_lwgeom_bbox(const LWGEOM *);
/*
* Use this macro to extract the char * required
// get the SRID from the LWGEOM
// none present => -1
-extern int lwgeom_getSRID(PG_LWGEOM *lwgeom);
+extern int pglwgeom_getSRID(PG_LWGEOM *lwgeom);
extern int lwgeom_getsrid(char *serialized);
-extern PG_LWGEOM *lwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID);
+extern PG_LWGEOM *pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID);
//get bounding box of LWGEOM (automatically calls the sub-geometries bbox generators)
extern BOX3D *lw_geom_getBB(char *serialized_form);
// get the SRID from the LWGEOM
// none present => -1
-int lwgeom_getSRID(PG_LWGEOM *lwgeom)
+int pglwgeom_getSRID(PG_LWGEOM *lwgeom)
{
unsigned char type = lwgeom->type;
char *loc = lwgeom->data;
return get_int32(loc);
}
-// Set the SRID of a LWGEOM
-// Returns a newly allocated LWGEOM object.
+// Set the SRID of a PG_LWGEOM
+// Returns a newly allocated PG_LWGEOM object.
// Allocation will be done using the lwalloc.
PG_LWGEOM *
-lwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID)
+pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID)
{
unsigned char type = lwgeom->type;
int bbox_offset=0; //0=no bbox, otherwise sizeof(BOX2DFLOAT4)
PG_LWGEOM *result;
/* COMPUTE_BBOX FOR_COMPLEX_GEOMS */
- if ( is_worth_caching_pglwgeom_bbox(ser) )
+ if ( is_worth_caching_serialized_bbox(ser) )
{
// if ( ! wantbbox ) elog(NOTICE, "PG_LWGEOM_construct forced wantbbox=1 due to rule FOR_COMPLEX_GEOMS");
wantbbox=1;
elog(NOTICE, "lwgeom_lt called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
elog(NOTICE, "lwgeom_le called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
elog(NOTICE, "lwgeom_eq called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
elog(NOTICE, "lwgeom_ge called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
elog(NOTICE, "lwgeom_gt called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
elog(NOTICE, "lwgeom_cmp called");
#endif
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,
"Operation on two GEOMETRIES with different SRIDs\n");
/***********************************************************
*
* $Log$
+ * Revision 1.6 2005/01/05 12:44:47 strk
+ * Added is_worth_caching_serialized_bbox(). Renamed lwgeom_setSRID() to
+ * pglwgeom_setSRID(). Fixed a bug in PG_LWGEOM_construct support for
+ * AUTOCACHE_BBOX.
+ *
* Revision 1.5 2004/09/29 10:50:30 strk
* Big layout change.
* lwgeom.h is public API
// copy 2 (see above)
result = PG_LWGEOM_construct(serialized,
- lwgeom_getSRID(geom), lwgeom_hasBBOX(geom->type));
+ pglwgeom_getSRID(geom), lwgeom_hasBBOX(geom->type));
PG_RETURN_POINTER(result);
}
geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
geom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
line2 = lwline_deserialize(SERIALIZED_FORM(geom2));
if ( line2 == NULL ) PG_RETURN_NULL(); // not a linestring
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
if ( ! compute_serialized_bbox_p(srl, getbox2d_internal(srl)) )
{
oldgeom = geom;
- geom = PG_LWGEOM_construct(srl, lwgeom_getSRID(geom), 0);
+ geom = PG_LWGEOM_construct(srl, pglwgeom_getSRID(geom), 0);
lwfree(oldgeom);
}
}
elog(NOTICE, "LWGEOM_collect(%s, %s): call", lwgeom_typename(TYPE_GETTYPE(pglwgeom1->type)), lwgeom_typename(TYPE_GETTYPE(pglwgeom2->type)));
#endif
- if ( lwgeom_getSRID(pglwgeom1) != lwgeom_getSRID(pglwgeom2) )
+ if ( pglwgeom_getSRID(pglwgeom1) != pglwgeom_getSRID(pglwgeom2) )
{
elog(ERROR, "Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
PG_RETURN_NULL();
}
- if ( lwgeom_getSRID(pglwg1) != lwgeom_getSRID(pglwg2) )
+ if ( pglwgeom_getSRID(pglwg1) != pglwgeom_getSRID(pglwg2) )
{
elog(ERROR, "Operation with two geometries with different SRIDs\n");
PG_RETURN_NULL();
{
PG_LWGEOM *geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
int type = lwgeom_getType(geom->type);
- int SRID = lwgeom_getSRID(geom);
+ int SRID = pglwgeom_getSRID(geom);
LWGEOM_EXPLODED *exp = lwgeom_explode(SERIALIZED_FORM(geom));
LWPOLY *poly=NULL;
LWPOINT *point;
if ( ! i )
{
geos_result = POSTGIS2GEOS(geom);
- SRID = lwgeom_getSRID(geom);
+ SRID = pglwgeom_getSRID(geom);
#ifdef DEBUG
elog(NOTICE, "first geom is a %s", lwgeom_typename(TYPE_GETTYPE(geom->type)));
#endif
}
else
{
- if ( SRID != lwgeom_getSRID(geom) )
+ if ( SRID != pglwgeom_getSRID(geom) )
{
elog(ERROR,
"Operation on mixed SRID geometries");
is3d = ( TYPE_NDIMS(geom1->type) > 2 ) ||
( TYPE_NDIMS(geom2->type) > 2 );
- SRID = lwgeom_getSRID(geom1);
- if ( SRID != lwgeom_getSRID(geom2) )
+ SRID = pglwgeom_getSRID(geom1);
+ if ( SRID != pglwgeom_getSRID(geom2) )
{
elog(ERROR, "Operation on two geometries with different SRIDs");
PG_RETURN_NULL();
is3d = ( TYPE_NDIMS(geom1->type) > 2 ) ||
( TYPE_NDIMS(geom2->type) > 2 );
- SRID = lwgeom_getSRID(geom1);
- if ( SRID != lwgeom_getSRID(geom2) )
+ SRID = pglwgeom_getSRID(geom1);
+ if ( SRID != pglwgeom_getSRID(geom2) )
{
elog(ERROR, "Operation on two geometries with different SRIDs");
PG_RETURN_NULL();
geom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- SRID = lwgeom_getSRID(geom1);
+ SRID = pglwgeom_getSRID(geom1);
initGEOS(MAXIMUM_ALIGNOF);
#endif
geom1 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- SRID = lwgeom_getSRID(geom1);
+ SRID = pglwgeom_getSRID(geom1);
initGEOS(MAXIMUM_ALIGNOF);
// elog(NOTICE,"result: %s", GEOSasText(g3) ) ;
- GEOSSetSRID(g3, lwgeom_getSRID(geom1));
+ GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
#ifdef PROFILE
profstart(PROF_G2P);
is3d = ( TYPE_NDIMS(geom1->type) > 2 ) ||
( TYPE_NDIMS(geom2->type) > 2 );
- SRID = lwgeom_getSRID(geom1);
- if ( SRID != lwgeom_getSRID(geom2) )
+ SRID = pglwgeom_getSRID(geom1);
+ if ( SRID != pglwgeom_getSRID(geom2) )
{
elog(ERROR, "Operation on two geometries with different SRIDs");
PG_RETURN_NULL();
is3d = ( TYPE_NDIMS(geom1->type) > 2 ) ||
( TYPE_NDIMS(geom2->type) > 2 );
- SRID = lwgeom_getSRID(geom1);
- if ( SRID != lwgeom_getSRID(geom2) )
+ SRID = pglwgeom_getSRID(geom1);
+ if ( SRID != pglwgeom_getSRID(geom2) )
{
elog(ERROR, "Operation on two geometries with different SRIDs");
PG_RETURN_NULL();
// elog(NOTICE,"result: %s", GEOSasText(g3) ) ;
- GEOSSetSRID(g3, lwgeom_getSRID(geom1));
+ GEOSSetSRID(g3, pglwgeom_getSRID(geom1));
#ifdef PROFILE
profstart(PROF_G2P);
#endif
PG_RETURN_NULL();
}
- GEOSSetSRID(geosresult, lwgeom_getSRID(geom));
+ GEOSSetSRID(geosresult, pglwgeom_getSRID(geom));
#ifdef PROFILE
profstart(PROF_G2P);
vgeoms[i] = POSTGIS2GEOS(geom);
if ( ! i )
{
- SRID = lwgeom_getSRID(geom);
+ SRID = pglwgeom_getSRID(geom);
}
else
{
- if ( SRID != lwgeom_getSRID(geom) )
+ if ( SRID != pglwgeom_getSRID(geom) )
{
elog(ERROR, "polygonize: operation on mixed SRID geometries");
PG_RETURN_NULL();
}
char
-is_worth_caching_pglwgeom_bbox(PG_LWGEOM *in)
+is_worth_caching_pglwgeom_bbox(const PG_LWGEOM *in)
{
#if ! AUTOCACHE_BBOX
return false;
}
char
-is_worth_caching_lwgeom_bbox(LWGEOM *in)
+is_worth_caching_serialized_bbox(const char *in)
+{
+#if ! AUTOCACHE_BBOX
+ return false;
+#endif
+ if ( TYPE_GETTYPE((unsigned char)in[0]) == POINTTYPE ) return false;
+ return true;
+}
+
+char
+is_worth_caching_lwgeom_bbox(const LWGEOM *in)
{
#if ! AUTOCACHE_BBOX
return false;
PG_FUNCTION_INFO_V1(LWGEOM_getSRID);
Datum LWGEOM_getSRID(PG_FUNCTION_ARGS)
{
- PG_LWGEOM *lwgeom = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- int srid = lwgeom_getSRID (lwgeom);
-
+ PG_LWGEOM *pglwgeom=(PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ int srid = pglwgeom_getSRID (pglwgeom);
PG_RETURN_INT32(srid);
}
int newSRID = PG_GETARG_INT32(1);
PG_LWGEOM *result;
- result = lwgeom_setSRID(lwgeom, newSRID);
+ result = pglwgeom_setSRID(lwgeom, newSRID);
PG_RETURN_POINTER(result);
}
TYPE_HASZ(line->type), TYPE_HASM(line->type), 1);
// Construct an LWPOINT
- point = lwpoint_construct(lwgeom_getSRID(geom),
+ point = lwpoint_construct(pglwgeom_getSRID(geom),
NULL, pts);
// Serialized the point
// And we construct the line
// TODO: use serialize_buf above, instead ..
result = PG_LWGEOM_construct(serializedpoint,
- lwgeom_getSRID(geom), 0);
+ pglwgeom_getSRID(geom), 0);
pfree(point);
pfree(serializedpoint);
TYPE_HASM(line->type), 1);
// Construct an LWPOINT
- point = lwpoint_construct(lwgeom_getSRID(geom), NULL, pts);
+ point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts);
// Serialized the point
serializedpoint = lwpoint_serialize(point);
// And we construct the line (copy again)
- result = PG_LWGEOM_construct(serializedpoint, lwgeom_getSRID(geom),
+ result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom),
0);
pfree(point);
TYPE_HASM(line->type), 1);
// Construct an LWPOINT
- point = lwpoint_construct(lwgeom_getSRID(geom), NULL, pts);
+ point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts);
// Serialized the point
serializedpoint = lwpoint_serialize(point);
// And we construct the line (copy again)
- result = PG_LWGEOM_construct(serializedpoint, lwgeom_getSRID(geom),
+ result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom),
0);
pfree(point);
int32 SRID;
PG_LWGEOM *result = NULL;
- if ( lwgeom_getSRID(geom) != -1 || TYPE_GETZM(geom->type) != 0 )
+ if ( pglwgeom_getSRID(geom) != -1 || TYPE_GETZM(geom->type) != 0 )
{
elog(WARNING, "OGC WKT expected, EWKT provided - use GeomFromEWKT() for this");
}
if ( PG_NARGS() > 1 )
{
SRID = PG_GETARG_INT32(1);
- if ( SRID != lwgeom_getSRID(geom) )
+ if ( SRID != pglwgeom_getSRID(geom) )
{
- result = lwgeom_setSRID(geom, SRID);
+ result = pglwgeom_setSRID(geom, SRID);
pfree(geom);
}
}
geom = (PG_LWGEOM *)DatumGetPointer(DirectFunctionCall1(
LWGEOMFromWKB, PG_GETARG_DATUM(0)));
- if ( lwgeom_getSRID(geom) != -1 || TYPE_GETZM(geom->type) != 0 )
+ if ( pglwgeom_getSRID(geom) != -1 || TYPE_GETZM(geom->type) != 0 )
{
elog(WARNING, "OGC WKB expected, EWKB provided - use GeometryFromEWKB() for this");
}
if ( PG_NARGS() > 1 )
{
SRID = PG_GETARG_INT32(1);
- if ( SRID != lwgeom_getSRID(geom) )
+ if ( SRID != pglwgeom_getSRID(geom) )
{
- result = lwgeom_setSRID(geom, SRID);
+ result = pglwgeom_setSRID(geom, SRID);
pfree(geom);
}
}
LWPOINT *point1, *point2;
POINT2D *p1, *p2;
- if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ if (pglwgeom_getSRID(geom1) != pglwgeom_getSRID(geom2))
{
elog(ERROR, "LWGEOM_distance_ellipsoid_point: Operation on two GEOMETRIES with different SRIDs\n");
PG_RETURN_NULL();
}
geom = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- if (lwgeom_getSRID(geom) == -1)
+ if (pglwgeom_getSRID(geom) == -1)
{
PG_FREE_IF_COPY(geom, 0);
elog(ERROR,"tranform: source SRID = -1");
}
// This call will always copy given geometry
- result = lwgeom_setSRID(geom, result_srid);
+ result = pglwgeom_setSRID(geom, result_srid);
PG_FREE_IF_COPY(geom, 0);
input_proj4_text = (PG_GETARG_TEXT_P(1));
if ( ! compute_serialized_bbox_p(srl, getbox2d_internal(srl)) )
{
oldgeom = result;
- result = PG_LWGEOM_construct(srl, lwgeom_getSRID(result), 0);
+ result = PG_LWGEOM_construct(srl, pglwgeom_getSRID(result), 0);
lwfree(oldgeom);
}
}