Skip to content
Permalink
Browse files
Contour layer: add GetFeatureInfo support
  • Loading branch information
rouault committed Jan 8, 2020
1 parent 8cb8ee9 commit ed1d778a2f71bc029213515de2dee47f7b458661
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
@@ -37,6 +37,7 @@
#include "gdal.h"
#include "gdal_alg.h"

#include "mapows.h"
#include "mapthread.h"
#include "mapraster.h"
#include "cpl_string.h"
@@ -111,6 +112,21 @@ static void msContourLayerInfoInitialize(layerObj *layer)
clinfo->ogrLayer.connection = (char*)msSmallMalloc(strlen(clinfo->ogrLayer.name)+13);
sprintf(clinfo->ogrLayer.connection, "__%s_CONTOUR__", clinfo->ogrLayer.name);
clinfo->ogrLayer.units = layer->units;

if (msOWSLookupMetadata(&(layer->metadata), "OFG", "ID_type") == NULL) {
msInsertHashTable(&(layer->metadata), "gml_ID_type", "Integer");
}
{
const char* elevItem = CSLFetchNameValue(layer->processing,"CONTOUR_ITEM");
if (elevItem && strlen(elevItem) > 0) {
char szTmp[100];
snprintf(szTmp, sizeof(szTmp), "%s_type", elevItem);
if (msOWSLookupMetadata(&(layer->metadata), "OFG", szTmp) == NULL) {
snprintf(szTmp, sizeof(szTmp), "gml_%s_type", elevItem);
msInsertHashTable(&(layer->metadata), szTmp, "Real");
}
}
}
}

static void msContourLayerInfoFree(layerObj *layer)
@@ -232,8 +248,11 @@ static int msContourLayerReadRaster(layerObj *layer, rectObj rect)
InvGeoTransform(adfGeoTransform, adfInvGeoTransform);

mapRect = rect;
map_cellsize_x = map_cellsize_y = map->cellsize;

if( map->cellsize == 0 )
{
map->cellsize = msAdjustExtent(&mapRect,map->width,map->height);
}
map_cellsize_x = map_cellsize_y = map->cellsize;
/* if necessary, project the searchrect to source coords */
if (msProjectionsDiffer( &(map->projection), &(layer->projection))) {
if ( msProjectRect(&map->projection, &layer->projection, &mapRect)
@@ -774,6 +793,7 @@ int msContourLayerClose(layerObj *layer)

int msContourLayerGetItems(layerObj *layer)
{
const char* elevItem;
contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo;

if (clinfo == NULL) {
@@ -782,7 +802,16 @@ int msContourLayerGetItems(layerObj *layer)
return MS_FAILURE;
}

return msContourLayerGetItems(&clinfo->ogrLayer);
layer->numitems = 0;
layer->items = (char **) msSmallCalloc(sizeof(char *),2);

layer->items[layer->numitems++] = msStrdup("ID");
elevItem = CSLFetchNameValue(layer->processing,"CONTOUR_ITEM");
if (elevItem && strlen(elevItem) > 0) {
layer->items[layer->numitems++] = msStrdup(elevItem);
}

return msLayerGetItems(&clinfo->ogrLayer);
}

int msContourLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
@@ -800,8 +829,13 @@ int msContourLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
return MS_FAILURE;
}

newRect = rect;

if( isQuery )
{
newRect = layer->map->extent;
}
else
{
newRect = rect;
/* if necessary, project the searchrect to source coords */
if (msProjectionsDiffer( &(layer->map->projection), &(layer->projection))) {
if (msProjectRect(&layer->projection, &layer->map->projection, &newRect)
@@ -810,6 +844,7 @@ int msContourLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
return MS_FAILURE;
}
}
}

/* regenerate the raster io */
if (clinfo->hOGRDS)
@@ -7,6 +7,9 @@
# RUN_PARMS: wms_contour_inline_ti.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=3.697829,-16.193665,57.120229,23.8731435&WIDTH=300&HEIGHT=300&LAYERS=contour_inline_ti&STYLES=&FORMAT=image%2Fpng" > [RESULT_DEMIME]
# RUN_PARMS: wms_contour_layer_ti.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=3.697829,-16.193665,57.120229,23.8731435&WIDTH=300&HEIGHT=300&LAYERS=contour_layer_ti&STYLES=&FORMAT=image%2Fpng" > [RESULT_DEMIME]

# RUN_PARMS: wms_contour_inline_ti_getfeatureinfo.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetFeatureInfo&SRS=EPSG%3A4326&BBOX=3.697829,-16.193665,57.120229,23.8731435&WIDTH=300&HEIGHT=300&LAYERS=contour_inline_ti&STYLES=&FORMAT=image%2Fpng&QUERY_LAYERS=contour_inline_ti&I=2&J=120&INFO_FORMAT=application/vnd.ogc.gml" > [RESULT_DEMIME]

# RUN_PARMS: wms_contour_inline_ti_getfeatureinfo_empty_result.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetFeatureInfo&SRS=EPSG%3A4326&BBOX=3.697829,-16.193665,57.120229,23.8731435&WIDTH=300&HEIGHT=300&LAYERS=contour_inline_ti&STYLES=&FORMAT=image%2Fpng&QUERY_LAYERS=contour_inline_ti&I=20&J=120&INFO_FORMAT=application/vnd.ogc.gml" > [RESULT_DEMIME]

MAP
NAME TEST_CONTOUR
@@ -21,7 +24,7 @@ MAP
METADATA
"ows_updatesequence" "123"
"WMS_TITLE" "Test WMS time support"
"WMS_ONLINERESOURCE" "http://localhost/path/to/mswms_time?"
"ows_ONLINERESOURCE" "http://localhost/path/to/mswms_time?"
"WMS_SRS" "EPSG:4326"
"OWS_SCHEMAS_LOCATION" "http://ogc.dmsolutions.ca"
"WMS_ACCESSCONTRAINTS" "none"
@@ -47,6 +50,7 @@ MAP
PROCESSING "BANDS=1"
PROCESSING "CONTOUR_ITEM=elevation"
PROCESSING "CONTOUR_INTERVAL=20"
TEMPLATE "ddd"
CLASS
STYLE
WIDTH 1
@@ -59,6 +63,7 @@ MAP
"wms_title" "contour_inline_ti"
"wms_timeitem" "TIME"
"wms_timeextent" "2004-01-01/2004-02-01"
"gml_include_items" "all"
END
END

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<msGMLOutput
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<contour_inline_ti_layer>
<gml:name>contour_inline_ti</gml:name>
<contour_inline_ti_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>3.500000,6.849074 4.286121,8.259505</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ID>0</ID>
<elevation>20.000</elevation>
</contour_inline_ti_feature>
</contour_inline_ti_layer>
</msGMLOutput>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<msGMLOutput
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</msGMLOutput>

0 comments on commit ed1d778

Please sign in to comment.