| 245 | } |
| 246 | |
| 247 | GEOSGeom msGEOSShape2Geometry(shapeObj *shape) |
| 248 | { |
| 249 | if(!shape) |
| 250 | return NULL; /* a NULL shape generates a NULL geometry */ |
| 251 | |
| 252 | switch(shape->type) { |
| 253 | case MS_SHAPE_POINT: |
| 254 | if(shape->numlines == 0 || shape->line[0].numpoints == 0) /* not enough info for a point */ |
| 255 | return NULL; |
| 256 | |
| 257 | if(shape->line[0].numpoints == 1) /* simple point */ |
| 258 | return msGEOSShape2Geometry_point(&(shape->line[0].point[0])); |
| 259 | else /* multi-point */ |
| 260 | return msGEOSShape2Geometry_multipoint(&(shape->line[0])); |
| 261 | break; |
| 262 | case MS_SHAPE_LINE: |
| 263 | if(shape->numlines == 0 || shape->line[0].numpoints < 2) /* not enough info for a line */ |
| 264 | return NULL; |
| 265 | |
| 266 | if(shape->numlines == 1) /* simple line */ |
| 267 | return msGEOSShape2Geometry_line(&(shape->line[0])); |
| 268 | else /* multi-line */ |
| 269 | return msGEOSShape2Geometry_multiline(shape); |
| 270 | break; |
| 271 | case MS_SHAPE_POLYGON: |
| 272 | if(shape->numlines == 0 || shape->line[0].numpoints < 4) /* not enough info for a polygon (first=last) */ |
| 273 | return NULL; |
| 274 | |
| 275 | return msGEOSShape2Geometry_polygon(shape); /* simple and multipolygon cases are addressed */ |
| 276 | break; |
| 277 | default: |
| 278 | break; |
| 279 | } |
| 280 | |
| 281 | return NULL; /* should not get here */ |
| 282 | } |
| 283 | |
| 284 | static shapeObj *msGEOSGeometry2Shape_point(GEOSGeom g) |
| 285 | { |
no test coverage detected