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

Function msLoadProjectionString

mapfile.c:1338–1583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1336
1337
1338int msLoadProjectionString(projectionObj *p, const char *value)
1339{
1340 p->gt.need_geotransform = MS_FALSE;
1341
1342#ifdef USE_PROJ
1343 if(p) msFreeProjection(p);
1344
1345
1346 /*
1347 * Handle new style definitions, the same as they would be given to
1348 * the proj program.
1349 * eg.
1350 * "+proj=utm +zone=11 +ellps=WGS84"
1351 */
1352 if( value[0] == '+' )
1353 {
1354 char *trimmed;
1355 int i, i_out=0;
1356
1357 trimmed = msStrdup(value+1);
1358 for( i = 1; value[i] != '\0'; i++ )
1359 {
1360 if( !isspace( value[i] ) )
1361 trimmed[i_out++] = value[i];
1362 }
1363 trimmed[i_out] = '\0';
1364
1365 p->args = msStringSplit(trimmed,'+', &p->numargs);
1366 free( trimmed );
1367 }
1368 else if (strncasecmp(value, "AUTO:", 5) == 0 ||
1369 strncasecmp(value, "AUTO2:", 6) == 0)
1370 {
1371 /* WMS/WFS AUTO projection: "AUTO:proj_id,units_id,lon0,lat0" */
1372 /* WMS 1.3.0 projection: "AUTO2:auto_crs_id,factor,lon0,lat0"*/
1373 /* Keep the projection defn into a single token for writeProjection() */
1374 /* to work fine. */
1375 p->args = (char**)msSmallMalloc(sizeof(char*));
1376 p->args[0] = msStrdup(value);
1377 p->numargs = 1;
1378 }
1379 else if (strncasecmp(value, "EPSG:", 5) == 0)
1380 {
1381 size_t buffer_size = 10 + strlen(value+5) + 1;
1382 char *init_string = (char*)msSmallMalloc(buffer_size);
1383
1384 /* translate into PROJ.4 format. */
1385 snprintf( init_string, buffer_size, "init=epsg:%s", value+5);
1386
1387 p->args = (char**)msSmallMalloc(sizeof(char*) * 2);
1388 p->args[0] = init_string;
1389 p->numargs = 1;
1390 }
1391 else if (strncasecmp(value, "urn:ogc:def:crs:EPSG:",21) == 0)
1392 { /* this is very preliminary urn support ... expand later */
1393 size_t buffer_size = 0;
1394 char *init_string = NULL;
1395 const char *code;

Callers 15

FLTParseEpsgStringFunction · 0.85
FLTApplySimpleSQLFilterFunction · 0.85
msBuildWMSLayerURLFunction · 0.85
msWCSGetCoverageFunction · 0.85
msWCSGetCoverageMetadataFunction · 0.85
msWCSGetCoverage20Function · 0.85
loadProjectionFunction · 0.85

Calls 9

msFreeProjectionFunction · 0.85
msStrdupFunction · 0.85
msStringSplitFunction · 0.85
strncasecmpFunction · 0.85
msSmallMallocFunction · 0.85
msIsAxisInvertedFunction · 0.85
strcasecmpFunction · 0.85
msSetErrorFunction · 0.85
msProcessProjectionFunction · 0.85

Tested by

no test coverage detected