[mapserver-users] (no subject)
Neil Fincham
neil at asdf.co.nz
Mon Apr 13 15:47:41 PDT 2009
Hi All,
I am using ArcGIS 9.2 and MS4W. I have two php_mapscipts, one I use on
shapefiles the other I use on SDE (Running on MSSQL 2005), the strange thing
is that running on shape files the (Almost) identical scripts behave in
different manors. Here are the scipts;-
Just so you know;-
$ qLayer = the layer to be queried
$qField = Field to be Quried
$qSelect = The value to be selected
<?php
$layer = $map->getLayerByName($qLayer); // Select the layer
//////////////// Shapefile Version
if (($layer->querybyAttributes($qField, $qSelect, MS_MULTIPLE)) ==
MS_SUCCESS) {
//////////////// SDE Version
if (($layer->querybyAttributes($qField, "(" . $qField . "='" . $qSelect .
"')", mapscript.MS_MULTIPLE)) == MS_SUCCESS) {
$layer->open(); // If the query was successful open the layer
echo $layer->getNumResults();
for ($i=0; $i < $layer->getNumResults(); $i++) { // Loop through the
resaults
$result = $layer->getResult($i);
$shape = $layer->getShape($result->tileindex,
$result->shapeindex);
if ($i == 0) { // Set the bounds to the first resault
returned
$MinX = $shape->bounds->minx;
$MaxX = $shape->bounds->maxx;
$MinY = $shape->bounds->miny;
$MaxY = $shape->bounds->maxy;
} else { // Loop through the results and "push" out the
bounds
if ($MinX > $shape->bounds->minx) {
$MinX = $shape->bounds->minx;
}
if ($MaxX < $shape->bounds->maxx) {
$MaxX = $shape->bounds->maxx;
}
if ($MinY > $shape->bounds->miny) {
$MinY = $shape->bounds->miny;
}
if ($MinY < $shape->bounds->maxy) {
$MaxY = $shape->bounds->maxy;
}
}
}
$layer->close(); // Close the layer
}
$map->setextent($MinX - $qBuffer, $MinY - $qBuffer, $MaxX + $qBuffer, $MaxY
+ qBuffer);
?>
If I run the shapfile version and there are 20 results it extends the bounds
around them BUT if I run the SDE version it finds the first result and uses
those extents. I can ( echo $layer->getNumResults() ) to verify that.
Am I doing something wrong? Is there a better way of doing this?
Thanks Heaps
Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090414/380a6f9e/attachment.htm>
More information about the MapServer-users
mailing list