[geos-commits] r2300 - trunk/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Mon Mar 23 20:19:33 EDT 2009
Author: mloskot
Date: 2009-03-23 20:19:33 -0400 (Mon, 23 Mar 2009)
New Revision: 2300
Modified:
trunk/capi/geos_c.cpp
trunk/capi/geos_c.h.in
trunk/capi/geos_ts_c.cpp
Log:
Fixed GEOSSetSRID_r missing, GEOSSetSRID duplicated (Ticket #242). A little of refactoring.
Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp 2009-03-23 23:50:08 UTC (rev 2299)
+++ trunk/capi/geos_c.cpp 2009-03-24 00:19:33 UTC (rev 2300)
@@ -455,11 +455,17 @@
}
int
-GEOSGetSRID(const Geometry *g1)
+GEOSGetSRID(const Geometry *g)
{
- return GEOSGetSRID_r( handle, g1 );
+ return GEOSGetSRID_r( handle, g );
}
+void
+GEOSSetSRID(Geometry *g, int srid)
+{
+ GEOSSetSRID_r( handle, g, srid );
+}
+
char
GEOSHasZ(const Geometry *g)
{
Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in 2009-03-23 23:50:08 UTC (rev 2299)
+++ trunk/capi/geos_c.h.in 2009-03-24 00:19:33 UTC (rev 2300)
@@ -591,13 +591,14 @@
/* Return 0 on exception */
extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g1);
-extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
-
extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1);
-extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
+extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int srid);
+extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
+ GEOSGeometry* g, int srid);
+
/* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
* for non-multi geometries. Older GEOS versions only accept
* GeometryCollections or Multi* geometries here, and are likely to crash
Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp 2009-03-23 23:50:08 UTC (rev 2299)
+++ trunk/capi/geos_ts_c.cpp 2009-03-24 00:19:33 UTC (rev 2300)
@@ -1578,17 +1578,6 @@
}
}
-void
-GEOSSetSRID(Geometry *g, int SRID)
-{
- assert(0 != g);
- if (0 != g)
- {
- g->setSRID(SRID);
- }
-}
-
-
int
GEOSGetNumCoordinates_r(GEOSContextHandle_t extHandle, const Geometry *g1)
{
@@ -2125,7 +2114,7 @@
#endif
std::vector<Geometry *>*geoms = new std::vector<Geometry *>(lines->size());
- for (int i = 0; i < lines->size(); ++i)
+ for (std::size_t i = 0; i < lines->size(); ++i)
{
(*geoms)[i] = (*lines)[i];
}
@@ -2151,8 +2140,10 @@
}
int
-GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry *g1)
+GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry *g)
{
+ assert(0 != g);
+
if ( 0 == extHandle )
{
return 0;
@@ -2167,7 +2158,7 @@
try
{
- return g1->getSRID();
+ return g->getSRID();
}
catch (const std::exception &e)
{
@@ -2181,6 +2172,35 @@
return 0;
}
+void
+GEOSSetSRID_r(GEOSContextHandle_t extHandle, Geometry *g, int srid)
+{
+ assert(0 != g);
+
+ if ( 0 == extHandle )
+ {
+ return;
+ }
+
+ GEOSContextHandleInternal_t *handle = 0;
+ handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+ if ( 0 != handle->initialized && 0 != g)
+ {
+ try
+ {
+ g->setSRID(srid);
+ }
+ catch (const std::exception &e)
+ {
+ handle->ERROR_MESSAGE("%s", e.what());
+ }
+ catch (...)
+ {
+ handle->ERROR_MESSAGE("Unknown exception thrown");
+ }
+ }
+}
+
const char* GEOSversion()
{
return GEOS_CAPI_VERSION;
More information about the geos-commits
mailing list