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

Function msOGRShapeToWKT

mapogr.cpp:3843–3982  ·  view source on GitHub ↗

/ msOGRShapeToWKT() */ /

Source from the content-addressed store, hash-verified

3841/* msOGRShapeToWKT() */
3842/************************************************************************/
3843char *msOGRShapeToWKT(shapeObj *shape)
3844{
3845#ifdef USE_OGR
3846 OGRGeometryH hGeom = NULL;
3847 int i;
3848 char *wkt = NULL;
3849
3850 if(!shape)
3851 return NULL;
3852
3853 ACQUIRE_OLD_OGR_LOCK;
3854 if( shape->type == MS_SHAPE_POINT && shape->numlines == 1
3855 && shape->line[0].numpoints == 1 )
3856 {
3857 hGeom = OGR_G_CreateGeometry( wkbPoint );
3858#if GDAL_VERSION_NUM >= 1310
3859 OGR_G_SetPoint_2D( hGeom, 0,
3860 shape->line[0].point[0].x,
3861 shape->line[0].point[0].y );
3862#else
3863 OGR_G_SetPoint( hGeom, 0,
3864 shape->line[0].point[0].x,
3865 shape->line[0].point[0].y,
3866 0.0 );
3867#endif
3868 }
3869 else if( shape->type == MS_SHAPE_POINT && shape->numlines == 1
3870 && shape->line[0].numpoints > 1 )
3871 {
3872 hGeom = OGR_G_CreateGeometry( wkbMultiPoint );
3873 for( i = 0; i < shape->line[0].numpoints; i++ )
3874 {
3875 OGRGeometryH hPoint;
3876
3877 hPoint = OGR_G_CreateGeometry( wkbPoint );
3878#if GDAL_VERSION_NUM >= 1310
3879 OGR_G_SetPoint_2D( hPoint, 0,
3880 shape->line[0].point[i].x,
3881 shape->line[0].point[i].y );
3882#else
3883 OGR_G_SetPoint( hPoint, 0,
3884 shape->line[0].point[i].x,
3885 shape->line[0].point[i].y,
3886 0.0 );
3887#endif
3888 OGR_G_AddGeometryDirectly( hGeom, hPoint );
3889 }
3890 }
3891 else if( shape->type == MS_SHAPE_LINE && shape->numlines == 1 )
3892 {
3893 hGeom = OGR_G_CreateGeometry( wkbLineString );
3894 for( i = 0; i < shape->line[0].numpoints; i++ )
3895 {
3896#if GDAL_VERSION_NUM >= 1310
3897 OGR_G_AddPoint_2D( hGeom,
3898 shape->line[0].point[i].x,
3899 shape->line[0].point[i].y );
3900#else

Callers 1

msShapeToWKTFunction · 0.85

Calls 2

msSetErrorFunction · 0.85
msStrdupFunction · 0.85

Tested by

no test coverage detected