Hi,
 
I would like to retrieve Infos from a WMS (MapServer 4.10.0) with the 
getFeatureInfo request, using GeoTools (2.3.0), but the LAYERS parameter is 
missing in my final request.
 
I create first my getMap request using myWebMapServer.createGetMapRequest(), 
then, create my getFeatureInfo request using 
myWebMapServer.createGetFeatureInfoRequest(), finally, I ask the server using 
myWebMapServer.issuerequest(myGetFeatureInfoRequest). But albeit my 
getMapRequest has the good LAYERS parameter, my getFeatureInfoRequest has not 
it.
 
Is someone know why I have this issue?
 
This is my code:
 
// START CODE
    /**
     * Makes a GetFeatureInfo request on the current WebMapServer.
     * @param size Output size of the Map.
     * @param crse Bounding Box of the Map.
     * @param p Requested point (warning: with Java Y-axis !).
     * @throws java.io.IOException 
     * @throws org.geotools.ows.ServiceException 
     * @return GetFeatureInfo of a point of current WebMapServer.
     */
    public String getFeatureInfo( Dimension size , CRSEnvelope crse , Point p ) 
throws IOException, ServiceException {
        StringBuffer sb = new StringBuffer();
        
        // GetFeatureInfo needs a GetMap before
        GetMapRequest gmReq = wms.createGetMapRequest();
        // We add the requested Layer
        gmReq.addLayer( getLayerByName(layerasstring) );
        // We set the BBOX of the requested Map
        gmReq.setBBox( crse );
        // We set the dimensions of the output
        gmReq.setDimensions(size.width, size.height);
        // We set the output format
        gmReq.setFormat("image/png");
        // We set the SRS
        gmReq.setSRS( crse.getEPSGCode() );
        // We want a transparent background
        gmReq.setTransparent(true);
        
        // Now, we can create our GetFeatureInfo, from the previous GetMap
        GetFeatureInfoRequest gfiReq = wms.createGetFeatureInfoRequest(gmReq);
        // We want request this layer
        gfiReq.addQueryLayer( getLayerByName( layerasstring ) );
        // We need information from this point (warning : java Y-axis goes from 
top to bottom, geographic goes from bottom to top !)
        gfiReq.setQueryPoint( p.x , size.height - p.y );
        
        // Tummy (Bidouille) used to circle an issue with LAYERS parameter...
        gfiReq.setProperty( "LAYERS" , layerasstring );
        
        // Debug
        System.out.println( gmReq.getFinalURL().toString() );
        System.out.println( gfiReq.getFinalURL().toString() );
        
        // We ask the server
        GetFeatureInfoResponse gfiRep = wms.issueRequest( gfiReq );
        // We read the response
        sb.append( FileReader.read( gfiRep.getInputStream() ) );
        
        return sb.toString();
    }
// END CODE
 
- layerasstring is the name of the layer.
- getLayerByName(String) function is a function which returns a 
org.geotools.data.ows.Layer of the current server from his name.
- The tummy (is it the good word for "bidouille" in french ?!) is here for the 
moment to make the code working, but I prefer find the bug. ;-)
- In the Debug output, the LAYERS parameter is here for gmReq (getMap), but not 
for gfiReq (getFeatureInfo).
 
Thanks in advance,
bests,
 
______________________________
François Tertre
BRGM STI/AD
3, avenue Claude Guillemin
BP 6009 - 45060 Orléans Cedex 2 
France
Tel:+33 238 643 642
Fax: +33 238 644 830
Secr: +33 238 643 999
Mail: [EMAIL PROTECTED]
Web: http://www.brgm.fr
 
**********************************************************************************************
Le contenu de ce mél et de ses pièces jointes est destiné à l'usage exclusif du 
(des) destinataire(s) expressément désigné(s) comme tel(s). En cas de réception 
de ce 
 mél par erreur, le signaler à son expéditeur et ne pas en divulguer le 
contenu. 
L'absence de virus a été vérifié à l'émission du message. Il convient néanmoins 
de 
vérifier l'absence de contamination à sa réception. 
The contents of this email and any attachments are confidential. They are 
intended for 
the named recipient(s) only. If you have received this email in error please 
notify the 
system manager or the sender immediately and do not disclose the contents to 
anyone or make copies. eSafe scanned this email for viruses, vandals and 
malicious 
content.
**********************************************************************************************
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to