[postgis-users] Mapserver extent question
Bill Binko
bill at binko.net
Tue Sep 20 14:37:37 PDT 2005
> > Hello,
> >
> > I have an extent from mapserver (e.g., "-121.682485 38.408966
> > -121.231440 38.763359") that I want to feed back into a PostGIS query.
> >
> > How do I express this extent in my query?
> >
> > I want to write a query something like
> >
> > select recid from tbl_points
> > where the_geom && <what goes here?> ;
> >
> >
Perhaps a simpler answer for you might be an undocumented feature in the
Mapserver PostGIS interface.
If what you want is to be able to include the _current_ visible extent,
you can use a special syntax like this: !BOX!
Months ago, I was playing with this. I wanted to take the average value
for the visible region and colorize the results based on the deviation
from the average. (I was just playing) To do that, I needed the box so
that I could calculate the average. Of course, it's incredibly
inefficient to do it this way, but here's how I used !BOX!...
DATA "parcel_shape from (select parcel_shape, parcels.oid,
total_acreage/ave_acreage as pct, total_acreage, ave_acreage
from parcels join parcel_info on sdf_num = feat_num ,
(select avg(total_acreage) as ave_acreage from parcels join
parcel_info on sdf_num = feat_num WHERE (zoning like 'R%' OR
zoning is null) AND parcel_shape && setSRID(!BOX!, 26759) and
Within(parcel_shape, setSRID(!BOX!, 26759))) as bar
where zoning like 'R%' or zoning is null) as foo using SRID=26759"
The point is that it will insert the current extents into the query string
wherever you put !BOX! (During 4.6 development, I submitted a patch that
allows > 1 !BOX!. Before that, you can only use it once.)
Hope this helps
Bill
More information about the postgis-users
mailing list