/ msOGRShapeFromWKT() */ /
| 3794 | /* msOGRShapeFromWKT() */ |
| 3795 | /************************************************************************/ |
| 3796 | shapeObj *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() */ |
no test coverage detected