Thinking; the getFeatureInfo is supposed to be in reference to a
GetMapRequest which you provide (that is you are performing your query
against a map...). I suspect that you can only perform a query against a
layer that is actually listed in your GetMap request?
Would that be the case...
You may need to check the test cases to find an example of GetFeatureInfo.
Jody
On Wed, Jun 1, 2011 at 6:16 AM, khalid Amiral <[email protected]> wrote:
> Hello every body,
> I'm looking for the structure of a URL for a query getFeatureInfo works
> because I used the code below but it gives me the following error:
> "QUERY_LAYERS contains layers not cited in LAYERS".
> with the exit URL :
> http://localhost:8080/geoserver/wms?Y=-42&X=147&SERVICE=WMS&FORMAT=image/png&HEIGHT=400&REQUEST=GetFeatureInfo&WIDTH=400&BBOX=-114.01268,59.4596930,-113.26043,60.0835794&SRS=EPSG:4326&QUERY_LAYERS=nurc%3AArc_Sample&VERSION=1.1.1
> when i put the exit URL directly in the browser with the correct layer
> (QUERY_LAYERS=nurc:Arc_Sample) it give me the same error !
> *The code:*
> import java.io.BufferedReader;
> import java.io.InputStreamReader;
> import java.net.URL;
> import java.util.Iterator;
> import org.geotools.data.ows.Layer;
> import org.geotools.data.ows.WMSCapabilities;
> import org.geotools.data.wms.WMSUtils;
> import org.geotools.data.wms.WebMapServer;
> import org.geotools.data.wms.request.GetFeatureInfoRequest;
> import org.geotools.data.wms.request.GetMapRequest;
> import org.geotools.data.wms.response.GetFeatureInfoResponse;
>
> public class GetFeatureInfo {
> public static void main(String[] args) throws Exception {
> try{
> URL url = new URL("
> http://localhost:8080/geoserver/wms?REQUEST=GetCapabilities");
> WebMapServer wms = new WebMapServer(url);
> WMSCapabilities caps = wms.getCapabilities();
> Layer layer = null;
> for( Iterator i = caps.getLayerList().iterator();
> i.hasNext();){
> Layer test = (Layer) i.next();
>
> if( test.getName() != null &&
> test.getName().length() != 0 ){
> layer = test;
> break;
> }
> }
> // GetFeatureInfo needs a GetMap before
> GetMapRequest getMapRequest =
> wms.createGetMapRequest();
> // We set the SRS
> getMapRequest.setSRS("EPSG:4326");
> // We set the dimensions of the output
> getMapRequest.setDimensions("400", "400");
> // We set the output format
> getMapRequest.setFormat("image/png");
> // We set the BBOX of the requested Map
>
> getMapRequest.setBBox("-114.01268,59.4596930,-113.26043,60.0835794");
>
> // Now, we can create our GetFeatureInfo, from the
> previous GetMap
> GetFeatureInfoRequest request =
> wms.createGetFeatureInfoRequest(getMapRequest);
> // We want request this layer
> request.addQueryLayer(layer);
> // We need information from this point
> request.setQueryPoint(147,-42);
>
> System.out.println(request.getFinalURL());
> // We ask the server
> GetFeatureInfoResponse response =
> (GetFeatureInfoResponse) wms.issueRequest(request);
> System.out.println(response.getContentType());
>
> BufferedReader in = new BufferedReader(new
> InputStreamReader(response.getInputStream()));
> String line;
> boolean textFound = false;
> while ((line = in.readLine()) != null) {
> System.out.println(line);
> } catch(java.net.ConnectException ce){
> if(ce.getMessage().indexOf("timed out")>0){
> System.err.println("Unable to test - timed out:
> "+ce);
> } else{
> throw(ce);
> }
> }
>
> }
> }
>
> And thank you very much.
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with
> vRanger.
> Installation's a snap, and flexible recovery options mean your data is
> safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users