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

Function ogrConvertGeometry

mapogr.cpp:385–466  ·  view source on GitHub ↗

* ogrConvertGeometry() * * Convert OGR geometry into a shape object doing the best possible * job to match OGR Geometry type and layer type. * * If layer type is incompatible with geometry, then shape is returned with * shape->type = MS_SHAPE_NULL **********************************************************************/

Source from the content-addressed store, hash-verified

383 * shape->type = MS_SHAPE_NULL
384 **********************************************************************/
385static int ogrConvertGeometry(OGRGeometryH hGeom, shapeObj *outshp,
386 enum MS_LAYER_TYPE layertype)
387{
388/* ------------------------------------------------------------------
389 * Process geometry according to layer type
390 * ------------------------------------------------------------------ */
391 int nStatus = MS_SUCCESS;
392
393 if (hGeom == NULL)
394 {
395 // Empty geometry... this is not an error... we'll just skip it
396 return MS_SUCCESS;
397 }
398
399 switch(layertype)
400 {
401/* ------------------------------------------------------------------
402 * POINT layer - Any geometry can be converted to point/multipoint
403 * ------------------------------------------------------------------ */
404 case MS_LAYER_POINT:
405 if(ogrGeomPoints(hGeom, outshp) == -1)
406 {
407 nStatus = MS_FAILURE; // Error message already produced.
408 }
409 break;
410/* ------------------------------------------------------------------
411 * LINE layer
412 * ------------------------------------------------------------------ */
413 case MS_LAYER_LINE:
414 if(ogrGeomLine(hGeom, outshp, MS_FALSE) == -1)
415 {
416 nStatus = MS_FAILURE; // Error message already produced.
417 }
418 if (outshp->type != MS_SHAPE_LINE && outshp->type != MS_SHAPE_POLYGON)
419 outshp->type = MS_SHAPE_NULL; // Incompatible type for this layer
420 break;
421/* ------------------------------------------------------------------
422 * POLYGON layer
423 * ------------------------------------------------------------------ */
424 case MS_LAYER_POLYGON:
425 if(ogrGeomLine(hGeom, outshp, MS_TRUE) == -1)
426 {
427 nStatus = MS_FAILURE; // Error message already produced.
428 }
429 if (outshp->type != MS_SHAPE_POLYGON)
430 outshp->type = MS_SHAPE_NULL; // Incompatible type for this layer
431 break;
432/* ------------------------------------------------------------------
433 * MS_ANNOTATION layer - return real feature type
434 * ------------------------------------------------------------------ */
435 case MS_LAYER_ANNOTATION:
436 case MS_LAYER_CHART:
437 case MS_LAYER_QUERY:
438 switch( OGR_G_GetGeometryType( hGeom ) )
439 {
440 case wkbPoint:
441 case wkbPoint25D:
442 case wkbMultiPoint:

Callers 3

msOGRGeometryToShapeFunction · 0.85
msOGRFileNextShapeFunction · 0.85
msOGRFileGetShapeFunction · 0.85

Calls 3

ogrGeomPointsFunction · 0.85
ogrGeomLineFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected