[mapserver-users] Create Dynamic Pt Layer, then queryByPoint()
Stephen Woodbridge
woodbri at swoodbridge.com
Fri Mar 1 14:33:37 PST 2002
Dan,
The LAYER must have TEMPLATE defined or it will NOT be queried so make
sure you have that set.
-Steve
Dan Barron wrote:
>
> I'm new Mapserver, been working with it for a few weeks now. This list and
> its archives have been a great resource of experience to draw on! I'm
> hoping someone can help me with a problem I seem to be having.
>
> I am trying to do the following:
>
> 1) using PHP/Mapscript, query a database of georef points, then create a
> dynamic layer of type POINT to display them
> 2) then use the queryByPoint() function to query a point
> 3) also use the queryByRect() function to query the whole current view ( a
> suggestion found in another post )
>
> Well, 1) is successful but 2) & 3) returns MS_FAILURE value or 1 - doesn't
> find anything. I would have expected 3) to at least find something since
> there are points being displayed in the current extent. I have looked
> through all the examples and the mail list archive to no avail at this
> point. Below are the relevant parts of my map file and php file.
>
> Anyone know the trick to this? Thanks!
>
> Dan Barron
> Destination Software LLC
> San Diego, CA
> dbarron at ddive.com
>
> << snip from map file for the point layer>>
> -------------------------------------------
> LAYER
> NAME 'point-test'
> TYPE POINT
> STATUS OFF
> CLASS
> name 'point-test'
> SYMBOL 'c:\bin\mapserver\mapservertest\graphics\novice-icon.png'
> template 'point-test-template.html'
> END
> tolerance 10
> END
>
> << snip from php file for the point query>>
> -------------------------------------------
> // turn it into lat lon values
> $georef_x = $mapext->minx + ($pix_x/$w)*($mapext->maxx-$mapext->minx);
> $georef_y = $mapext->maxy - ($pix_y/$h)*($mapext->maxy-$mapext->miny);
> $georef_pt = ms_newPointObj();
> $georef_pt->setXY( $georef_x, $georef_y);
>
> // set the new extent values
> $my_extent = ms_newrectObj();
> $my_extent->setextent($extent_to_set[0],$extent_to_set[1],
> $extent_to_set[2],$extent_to_set[3]);
>
> $mode = $HTTP_POST_VARS["mode"];
> if( $mode == $query_selected ) {
> $zoom_factor = 0;
> $check_query = "checked";
>
> // query by point defined by mouse click
> $found = $map->queryByPoint($georef_pt, MS_SINGLE, -1);
> echo "query found=".$found."<br>";
>
> $qr = ms_newRectObj();
> $qr->setextent($extent_to_set[0],$extent_to_set[1],
> $extent_to_set[2],$extent_to_set[3]);
>
> // query by rectObj the size of current view extent
> $found = $map->queryByRect($qr);
> echo "query found=".$found."<br>";
More information about the MapServer-users
mailing list