MCPcopy Create free account
hub / github.com/MapServer/MapServer / msGEOSDistance

Function msGEOSDistance

mapgeos.c:1223–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1221}
1222
1223double msGEOSDistance(shapeObj *shape1, shapeObj *shape2)
1224{
1225#ifdef USE_GEOS
1226 GEOSGeom g1, g2;
1227 double distance;
1228 int result;
1229
1230 if(!shape1 || !shape2)
1231 return -1;
1232
1233 if(!shape1->geometry) /* if no geometry for shape1 then build one */
1234 shape1->geometry = (GEOSGeom) msGEOSShape2Geometry(shape1);
1235 g1 = (GEOSGeom) shape1->geometry;
1236 if(!g1) return -1;
1237
1238 if(!shape2->geometry) /* if no geometry for shape2 then build one */
1239 shape2->geometry = (GEOSGeom) msGEOSShape2Geometry(shape2);
1240 g2 = (GEOSGeom) shape2->geometry;
1241 if(!g2) return -1;
1242
1243 result = GEOSDistance(g1, g2, &distance);
1244 return ((result==0) ? -1 : distance);
1245#else
1246 return msDistanceShapeToShape(shape1, shape2); /* fall back on brute force method (for MapScript) */
1247#endif
1248}

Callers 1

yyparseFunction · 0.85

Calls 2

msGEOSShape2GeometryFunction · 0.85
msDistanceShapeToShapeFunction · 0.85

Tested by

no test coverage detected