[Mapserver-users] PHP Mapsctipt, PostGIS and extent of required features - a faster method?
Ellis Robin Bundaberg
Robin.Ellis at nrm.qld.gov.au
Tue Dec 2 15:49:41 PST 2003
Another message along the 'zoom to selected features' theme, but what I'm after is some hints that will hopefully speed my process up.
The concept of my system is that a user can input 1 or more unique identifiers for some cadastral polygon data we have stored in Postges/PostGIS format, with 1620320 records. The identifiers are placed into a string that is used firstly for applying a filter to the cadastre layer, and secondly to get the extent of the required features. The string (or 'filterexpression') would look something like:
fieldname = 'identifier1' or fieldname = 'identifier2' etc...
In PHP mapscript I use the following to apply the filter to my cadastre layer:
$zoomdcdblayer = $map->getLayerByName("Selected DCDB");
$thefilterexpression = $thefilterexpression." or lotplan = '".$thedcdbparcel."'";
$zoomdcdblayer->setfilter($thefilterexpression2);
This part works great, the filter is applied and displayed correctly in the blink of an eye. The next step is getting the extent of the required features so that view can be zoomed to the appropriate extent. I'm currently acheiving this like:
$extquery = "SELECT extent(geo_value) FROM sedcdb where $thefilterexpression";
$res = pg_query($connection, $extquery) or die("Error in query: $query. " . pg_last_error($connection));
$row = pg_fetch_row($res, $i);
$swlong = substr($row[0], 6, 10);
$swlat = substr($row[0], 17, 10);
$nelong = substr($row[0], 30, 10);
$nelat = substr($row[0], 41, 10);
$map->setextent($swlong,$swlat,$nelong,$nelat);
Which works well, however the time it takes to process the extent increases dramatically when more than one unique identifier is supplied. That is, the results for a single polygon are processed in around 1 second, two polygons in around 20 - 25 seconds, and so on. I do have an index created for the unique identifier field. The time lag appears associed with the 'select extent' query - maybe I could be structuring the details of this query in a smarter way, or maybe there is just a better way to go about it. We used to have a similar system utilising querymap and mapext=shapes, however this was outside of the mapscript realm and only worked for a single feature. I'm not sure mapscript and Postgis allow a simple replication of this.
Does anybody have any suggestions as to how the speed of processing may be improved?
Thanks
Rob
Robin Ellis
Department of Natural Resources and Mines
PO Box 1167
Bundaberg QLD 4670
ph +61 7 4131 5771
fax +61 7 4131 5823
Robin.Ellis at nrm.qld.gov.au
************************************************************************
The information in this e-mail together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.
Any form of review, disclosure, modification, distribution
and/or publication of this e-mail message is prohibited.
If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.
************************************************************************
More information about the MapServer-users
mailing list