Getting values from a WMS with GeoTiff file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting values from a WMS with GeoTiff file

Riccardo Di Stefano

Hello everyone!

 

I'm quite new to OpenLayers, and completely new to WMS querying. I’m needing some help here.

 

I have to query values of a WMS hosted by Geoserver from a GeoTiff file.

What is the best way? Following the examples I found on the web (i.e. http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/getfeatureinfo-control.html), I tried to perform a WMSGetFeatureInfo like follows:

 

 

function initialize(){

 

var resolutions = OpenLayers.Layer.Bing.prototype.serverResolutions.slice(MYMIN, MYMAX);

 

var layer_BNI = new OpenLayers.Layer.WMS("MY TITLE",

            "http://localhost:8080/geoserver/wms",

            { 'layers': 'MYLAYER', transparent: true, format: 'image/png' },

            { isBaseLayer: false }

       );

 

var map = new OpenLayers.Map({

div: MYDIV,

theme: null,

projection: "EPSG:900913",

layers: [

layer_BNI,

new OpenLayers.Layer.OSM("MapQuest-OSM Tiles", arrayOSM, {

attribution: "<p>Data, imagery and map information provided by <a href='http://www.mapquest.com/'  target='_blank'>MapQuest</a>, <a href='http://www.openstreetmap.org/' target='_blank'>Open Street Map</a> and contributors, <a href='http://creativecommons.org/licenses/by-sa/2.0/' target='_blank'>CC-BY-SA</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png' border='0'></p>",

transitionEffect: "resize",

zoomOffset: MYMIN,

                            resolutions: resolutions

                   })

],

controls: [

new OpenLayers.Control.Attribution(),

new OpenLayers.Control.Navigation()

],

center: [0, 0],

zoom: MYZOOM

});

 

 

var info = new OpenLayers.Control.WMSGetFeatureInfo({

        url: 'http://localhost:8080/geoserver/wms',

        title: 'Identify features by clicking',

        layers: [layer_BNI],

        eventListeners: {

            getfeatureinfo: getInfo

        },

        queryVisible: true

    });

 

map.addControl(info);

info.activate();

 

}

 

function getInfo(event) {

//event is always empty

}

 

 

My layers are loaded and shown correctly, getInfo is fired correctly, but event.text is ALWAYS an empty string.

With QGIS values are extracted correctly from my WMS, so I guess the issue is not WMS-side but client-side.

What am I doing wrong?

 

 

Thank you very much!


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Getting values from a WMS with GeoTiff file

D_Guidi
On Thu, Dec 5, 2013 at 12:09 PM, Riccardo Di Stefano
<[hidden email]> wrote:
> I have to query values of a WMS hosted by Geoserver from a GeoTiff file.
You're working with a raster  (i.e an image) so AFAIK there are no
ways to extract information from a data source like this via a
GetFeatureInfo, because ecutally there isn't information to read.
You can extract information from vector data like shapefiles.



Diego Guidi
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Getting values from a WMS with GeoTiff file

Riccardo Di Stefano
I made some more tests: debugging GeoExplorer (which uses OpenLayers) with
Firefox debugger, I see that the following GetFeatureInfo request is sent:

http://localhost:8080/geoserver/ows?LAYERS=ENDORSE:ENDORSE_BNI&QUERY_LAYERS=
ENDORSE:ENDORSE_BNI&STYLES=&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo
&BBOX=-7612907.636721%2C1665802.66581%2C11133120.673553%2C5931600.339756&FEA
TURE_COUNT=10&HEIGHT=436&WIDTH=1916&FORMAT=image/png&INFO_FORMAT=application
/vnd.ogc.gml&SRS=EPSG:900913&X=866&Y=285

The WMS answers correctly; here is the XML I get:

<?xml version="1.0" encoding="UTF-8"?>
                <wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ENDORSE="http://opengeo.org/#ENDORSE"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">
                                <gml:boundedBy>
                                                <gml:null>unknown</gml:null>
                                </gml:boundedBy>
                                <gml:featureMember>
                                                <ENDORSE:ENDORSE_BNI fid="">
 
<ENDORSE:GRAY_INDEX>2295.0</ENDORSE:GRAY_INDEX>
                                                </ENDORSE:ENDORSE_BNI>
                                </gml:featureMember>
                </wfs:FeatureCollection>


2295.0 is the correct value for the my lat/lon.
I should be able to do the same with my code, but I just don't know how...
Any advices?

Thank you again!

-----Original Message-----
From: Diego Guidi [mailto:[hidden email]]
Sent: giovedì 5 dicembre 2013 12:24
To: Riccardo Di Stefano
Cc: [hidden email]
Subject: Re: [OpenLayers-Users] Getting values from a WMS with GeoTiff file

On Thu, Dec 5, 2013 at 12:09 PM, Riccardo Di Stefano
<[hidden email]> wrote:
> I have to query values of a WMS hosted by Geoserver from a GeoTiff file.
You're working with a raster  (i.e an image) so AFAIK there are no ways to
extract information from a data source like this via a GetFeatureInfo,
because ecutally there isn't information to read.
You can extract information from vector data like shapefiles.



Diego Guidi


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users