[mapserver-users] Itemquery in Mapscript(PHP)

Laurent FOULONNEAU adsllaurentf at canl.nc
Sat Sep 1 01:00:40 EDT 2001


John,

Is this the only layer in your mapfile ? if yes it must show nothing at the
first time.

Have you tried a regex expression like /./  does it show somethig ? It show
all in my case...

I ve tested and it  work fine for me with OGR but in this case I have to
protect non regex $value with " "
eg :
$class->setExpression($value); -->  $class->setExpression("\"$value\"");
or directly in the search text box .

What is strange is that it did not zoom to the object ??? why ?

Your error look like more a problem with your mapinfo tables. Are you sure
that  your VA_CNTY.dat (for the data) exist and is not corrupted. I check my
mapinfo files with mapinfo proviewer before using them in mapserver.

My BDF.* mapinfo files comme from mapinfo 4.5 with a column named ID
My layer in map file  for OGR and mapinfo file is :
LAYER
  NAME BDF
  TYPE POLYGON
  STATUS ON
  CONNECTIONTYPE OGR
  CONNECTION "D:\Program Files\Apache
Group\Apache\htdocs\dev\montdore\BDF.tab"
  CLASSITEM "ID"
  CLASS
   NAME "ID"
  END
END # layer

Bon courage
Laurent FOULONNEAU


----- Original Message -----
From: "Arthur, John" <John.Arthur at voicestream.com>
To: "'Laurent FOULONNEAU'" <adsllaurentf at canl.nc>;
<mapserver-users at lists.gis.umn.edu>
Sent: Friday, August 31, 2001 12:44 AM
Subject: RE: [mapserver-users] Itemquery in Mapscript(PHP)


> Laurent,
>
> Thanks for your help.  I must be doing something wrong, it didn't seem to
> work for me. I'm using 3.5
> When I run the search the first time, the map is returned, but nothing is
> highlighted or zoomed.
> When I run the search the second time, an error is returned:
> Warning: MapServer Error in msLoadMap(): ():(0) in c:\program
> files\apache group\apache\mapinfo\htdocs\drawquery.php on line 7
>
> My layer is as follows:
>
> LAYER
>   NAME countysearch
>   TYPE POLYGON
>   STATUS ON
>   CONNECTIONTYPE OGR
>   CONNECTION "c:/mapinfo work files/VA/Counties/VA_CNTY.tab"
>   CLASSITEM "County"
>   CLASS
>    NAME "County"
>      END
> END # layer
>
> My form is as follows:
>
> <FORM>
>         <input type="hidden" name="mode" value="itemquery">
>         <input type="hidden" name="item" value="County">
>         <input type="hidden" name="qlayer" value="countysearch">
>         <input type="TEXT" size="30" name="value" value="">
>         <input type="submit" value="Search">
> </FORM>
>
> Does this not work with OGR?
>
> Thanks
> John Arthur
>
>
> -----Original Message-----
> From: Laurent FOULONNEAU [mailto:adsllaurentf at canl.nc]
> Sent: Thursday, August 30, 2001 7:48 AM
> To: Arthur, John; mapserver-users at lists.gis.umn.edu
> Subject: Re: [mapserver-users] Itemquery in Mapscript(PHP)
>
>
> Could certainly be improved.....
> First you have a blank image, when you use the search form, your object is
> 'automagically' ;) zoomed and painted in red
>
> The others object are not showed.
>
> Laurent
>
> //--------------------------------------begin draw_query.php
> <HTML>
> <?php
>
> dl("php_mapscript.dll");   // PHP4
>
> // variables globales
> $map_obj= ms_newMapObj("yourmapfile.map");
> $red = $map_obj->addColor(255, 0, 0);
>
> // fonctions
> function DrawQueryMap()
> {
> GLOBAL $map_obj,$mode,$item, $qlayer, $value,$red;
> if($qlayer && $mode == "itemquery" && $value && $item)
> {
> $layer = $map_obj->getlayerbyname($qlayer);
> for ($c=0; $c < $layer->numclasses; $c++)
>  {
>  $class=$layer->getclass($c);
>  if ($class->name == $item)
>   {
>    $class->setExpression($value);
>    $class->set("color", $red);
>   }
>  }
> }
>
>
>
>
>
> $img = $map_obj->draw();
> $url = $img->saveWebImage($img, 0, 0, -1);
> echo"<INPUT  TYPE=image SRC=$url  BORDER=0 WIDTH=$map_obj->width
> HEIGHT=$map_obj->height NAME=mainmap>";
> }
>
>
>
> ?>
>
> <HEAD>
>  <?php DrawQueryMap() ?>
>
> </HEAD>
> <FORM>
>         <input type="hidden" name="mode" value="itemquery">
>         <input type="hidden" name="item"
> value="your_class_name_in_the_map_file">
>         <input type="hidden" name="qlayer"
> value="your_layer_in_the_map_file">
>         <input type="TEXT" size="30" name="value" value="">
>         <input type="submit" value="Search">
> </FORM>
>
> </HTML>
> //------------------------------------- end of draw_query.php
>
> //-----------------------------yourmapfile.map : add a  layer with a class
> name and a classitem with the same name
> LAYER
>   NAME your_layer_in_the_map_file
>   TYPE POLYGON
>   STATUS ON
>   DATA your_shape_file
>   CLASSITEM "your_class_name_in_the_map_file"
>   CLASS
>    NAME "your_class_name_in_the_map_file"
>      END
> END # layer
> //----------------end of layer definition
>
>
>
> ----- Original Message -----
> From: "Arthur, John" <John.Arthur at voicestream.com>
> To: <mapserver-users at lists.gis.umn.edu>
> Sent: Thursday, August 30, 2001 7:10 AM
> Subject: [mapserver-users] Itemquery in Mapscript(PHP)
>
>
> > Sorry if this is documented somewhere, but I couldn't find anything on
how
> > to perform an Itemquery in PHP mapscript(not cgi).
> > I would like to type a search on a field (in a point or polygon layer)
and
> > return a map zoomed in on that search.
> >
> > John Arthur
> > RF Technician
> > Office:   (757) 490-7221
> > Cellular: (757) 692-1515
> > Email: john.arthur at voicestream.com
> > _~-^-~_
> > VoiceStream
> > W I R E L E S S
> >




More information about the mapserver-users mailing list