MCPcopy Index your code
hub / github.com/MapServer/MapServer / msOGRShapeFromWKT

Function msOGRShapeFromWKT

mapogr.cpp:3796–3838  ·  view source on GitHub ↗

/ msOGRShapeFromWKT() */ /

Source from the content-addressed store, hash-verified

3794/* msOGRShapeFromWKT() */
3795/************************************************************************/
3796shapeObj *msOGRShapeFromWKT(const char *string)
3797{
3798#ifdef USE_OGR
3799 OGRGeometryH hGeom = NULL;
3800 shapeObj *shape=NULL;
3801
3802 if(!string)
3803 return NULL;
3804
3805 ACQUIRE_OLD_OGR_LOCK;
3806 if( OGR_G_CreateFromWkt( (char **)&string, NULL, &hGeom ) != OGRERR_NONE )
3807 {
3808 msSetError(MS_OGRERR, "Failed to parse WKT string.",
3809 "msOGRShapeFromWKT()" );
3810 RELEASE_OLD_OGR_LOCK;
3811 return NULL;
3812 }
3813
3814 /* Initialize a corresponding shapeObj */
3815
3816 shape = (shapeObj *) malloc(sizeof(shapeObj));
3817 msInitShape(shape);
3818
3819 /* translate WKT into an OGRGeometry. */
3820
3821 if( msOGRGeometryToShape( hGeom, shape,
3822 wkbFlatten(OGR_G_GetGeometryType(hGeom)) )
3823 == MS_FAILURE )
3824 {
3825 RELEASE_OLD_OGR_LOCK;
3826 free( shape );
3827 return NULL;
3828 }
3829
3830 OGR_G_DestroyGeometry( hGeom );
3831
3832 RELEASE_OLD_OGR_LOCK;
3833 return shape;
3834#else
3835 msSetError(MS_OGRERR, "OGR support is not available.","msOGRShapeFromWKT()");
3836 return NULL;
3837#endif
3838}
3839
3840/************************************************************************/
3841/* msOGRShapeToWKT() */

Callers 1

msShapeFromWKTFunction · 0.85

Calls 3

msSetErrorFunction · 0.85
msInitShapeFunction · 0.85
msOGRGeometryToShapeFunction · 0.85

Tested by

no test coverage detected