[Mapserver-users] (no subject)

Eric Bridger eric at gomoos.org
Thu Jul 31 10:30:54 EDT 2003


I did something similiar with a shapefile of bathymetry lines using perl
mapscript to find the nearest line. e.g.

$click_pt is the point the user clicked.
loop to increase tolerance until we find some lines. calling
queryByPoint() each time.
 
while($layerObj->queryByPoint($map,$click_pt,$mapscript::MS_MULTIPLE,undef)){
   $layerObj->{tolerance} += 3;
}

Then open the shapefile and use the layer's result cache to retrieve
each shape found. 

$record_id = $results->{shapeindex}

$layerObj->getShape($shape, undef, $record_id);
Then check the distance of the click_pt to the shape and
save the record id if its the minimum so far.
$distance = $click_pt->distanceToShape($shape);

if($distance < $min_distance){
   $min_distance = $distance;
   $closest_record_id = $record_id;
}
 
When you done you have the dbf $record_id of the line closest to your
click point which you can use to retrieve the street name.

Eric



On Thu, 2003-07-31 at 17:00, Lowell Filak wrote:
> If you view lat/long as a point you can query a street layer by using
> the "tolerance" on the layer and doing a query.
> However I don't believe it returns the "closest", but you should be able
> to find discussion on this in the archives.
> Lowell
> 
> The following message was sent by "Hermie" <hartr at 3logix.com.au> on Thu,
> 31 Jul 2003 18:43:45 +1000.
> 
> > Hi,
> > 
> > Is there a standard command to access the name of the label/name of the
> > closest road/street based on a given lat/long.
> > 
> > Any assistance would be great.
> > 
> > Hart Runge
> > 3Logix Pty Ltd
> > Delivering Total Logistic Solutions
> > Ph. 1300 727 100
> > Fax 1300 727 101
> > Mobile 0402 794198
> > mailto:hartr at 3Logix.com.au <mailto:hartrung at remede.com.au>
> > http://www.3Logix.com.au <http://www.remede.com.au/>
> > 
> > This transmission is for the intended addressee only. If you have received
> > this transmission in error, please delete the mail and notify the sender.
> > The Contents of this e-mail are the opinion of the writer only and are not
> > endorsed by 3Logix Pty Ltd unless expressly stated otherwise.
> > 
> > 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the mapserver-users mailing list