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

Function msGMLWriteQuery

mapgml.c:1129–1306  ·  view source on GitHub ↗

Dump GML query results for WMS GetFeatureInfo */

Source from the content-addressed store, hash-verified

1127
1128/* Dump GML query results for WMS GetFeatureInfo */
1129int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)
1130{
1131#if defined(USE_WMS_SVR)
1132 int status;
1133 int i,j,k;
1134 layerObj *lp=NULL;
1135 shapeObj shape;
1136 FILE *stream=stdout; /* defaults to stdout */
1137 char szPath[MS_MAXPATHLEN];
1138 char *value;
1139 const char *pszMapSRS = NULL;
1140
1141 gmlGroupListObj *groupList=NULL;
1142 gmlItemListObj *itemList=NULL;
1143 gmlConstantListObj *constantList=NULL;
1144 gmlGeometryListObj *geometryList=NULL;
1145 gmlItemObj *item=NULL;
1146 gmlConstantObj *constant=NULL;
1147
1148 msInitShape(&shape);
1149
1150 if(filename && strlen(filename) > 0) { /* deal with the filename if present */
1151 stream = fopen(msBuildPath(szPath, map->mappath, filename), "w");
1152 if(!stream) {
1153 msSetError(MS_IOERR, "(%s)", "msGMLWriteQuery()", filename);
1154 return(MS_FAILURE);
1155 }
1156 }
1157
1158 /* charset encoding: lookup "gml_encoding" metadata first, then */
1159 /* "wms_encoding", and if not found then use "ISO-8859-1" as default. */
1160 msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "encoding", OWS_NOERR, "<?xml version=\"1.0\" encoding=\"%s\"?>\n\n", "ISO-8859-1");
1161 msOWSPrintValidateMetadata(stream, &(map->web.metadata), namespaces, "rootname", OWS_NOERR, "<%s ", "msGMLOutput");
1162
1163 msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "uri", OWS_NOERR, "xmlns=\"%s\"", NULL);
1164 msIO_fprintf(stream, "\n\t xmlns:gml=\"http://www.opengis.net/gml\"" );
1165 msIO_fprintf(stream, "\n\t xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
1166 msIO_fprintf(stream, "\n\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
1167 msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "schema", OWS_NOERR, "\n\t xsi:schemaLocation=\"%s\"", NULL);
1168 msIO_fprintf(stream, ">\n");
1169
1170 /* a schema *should* be required */
1171 msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "description", OWS_NOERR, "\t<gml:description>%s</gml:description>\n", NULL);
1172
1173 /* Look up map SRS. We need an EPSG code for GML, if not then we get null and we'll fall back on the layer's SRS */
1174 pszMapSRS = msOWSGetEPSGProj(&(map->projection), NULL, namespaces, MS_TRUE);
1175
1176 /* step through the layers looking for query results */
1177 for(i=0; i<map->numlayers; i++) {
1178 const char *pszOutputSRS = NULL;
1179 lp = (GET_LAYER(map, map->layerorder[i]));
1180
1181 if(lp->resultcache && lp->resultcache->numresults > 0) { /* found results */
1182
1183#ifdef USE_PROJ
1184 /* Determine output SRS, if map has none, then try using layer's native SRS */
1185 if ((pszOutputSRS = pszMapSRS) == NULL) {
1186 pszOutputSRS = msOWSGetEPSGProj(&(lp->projection), NULL, namespaces, MS_TRUE);

Callers 1

msWMSFeatureInfoFunction · 0.85

Calls 15

msInitShapeFunction · 0.85
msBuildPathFunction · 0.85
msSetErrorFunction · 0.85
msOWSPrintEncodeMetadataFunction · 0.85
msIO_fprintfFunction · 0.85
msOWSGetEPSGProjFunction · 0.85
msSmallMallocFunction · 0.85
msFreeFunction · 0.85
msOWSLookupMetadataFunction · 0.85
msOWSPrintMetadataFunction · 0.85
msGMLGetItemsFunction · 0.85

Tested by

no test coverage detected