[mapserver-users] Querybypoint on wms / mapscript

jerome guitton jerome.guitton at agrocampus-ouest.fr
Fri Feb 12 10:55:13 EST 2010


I need to make a querybypoint on a layers that are wms layers.

the mapfile for the wms is

MAP
   EXTENT -7.62370822331571 43.5483013153076 -0.202127302673821 
48.9686855316162
   FONTSET "fonts.list"
   IMAGECOLOR 255 255 255
   IMAGETYPE PNG
   SYMBOLSET "examples.sym"
   SIZE 650 475
   STATUS ON
   UNITS METERS
   NAME "MS"

  PROJECTION
   "init=epsg:4326"
END


   WEB
     IMAGEPATH "/var/www/html/reglementation_fr/tmp/"
     IMAGEURL "/reglementation_fr2/tmp/"
     QUERYFORMAT text/html
     LEGENDFORMAT text/html
     BROWSEFORMAT text/html
TEMPLATE "TOTO"
    METADATA
  "queryable" "true"
    wms_title "Demo serveur WMS"
    wms_onlineressource 
"http://xxx/cgi-bin/mapserv?map=/var/www/html/reglementation_fr/data/mapfile/reglementations_wms.map& 
<http://xxx/cgi-bin/mapserv?map=/var/www/html/reglementation_fr/data/mapfile/reglementations_wms.map&>" 

    wms_srs "EPSG:4326"
    END
   END


  LAYER
     CONNECTION "user=xxx dbname=reglementations_france host=localhost 
password=xxx"
     CONNECTIONTYPE POSTGIS
     DATA "geom from (select distinct idcouche as oid,idcouche as 
gid,idcouche,geom,nom from couches where groupe like 'traitcote') as foo"
     LABELITEM "nom"
     METADATA
  "queryable" "true"
       "wms_title"    "layer_fond"
     END
     NAME "layer_fond"
     TEMPLATE 'TOTO'
  PROJECTION
       "init=epsg:4326"
     END
     STATUS ON
     TYPE POLYGON
     UNITS METERS
     CLASS
       STYLE
         ANGLE 360
         COLOR 200 200 200
         OUTLINECOLOR 0 0 0
         SYMBOL 0
         WIDTH 1
       END
     END
   END


END


And i want to make a query by point on a mapfile that use these wms layers

MAP
   NAME monde
   # Map image size
   SIZE 700 700
   EXTENT -6.844027 45.180141 -0.937777 50.224335
   PROJECTION
       "init=epsg:4326"
     END

   # Background color for the map canvas -- change as desired

   IMAGEQUALITY 95
   IMAGETYPE gif
   OUTPUTFORMAT
     NAME gif
     DRIVER 'GD/GIF'
     MIMETYPE 'image/gif'
     #IMAGEMODE PC256
     EXTENSION 'gif'
   END
   # Legend


   # 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'           'monde'
       '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
     NAME 'world_borders'
     TYPE POLYGON
TEMPLATE '../../tmp/test.html'
     DATA '/var/www/html/testmapscript/data/world_borders.shp'

     STATUS DEFAULT
     TRANSPARENCY 100



       END

    LAYER
     CONNECTION 
"http://xxxx/cgi-bin/mapserv?map=/var/www/html/reglementation_fr/data/mapfile/reglementations_wms.map& 
<http://xxxx/cgi-bin/mapserv?map=/var/www/html/reglementation_fr/data/mapfile/reglementations_wms.map&>" 

     CONNECTIONTYPE WMS
     METADATA
       "wms_srs"    "EPSG:4326"
"queryable"    "true"
       "wms_name"    "layer_fond"
       "wms_format"    "image/gif"
       "wms_server_version"    "1.1.1"
       "wms_title"    "layer_fond"
     ENDa
     NAME "layer_fond"
TEMPLATE '../../tmp/test.html'
     STATUS ON
     TYPE RASTER
     UNITS METERS
   END
END

With mapscript the map appear no problem. But then i want to know if 
i've got a layer that is on the point (0,48.20)

so here is my php file

<?php
$map_path="/var/www/html/testmapscript/mapfile/";

$map = ms_newMapObj($map_path."toto3.map") or die("on a mal charge le 
.map");

echo "Nombre de couches".($map->numlayers)."<HR>";

  $mpoint = ms_newPointObj();
     $mpoint->SetXY(0,48.20);
     // find into layer the most closed point
//------- LOOP ON LAYERS and get identify results.


$tot = $map->numlayers;
for ($i =0; $i < $tot; $i++) {
    //------- get map layer.
echo "on teste $i ";
    $oLayer = $map->getLayer($i);
    //------- Verify Layer type
    //------- Validate if query succeeds.
    $check_query = $oLayer->queryByPoint($mpoint, MS_SINGLE,0);

echo "---$check_query----".($oLayer->getNumResults())." ";
    if ($check_query != MS_SUCCESS) {echo "Rien ".$oLayer->name."<BR> ";}
         else {echo "on trouve une intersection avec 
".$oLayer->name."<BR>";}
    //------- Open layer for data input.
     $oLayer->open();

} // for i

?>


He find that my layer world_borders (from the shapefile) in on the point 
but not the second one. But both should be find.

Please why can't i querybypoint on a wms layer ?

Jerome guitton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100212/756a0d8f/attachment-0001.html


More information about the mapserver-users mailing list