banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

GeoDataDays 2025

#1 Fri 30 April 2010 08:42

icadedt
Participant assidu
Lieu: ici et là
Date d'inscription: 21 Jul 2006
Messages: 478

openlayers fonction getfeatureinfo sur couche ponctuelle

Bonjour, avec la fonction getfeatureinfo de mapserver , on peut recuperer des infos des objets sur lesquls on clicque


le probleme vient quand on essaye de pointer sur un objet d'une couche de type ponctuel, l'info ne remonte pas tant qu'on a pas visé exactement sur le centroide de l'objet, ce qui est tres difficile surtout si le zoom est petit !!!!!


ma question est la suivante: est -il possible de parametrer le getfeatureinfo pour qu'il accepte une zone de tolérance?
une requete spatiale du genre intersects...

faut il parametrer ca dans le mapfile  ou dans openlayers?





Code:

            map.events.register('click', map, function(e) {



                var params = {
                    REQUEST: "GetFeatureInfo",
                    EXCEPTIONS: "application/vnd.ogc.se_xml",
                    BBOX: map.getExtent().toBBOX(),
                    X: e.xy.x,
                    Y: e.xy.y,
                    INFO_FORMAT: 'text/plain',

                    QUERY_LAYERS: 'mespoints',



                    FEATURE_COUNT: 1,
                    Layers: 'mespoints',
                    Styles: '',
                    Srs: 'EPSG:4326',
                    WIDTH: map.size.w,
                    HEIGHT: map.size.h,
                    format: 'image/png',
                    VERSION: '1.0.0'
                };



                OpenLayers.loadURL("http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/test/mapfilepostgisWMS.map", params, this, setHTML)
                OpenLayers.Event.stop(e);
                
                
            });

mon mapfile:



Code:

 
# Edit this file to customize for your map interface
# (Created with PyQgis MapServer Export plugin)
MAP
  NAME MyMap
  # Map image size
  SIZE 600 400
  UNITS meters

  EXTENT -97.960008 40.009933 -81.249600 50.645179
  


  PROJECTION
    
   "init=epsg:900913" ##recommended
 END

  SYMBOL
   NAME 'circle'
        TYPE ellipse
        FILLED true
        POINTS 1 1 END
        STYLE 2 1 END
     
        
  END



    SYMBOLSET "symbols/symbols35.sym"
SYMBOL
        
        NAME 'imageGIFouJPEG'
        TYPE PIXMAP
        IMAGE "symbols/Ducky.png"
        
    

    END


  TRANSPARENT ON
  # Background color for the map canvas -- change as desired
  IMAGECOLOR 255 255 255
  IMAGEQUALITY 95
  IMAGETYPE PNG
  OUTPUTFORMAT
    NAME 'PNG'
    DRIVER 'GD/PNG'
    MIMETYPE 'image/png'
    #IMAGEMODE PC256
    EXTENSION 'png'
  END
  # Legend
  LEGEND
      IMAGECOLOR 255 255 255
    STATUS ON
    KEYSIZE 18 12
    LABEL
      TYPE BITMAP
      SIZE MEDIUM
      COLOR 0 0 89
    END
  END

  # Web interface definition. Only the template parameter
  # is required to display a map. See MapServer documentation
  WEB
    # Set IMAGEPATH to the path where MapServer should
    # write its output.
    IMAGEPATH '/tmp/'

    # Set IMAGEURL to the url that points to IMAGEPATH
    # as defined in your web server configuration
    IMAGEURL '/tmp/'

    # WMS server settings
    METADATA
      'wms_title'           'MyMap'
      'wms_onlineresource'  'http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/test/mapfilepostgisWMS.map&'
      'wms_srs'             'EPSG:4326'
    END

    #Scale range at which web interface will operate
    # Template and header/footer settings
    # Only the template parameter is required to display a map. See MapServer documentation
  END







#================================================================================================================================================

#================================================================================================================================================

#================================================================================================================================================







  LAYER
   TEMPLATE "void"  # mettre ca , indispensable pour utiliser GetFeatureInfo

    NAME 'states_ugl'
    TYPE POLYGON
    CONNECTIONTYPE postgis
    CONNECTION 'host=localhost user=postgres password=azertyuiop dbname=postgistest'
    DATA 'the_geom from states_ugl  using unique gid using srid=-1'
    FILTER ("STATE" not similar to 'Michiga%' or "STATE" ='Michigan')


    METADATA

      wms_title 'states_ugl_titre'
      wms_name 'states_ugl_titre_name'
      wms_include_items "all" # "STATE,gid"   # pour GetFeatureInfo
      wms_feature_info_mime_type "text/plain"

      wms_srs 'EPSG:4326'

    END




    STATUS ON
    TRANSPARENCY 100 #alpha
   
  
  PROJECTION
    
   "init=epsg:4326" ##recommended
 END
    CLASS
       NAME 'states_ugl' 
       STYLE
         SYMBOL 'circle'
         SIZE 5
         OUTLINECOLOR 40 100 78
         COLOR 20 150 100
         ANTIALIAS TRUE
      
       END
    END
  END








#================================================================================================================================================

#================================================================================================================================================

#================================================================================================================================================





    LAYER # test couche ponctuelle

            TEMPLATE "void"  # mettre ca , indispensable pour utiliser GetFeatureInfo
 
        TYPE POINT

        STATUS DEFAULT #doit etre à DEFAULT si visible

        TRANSPARENCY 99 # mettre à 99 et pas 100 sinon le fond des png devient visible

          CONNECTION "host=localhost dbname=postgistest user=postgres password=azertyuiop port=5432"

          CONNECTIONTYPE POSTGIS

          DATA 'geom from point1  using unique gid using srid=-1'


        NAME "mespoints"



 
  
  PROJECTION
    
   "init=epsg:4326" ##recommended
 END
        
 METADATA

      wms_title 'point1'
      wms_name 'point1'
      wms_include_items "all"    # pour GetFeatureInfo
      wms_feature_info_mime_type "text/plain"

      wms_srs 'EPSG:4326'

    END




    
        CLASS


        

            STATUS ON
            #EXPRESSION ( [gid] >= 0 and  [gid] < 10000000000  )
                 STYLE
                                
    
 
                       ANTIALIAS TRUE #antialiasing
                      COLOR 255 100 100
                SIZE [gid]  # symbole ponctuel proportionnel carte thematique
                      MINSIZE 0
                #MAXSIZE 1300
                 SYMBOL "circle"   # imageGIFouJPEG  #"tent"

                SIZE 10
                OUTLINECOLOR 255 100 20
                #color -1 -1 -1
                 OUTLINECOLOR 20 20 20
                 END     
   

              LABEL

                 Wrap ' ' # caractere ou chaine consdere pour sauter à la ligne dans label quand concat champ (TEXT()) 
                color 132 31 31
                ANTIALIAS TRUE #antialiasing

              END #end label


            END  #end class



        CLASS

            
             
            STATUS OFF
            EXPRESSION (  [gid] >= 10  ) 
             
                 STYLE
                       ANTIALIAS TRUE #antialiasing
                      
                SIZE 45
                      #MINSIZE 100
                #MAXSIZE 1300
                 SYMBOL "circle"
                 
                OUTLINECOLOR 20 20 20    


                 END     
   

              LABEL

                 Wrap ' ' # caractere ou chaine consdere pour sauter à la ligne dans label quand concat champ (TEXT()) 
                color 132 31 31
                ANTIALIAS TRUE #antialiasing

              END #end label


            END  #end class



    
        





    END #end layer












END

d'avance merci

Dernière modification par icadedt (Fri 30 April 2010 08:43)

Hors ligne

 

#2 Tue 04 May 2010 09:34

icadedt
Participant assidu
Lieu: ici et là
Date d'inscription: 21 Jul 2006
Messages: 478

Re: openlayers fonction getfeatureinfo sur couche ponctuelle

j'ai trouvé


il faut jouer sur le paramètre "TOLERANCE" dans la partie layer du mapfile et jouer aussi sur " FEATURE_COUNT" dans openlayers:

map.events.register('click', map, function(e) {

                document.getElementById('docs').innerHTML = "Patientez SVP...";

                var params = {
                    REQUEST: "GetFeatureInfo",
                    EXCEPTIONS: "application/vnd.ogc.se_xml",
                    BBOX: map.getExtent().toBBOX(),
                    X: e.xy.x,
                    Y: e.xy.y,
                    INFO_FORMAT: 'text/html',

                    QUERY_LAYERS: 'states_ugl,mespoints',

                    FEATURE_COUNT: 1, 
                    Layers: 'mespoints,states_ugl',
                   
                    Styles: '',
                    Srs: 'EPSG:4326',
                    WIDTH: map.size.w,
                    HEIGHT: map.size.h,
                    format: 'image/png',
                    VERSION: '1.0.0'

                };


                OpenLayers.loadURL("http://localhost:8081/cgi-bin/mapserv.exe?map=/ms4w/Apache/htdocs/test/mapfilepostgisWMS.map", params, this, setHTML)
                OpenLayers.Event.stop(e);


            });

Dernière modification par icadedt (Tue 04 May 2010 09:40)

Hors ligne

 

Pied de page des forums

Copyright Association GeoRezo