[postgis-users] Help with query

Burgholzer,Robert rwburgholzer at deq.virginia.gov
Wed Dec 10 06:07:33 PST 2008


Mark,

This could be either a mapserver question, or a postgis question
depending on the solution you chose.  I would say the following
(untested code):

 

Mapserver:

-          define 3 layers, 1 for each concentric circle using your 1 dd
circle as the template, with duplicates of 2 and 3

 

PostGIS:

construct a query which will return 3 results for each point in your
set, using a UNION, and altering your gid to be a decimal with .1,.2,
and .3 appended on the end to insure a unique gid, something like:
DATA "the_geom from (  (SELECT buffer(geometryfromtext('POINT(' ||
(%mapx%) || ' ' || (%mapy%) || ')',4326), 1) AS the_geom, (gid::float8 +
0.1) as gid FROM kbapoly) UNION (SELECT buffer(geometryfromtext('POINT('
|| (%mapx%) || ' ' || (%mapy%) || ')',4326), 2) AS the_geom,
(gid::float8 + 0.2) as gid  FROM kbapoly) UNION (SELECT
buffer(geometryfromtext('POINT(' || (%mapx%) || ' ' || (%mapy%) ||
')',4326), 3) AS the_geom, (gid::float8 + 0.3) as gid FROM kbapoly) ) as
myquery using srid=4326 using unique gid" 

 

This PostGIS query assumes that mapserver will accept a floating point
as the unique identifier, rather than an integer, and I do not know if
that is acceptable or not.  Once again, probably more of a mapserver
question, when you get right down to it.

 

HTH,

r.b.

 

 

Robert W. Burgholzer

Surface Water Modeler

Office of Water Supply and Planning

Virginia Department of Environmental Quality

rwburgholzer at deq.virginia.gov

804-698-4405

Open Source Modeling Tools:

http://sourceforge.net/projects/npsource/

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of mark
balman
Sent: Tuesday, December 09, 2008 11:53 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Help with query

 

Hi All

 

I am trying to create a query that uses a mouse click to get coordinates
(from mapserver) and then features within a specified distance are
selected and displayed in different colours. The query I have at the
moment works well, however, the problem I am trying to solve is how to
indicate these distances with concentric circles around the coordinates
from the mouse click. Is this do-able? My query is as follows;

 

DATA "the_geom FROM (SELECT intname,the_geom, gid, distance(the_geom,
geometryfromtext('POINT(' || (%mapx%) || ' ' || (%mapy%) || ')',4326))
AS dist from kbapoly) as myquery using SRID=4326 using unique gid"

 

At the moment I define the distance from the CLASS EXPRESSION so I have
3 classes

 

1)  EXPRESSION ([dist] <= 1)

2)  EXPRESSION ([dist] >= 1 AND [dist] <= 2)

3)  EXPRESSION ([dist] >= 2 AND [dist] <= 3)

 

(distance is decimal degrees)

 

I can create a buffer around a mouse click on the map using the
following query

 

DATA "the_geom from (SELECT buffer(geometryfromtext('POINT(' || (%mapx%)
|| ' ' || (%mapy%) || ')',4326), 1) AS the_geom, gid as gid FROM
kbapoly) as myquery using srid=4326 using unique gid" 

 

What I am struggling with is how to combine these two queries if this is
possible. So I can display three concentric buffers at 1, 2 and 3
decimal degrees around the selected features.

 

Any help or advice would be really appreciated.

 

Thanks in advance

 

Mark

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081210/b70d9ea5/attachment.html>


More information about the postgis-users mailing list