[mapserver-commits] r9342 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Sep 24 13:17:41 EDT 2009
Author: assefa
Date: 2009-09-24 13:17:40 -0400 (Thu, 24 Sep 2009)
New Revision: 9342
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapgml.c
trunk/mapserver/mapwfs.c
Log:
support axis ordering for WFS 1.1 (#2899)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2009-09-24 01:56:24 UTC (rev 9341)
+++ trunk/mapserver/HISTORY.TXT 2009-09-24 17:17:40 UTC (rev 9342)
@@ -14,6 +14,7 @@
Current Version (SVN trunk):
----------------------------
+ - support axis odering for WFS 1.1 (#2899)
Version 5.6.0-beta1 (2009-09-23):
---------------------------------
Modified: trunk/mapserver/mapgml.c
===================================================================
--- trunk/mapserver/mapgml.c 2009-09-24 01:56:24 UTC (rev 9341)
+++ trunk/mapserver/mapgml.c 2009-09-24 17:17:40 UTC (rev 9342)
@@ -1360,6 +1360,40 @@
#endif
}
+
+/************************************************************************/
+/* msAxisSwapShape */
+/* */
+/* Utility function to swap x and y coordiatesn Use for now for */
+/* WFS 1.1.x */
+/************************************************************************/
+void msAxisSwapShape(shapeObj *shape)
+{
+ double tmp;
+ int i,j;
+
+ if (shape)
+ {
+ for(i=0; i<shape->numlines; i++)
+ {
+ for( j=0; j<shape->line[i].numpoints; j++ )
+ {
+ tmp = shape->line[i].point[j].x;
+ shape->line[i].point[j].x = shape->line[i].point[j].y;
+ shape->line[i].point[j].y = tmp;
+ }
+ }
+
+ /*swap bounds*/
+ tmp = shape->bounds.minx;
+ shape->bounds.minx = shape->bounds.miny;
+ shape->bounds.miny = tmp;
+
+ tmp = shape->bounds.maxx;
+ shape->bounds.maxx = shape->bounds.maxy;
+ shape->bounds.maxy = tmp;
+ }
+}
/*
** msGMLWriteWFSQuery()
**
@@ -1383,13 +1417,42 @@
gmlConstantObj *constant=NULL;
char *namespace_prefix=NULL;
+ const char *axis = NULL;
+ int bSwapAxis = 0;
+ double tmp;
msInitShape(&shape);
+ /*add a check to see if the map projection is set to be north-east*/
+ for( i = 0; i < map->projection.numargs; i++ )
+ {
+ if( strstr(map->projection.args[i],"epsgaxis=") != NULL )
+ {
+ axis = strstr(map->projection.args[i],"=") + 1;
+ break;
+ }
+ }
+
+ if (axis && strcasecmp(axis,"ne") == 0 )
+ bSwapAxis = 1;
+
+
/* Need to start with BBOX of the whole resultset */
if (msGetQueryResultBounds(map, &resultBounds) > 0)
- gmlWriteBounds(stream, outputformat, &resultBounds, msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE), " ");
+ {
+ if (bSwapAxis)
+ {
+ tmp = resultBounds.minx;
+ resultBounds.minx = resultBounds.miny;
+ resultBounds.miny = tmp;
+ tmp = resultBounds.maxx;
+ resultBounds.maxx = resultBounds.maxy;
+ resultBounds.maxy = tmp;
+
+ }
+ gmlWriteBounds(stream, outputformat, &resultBounds, msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE), " ");
+ }
/* step through the layers looking for query results */
for(i=0; i<map->numlayers; i++) {
@@ -1455,7 +1518,10 @@
msIO_fprintf(stream, " <%s gml:id=\"%s.%s\">\n", layerName, lp->name, shape.values[featureIdIndex]);
} else
msIO_fprintf(stream, " <%s>\n", layerName);
-
+
+ if (bSwapAxis)
+ msAxisSwapShape(&shape);
+
/* write the feature geometry and bounding box */
if(!(geometryList && geometryList->numgeometries == 1 && strcasecmp(geometryList->geometries[0].name, "none") == 0)) {
#ifdef USE_PROJ
Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c 2009-09-24 01:56:24 UTC (rev 9341)
+++ trunk/mapserver/mapwfs.c 2009-09-24 17:17:40 UTC (rev 9342)
@@ -1168,33 +1168,6 @@
}
}
- /*
- srs is defined for wfs 1.1. If it is available. If it used to set
- the map projection. For EPSG codes between 4000 and 5000
- that coordinates order follow what is defined in the ESPG database
- see #2899
- */
- if (strncmp(paramsObj->pszVersion,"1.1",3) == 0 && paramsObj->pszSrs && pszOutputSRS)
- {
- /*check if the srs passed is valid. Assuming that it is an EPSG:xxx format.
- TODO: do we accept urn type projection strings*/
- if (strncasecmp(paramsObj->pszSrs, "EPSG:", 5) == 0)
- {
- if (strcasecmp(paramsObj->pszSrs, pszOutputSRS) != 0)
- {
- msSetError(MS_WFSERR,
- "Invalid GetFeature Request: SRSNAME value should be valid for all the TYPENAMES. Please check the capabilities and reformulate your request.",
- "msWFSGetFeature()");
- return msWFSException(map, "typename", "InvalidParameterValue", paramsObj->pszVersion);
- }
- /*we load the projection sting in the map and possibly
- set the axis order*/
- msFreeProjection(&map->projection);
- msLoadProjectionStringEPSG(&(map->projection), paramsObj->pszSrs);
- }
- }
-
-
/* Validate outputformat */
if (paramsObj->pszOutputFormat) {
/* We support only GML2 and GML3 for now. */
@@ -1503,15 +1476,67 @@
msFreeCharArray(layers, numlayers);
+ /*
+ srs is defined for wfs 1.1. If it is available. If it used to set
+ the map projection. For EPSG codes between 4000 and 5000
+ that coordinates order follow what is defined in the ESPG database
+ see #2899
+ */
+ if (strncmp(paramsObj->pszVersion,"1.1",3) == 0 && paramsObj->pszSrs && pszOutputSRS)
+ {
+ /*check if the srs passed is valid. Assuming that it is an EPSG:xxx format,
+ Or urn:ogc:def:crs:EPSG:xxx format. */
+ if (strncasecmp(paramsObj->pszSrs, "EPSG:", 5) == 0)
+ {
+ if (strcasecmp(paramsObj->pszSrs, pszOutputSRS) != 0)
+ {
+ msSetError(MS_WFSERR,
+ "Invalid GetFeature Request: SRSNAME value should be valid for all the TYPENAMES. Please check the capabilities and reformulate your request.",
+ "msWFSGetFeature()");
+ return msWFSException(map, "typename", "InvalidParameterValue", paramsObj->pszVersion);
+ }
+ /*we load the projection sting in the map and possibly
+ set the axis order*/
+ msFreeProjection(&map->projection);
+ msLoadProjectionStringEPSG(&(map->projection), paramsObj->pszSrs);
+ }
+ else if (strncasecmp(paramsObj->pszSrs, "urn:EPSG:geographicCRC:",23) == 0)
+ {
+ char epsg_string[100];
+ const char *code;
+
+ code = paramsObj->pszSrs + 23;
+
+ sprintf( epsg_string, "EPSG:%s", code );
+ if (strcasecmp(epsg_string, pszOutputSRS) != 0)
+ {
+ msSetError(MS_WFSERR,
+ "Invalid GetFeature Request: SRSNAME value should be valid for all the TYPENAMES. Please check the capabilities and reformulate your request.",
+ "msWFSGetFeature()");
+ return msWFSException(map, "typename", "InvalidParameterValue", paramsObj->pszVersion);
+ }
+ /*we load the projection sting in the map and possibly
+ set the axis order*/
+ msFreeProjection(&map->projection);
+ msLoadProjectionStringEPSG(&(map->projection), epsg_string);
+ }
+ }
/* Set map output projection to which output features should be reprojected */
- if (pszOutputSRS && strncasecmp(pszOutputSRS, "EPSG:", 5) == 0) {
- char szBuf[32];
- sprintf(szBuf, "init=epsg:%.10s", pszOutputSRS+5);
-
- if (msLoadProjectionString(&(map->projection), szBuf) != 0) {
- msSetError(MS_WFSERR, "msLoadProjectionString() failed", "msWFSGetFeature()");
- return msWFSException(map, "mapserv", "NoApplicableCode", paramsObj->pszVersion);
- }
+ else if (pszOutputSRS && strncasecmp(pszOutputSRS, "EPSG:", 5) == 0)
+ {
+ int nTmp =0;
+ msFreeProjection(&map->projection);
+ msInitProjection(&map->projection);
+
+ if (strncmp(paramsObj->pszVersion,"1.1",3) == 0)
+ nTmp = msLoadProjectionStringEPSG(&(map->projection), pszOutputSRS);
+ else
+ nTmp = msLoadProjectionString(&(map->projection), pszOutputSRS);
+
+ if (nTmp != 0) {
+ msSetError(MS_WFSERR, "msLoadProjectionString() failed", "msWFSGetFeature()");
+ return msWFSException(map, "mapserv", "NoApplicableCode", paramsObj->pszVersion);
+ }
}
/*
More information about the mapserver-commits
mailing list