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

Function msOWSGetProjURI

mapows.c:1959–2011  ·  view source on GitHub ↗

** msOWSGetProjURI() ** ** Fetch an OGC URI for this layer or map. Similar to msOWSGetEPSGProj() ** but returns the result in the form "http://www.opengis.net/def/crs/EPSG/0/27700". ** The returned buffer is dynamically allocated, and must be freed by the ** caller. */

Source from the content-addressed store, hash-verified

1957** caller.
1958*/
1959char *msOWSGetProjURI(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne)
1960{
1961 char *result;
1962 char **tokens;
1963 int numtokens, i;
1964
1965 const char *oldStyle = msOWSGetEPSGProj( proj, metadata, namespaces,
1966 bReturnOnlyFirstOne );
1967
1968 if( oldStyle == NULL || !EQUALN(oldStyle,"EPSG:",5) )
1969 return NULL;
1970
1971 result = msStrdup("");
1972
1973 tokens = msStringSplit(oldStyle, ' ', &numtokens);
1974 for(i=0; tokens != NULL && i<numtokens; i++)
1975 {
1976 char urn[100];
1977
1978 if( strncmp(tokens[i],"EPSG:",5) == 0 )
1979 snprintf( urn, sizeof(urn), "http://www.opengis.net/def/crs/EPSG/0/%s", tokens[i]+5 );
1980 else if( strcasecmp(tokens[i],"imageCRS") == 0 )
1981 snprintf( urn, sizeof(urn), "http://www.opengis.net/def/crs/OGC/0/imageCRS" );
1982 else if( strncmp(tokens[i],"http://www.opengis.net/def/crs/",16) == 0 )
1983 snprintf( urn, sizeof(urn), "%s", tokens[i] );
1984 else
1985 strlcpy( urn, "", sizeof(urn) );
1986
1987 if( strlen(urn) > 0 )
1988 {
1989 result = (char *) realloc(result,strlen(result)+strlen(urn)+2);
1990
1991 if( strlen(result) > 0 )
1992 strcat( result, " " );
1993 strcat( result, urn );
1994 }
1995 else
1996 {
1997 msDebug( "msOWSGetProjURI(): Failed to process SRS '%s', ignored.",
1998 tokens[i] );
1999 }
2000 }
2001
2002 msFreeCharArray(tokens, numtokens);
2003
2004 if( strlen(result) == 0 )
2005 {
2006 msFree( result );
2007 return NULL;
2008 }
2009 else
2010 return result;
2011}
2012
2013
2014/*

Calls 8

msOWSGetEPSGProjFunction · 0.85
msStrdupFunction · 0.85
msStringSplitFunction · 0.85
strcasecmpFunction · 0.85
strlcpyFunction · 0.85
msDebugFunction · 0.85
msFreeCharArrayFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected