[Mapserver-users] Mapscript Querying Projected layer.
Eric Bridger
eric at gomoos.org
Mon Feb 24 02:42:26 PST 2003
I am using mapserver and mapscript with PROJ4 to display a non-projected
map in decimal degees:
PROJECTION
"proj=lat/long"
END
UNITS DD
Most of the layers are in lat/long coordinate shape files. But one
layer is in UTM coordinates. That layer has a utm projection:
LAYER
NAME "surficial"
TYPE "POLYGON"
TEMPLATE "none.html"
...
PROJECTION
"proj=utm"
"ellps=GRS80"
"zone=19"
"north"
"no_defs"
END
...
This is all working fine.
But I am having trouble querying the projected layer using Perl
Mapscript3.6.4. I am creating a point object, which is then used in
layer->queryByPoint() to get the polygon clicked on.
When the overall map projection is UTM, the point object is created in
UTM meters and queryByPoint() works as expected.
But when the overall map is in latlong projection, the point is created
using lat/long and then point->project(geo_proj, utm_proj) is called to
project the point into the UTM. All this works correctly, the point
coordinates are now in UTM meters. But layer->queryByPoint() always
fails to return any results. I'm puzzled by the fact that identical
code works on the UTM projected map, but not on the UTM projected layer.
Am I missing something?
Eric Bridger
Gulf of Maine Ocean Observing System www.gomoos.org
code snippet:
my $proj_utm = new
projectionObj('proj=utm,ellps=GRS80,zone=19,north,no_defs');
my $proj_geo = projectionObj('proj=latlong');
# reproject the point if overall map projection is latlong
if($map->getProjection() =~ /latlong/){
$click_pt->project($proj_geo, $proj_utm);
}
$layer = $map->getLayerByName('surficial');
if($layer->queryByPoint($map,$click_pt,$mapscript::MS_MULTIPLE,0)){
$error = "No results!\n";
}
More information about the MapServer-users
mailing list