Changeset 12394

Show
Ignore:
Timestamp:
10/13/07 00:12:13 (1 year ago)
Author:
hobu
Message:

apply patch for #1871 to expose GEOS IsValid?, IsEmpty?, and IsRing?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogr_api.h

    r11873 r12394  
    122122void   CPL_DLL OGR_G_Empty( OGRGeometryH ); 
    123123int    CPL_DLL OGR_G_IsEmpty (OGRGeometryH ); 
     124int    CPL_DLL OGR_G_IsValid (OGRGeometryH ); 
     125int    CPL_DLL OGR_G_IsSimple (OGRGeometryH ); 
     126int    CPL_DLL OGR_G_IsRing (OGRGeometryH ); 
    124127 
    125128/* backward compatibility */ 
  • trunk/gdal/ogr/ogr_geometry.h

    r11885 r12394  
    8686    virtual int getCoordinateDimension() const; 
    8787    virtual OGRBoolean  IsEmpty() const;  
    88     virtual OGRBoolean  IsSimple() const { return 1; } 
     88    virtual OGRBoolean  IsValid() const; 
     89    virtual OGRBoolean  IsSimple() const; 
     90    virtual OGRBoolean  IsRing() const; 
    8991    virtual void        empty() = 0; 
    9092    virtual OGRGeometry *clone() const = 0; 
  • trunk/gdal/ogr/ogrgeometry.cpp

    r12016 r12394  
    11371137   return ((OGRGeometry *) hGeom)->IsEmpty(); 
    11381138} 
     1139 
     1140/************************************************************************/ 
     1141/*                              IsValid()                               */ 
     1142/************************************************************************/ 
     1143 
     1144/** 
     1145 * Test if the geometry is valid 
     1146 * 
     1147 * This method is the same as the C function OGR_G_IsValid(). 
     1148 * 
     1149 * This method is built on the GEOS library, check it for the definition 
     1150 * of the geometry operation. 
     1151 * If OGR is built without the GEOS library, this method will always return  
     1152 * FALSE.  
     1153 * 
     1154 * 
     1155 * @return TRUE if the geometry has no points, otherwise FALSE.   
     1156 */ 
     1157 
     1158OGRBoolean 
     1159OGRGeometry::IsValid(  ) const 
     1160 
     1161{ 
     1162#ifndef HAVE_GEOS 
     1163 
     1164    return FALSE; 
     1165 
     1166#else 
     1167 
     1168    OGRBoolean bResult = FALSE; 
     1169    GEOSGeom hThisGeosGeom = NULL; 
     1170     
     1171    hThisGeosGeom = exportToGEOS(); 
     1172 
     1173    if( hThisGeosGeom != NULL  ) 
     1174    { 
     1175        bResult = GEOSisValid( hThisGeosGeom ); 
     1176        GEOSGeom_destroy( hThisGeosGeom ); 
     1177    } 
     1178 
     1179    return bResult; 
     1180 
     1181#endif /* HAVE_GEOS */ 
     1182} 
     1183 
     1184int OGR_G_IsValid( OGRGeometryH hGeom ) 
     1185 
     1186{ 
     1187   return ((OGRGeometry *) hGeom)->IsValid(); 
     1188} 
     1189 
     1190/************************************************************************/ 
     1191/*                              IsSimple()                               */ 
     1192/************************************************************************/ 
     1193 
     1194/** 
     1195 * Test if the geometry is simple 
     1196 * 
     1197 * This method is the same as the C function OGR_G_IsSimple(). 
     1198 * 
     1199 * This method is built on the GEOS library, check it for the definition 
     1200 * of the geometry operation. 
     1201 * If OGR is built without the GEOS library, this method will always return  
     1202 * FALSE.  
     1203 * 
     1204 * 
     1205 * @return TRUE if the geometry has no points, otherwise FALSE.   
     1206 */ 
     1207 
     1208OGRBoolean 
     1209OGRGeometry::IsSimple(  ) const 
     1210 
     1211{ 
     1212#ifndef HAVE_GEOS 
     1213 
     1214    return FALSE; 
     1215 
     1216#else 
     1217 
     1218    OGRBoolean bResult = FALSE; 
     1219    GEOSGeom hThisGeosGeom = NULL; 
     1220     
     1221    hThisGeosGeom = exportToGEOS(); 
     1222 
     1223    if( hThisGeosGeom != NULL  ) 
     1224    { 
     1225        bResult = GEOSisSimple( hThisGeosGeom ); 
     1226        GEOSGeom_destroy( hThisGeosGeom ); 
     1227    } 
     1228 
     1229    return bResult; 
     1230 
     1231#endif /* HAVE_GEOS */ 
     1232} 
     1233 
     1234int OGR_G_IsSimple( OGRGeometryH hGeom ) 
     1235 
     1236{ 
     1237   return ((OGRGeometry *) hGeom)->IsSimple(); 
     1238} 
     1239 
     1240/************************************************************************/ 
     1241/*                              IsRing()                               */ 
     1242/************************************************************************/ 
     1243 
     1244/** 
     1245 * Test if the geometry is a ring 
     1246 * 
     1247 * This method is the same as the C function OGR_G_IsRing(). 
     1248 * 
     1249 * This method is built on the GEOS library, check it for the definition 
     1250 * of the geometry operation. 
     1251 * If OGR is built without the GEOS library, this method will always return  
     1252 * FALSE.  
     1253 * 
     1254 * 
     1255 * @return TRUE if the geometry has no points, otherwise FALSE.   
     1256 */ 
     1257 
     1258OGRBoolean 
     1259OGRGeometry::IsRing(  ) const 
     1260 
     1261{ 
     1262#ifndef HAVE_GEOS 
     1263 
     1264    return FALSE; 
     1265 
     1266#else 
     1267 
     1268    OGRBoolean bResult = FALSE; 
     1269    GEOSGeom hThisGeosGeom = NULL; 
     1270     
     1271    hThisGeosGeom = exportToGEOS(); 
     1272 
     1273    if( hThisGeosGeom != NULL  ) 
     1274    { 
     1275        bResult = GEOSisRing( hThisGeosGeom ); 
     1276        GEOSGeom_destroy( hThisGeosGeom ); 
     1277    } 
     1278 
     1279    return bResult; 
     1280 
     1281#endif /* HAVE_GEOS */ 
     1282} 
     1283 
     1284int OGR_G_IsRing( OGRGeometryH hGeom ) 
     1285 
     1286{ 
     1287   return ((OGRGeometry *) hGeom)->IsRing(); 
     1288} 
     1289 
    11391290/************************************************************************/ 
    11401291/*                       OGRGeometryTypeToName()                        */ 
  • trunk/gdal/swig/include/ogr.i

    r11760 r12394  
    12611261    return OGR_G_IsEmpty(self); 
    12621262  }   
     1263   
     1264  bool IsValid () { 
     1265    return OGR_G_IsValid(self); 
     1266  }   
     1267   
     1268  bool IsSimple () { 
     1269    return OGR_G_IsSimple(self); 
     1270  }   
     1271   
     1272  bool IsRing () { 
     1273    return OGR_G_IsRing(self); 
     1274  }   
     1275   
    12631276  bool Intersect (OGRGeometryShadow* other) { 
    12641277    return OGR_G_Intersect(self, other);