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

Function msOGRSpatialRef2ProjectionObj

mapogr.cpp:1162–1202  ·  view source on GitHub ↗

* msOGRSpatialRef2ProjectionObj() * * Init a MapServer projectionObj using an OGRSpatialRef * Works only with PROJECTION AUTO * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/

Source from the content-addressed store, hash-verified

1160 * Returns MS_SUCCESS/MS_FAILURE
1161 **********************************************************************/
1162static int msOGRSpatialRef2ProjectionObj(OGRSpatialReferenceH hSRS,
1163 projectionObj *proj, int debug_flag )
1164{
1165#ifdef USE_PROJ
1166 // First flush the "auto" name from the projargs[]...
1167 msFreeProjection( proj );
1168
1169 if (hSRS == NULL || OSRIsLocal( hSRS ) )
1170 {
1171 // Dataset had no set projection or is NonEarth (LOCAL_CS)...
1172 // Nothing else to do. Leave proj empty and no reprojection will happen!
1173 return MS_SUCCESS;
1174 }
1175
1176 // Export OGR SRS to a PROJ4 string
1177 char *pszProj = NULL;
1178
1179 ACQUIRE_OLD_OGR_LOCK;
1180 if (OSRExportToProj4( hSRS, &pszProj ) != OGRERR_NONE ||
1181 pszProj == NULL || strlen(pszProj) == 0)
1182 {
1183 RELEASE_OLD_OGR_LOCK;
1184 msSetError(MS_OGRERR, "Conversion from OGR SRS to PROJ4 failed.",
1185 "msOGRSpatialRef2ProjectionObj()");
1186 CPLFree(pszProj);
1187 return(MS_FAILURE);
1188 }
1189
1190 RELEASE_OLD_OGR_LOCK;
1191
1192 if( debug_flag )
1193 msDebug( "AUTO = %s\n", pszProj );
1194
1195 if( msLoadProjectionString( proj, pszProj ) != 0 )
1196 return MS_FAILURE;
1197
1198 CPLFree(pszProj);
1199#endif
1200
1201 return MS_SUCCESS;
1202}
1203#endif // defined(USE_OGR) || defined(USE_GDAL)
1204
1205/**********************************************************************

Callers 2

msOGCWKT2ProjectionObjFunction · 0.85
msOGRLayerOpenFunction · 0.85

Calls 4

msFreeProjectionFunction · 0.85
msSetErrorFunction · 0.85
msDebugFunction · 0.85
msLoadProjectionStringFunction · 0.85

Tested by

no test coverage detected