[postgis-users] Obtaining vertex order...

Obe, Regina robe.dnd at cityofboston.gov
Fri Jul 20 06:26:34 PDT 2007


If I understand you correctly, I think you are missing an order by
obstacles.id in your order by clause.  
 
create table wp_obs as select Pointn(exteriorring(obstacles.geom ),
generate_series(1,npoints(obstacles.geom)-1)) as geom,
nextval('wp_seq3') as id from obstacles, place where obstacles.geom &&
place.geometry and intersects(place.geometry,obstacles.geom) order by
obstacles.id, distance (Pointn(exteriorring( obstacles.geom),
generate_series(1,npoints(obstacles.geom)-1)),GeomFromText('POINT(3.2
-35.9)',-1));

 
Although for efficiency (you may want to try both, I think it may be
more efficient to order your obstacles table first in a subquery.
Something like below.
 
create table wp_obs as 
select Pointn(exteriorring(o.geom ),
generate_series(1,npoints(o.geom)-1)) as geom, nextval('wp_seq3') as id 
from (SELECT * FROM obstacles ORDER BY obstacles.id) o, place where
o.geom && place.geometry and intersects(place.geometry,o.geom) 
order by o.id, distance (Pointn(exteriorring( o.geom),
generate_series(1,npoints(o.geom)-1)),GeomFromText('POINT(3.2
-35.9)',-1));
 
As a side note -  using degree point distance for ordering doesn't
guarantee proximity if you are looking at large global areas.  This is
because the degree distance is not in line with actual physical distance
sort when you are looking across large areas.  You may want to order by
distance_sphere instead -  just a suggestion.
 
 

________________________________

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Manu
Sent: Friday, July 20, 2007 7:10 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Obtaining vertex order...


Hi, I am trying to create a table of vertex of a family of polygons,
order by the distance to a point (3.2 -35.9). I need also a integer
column id.

I made this:
create table wp_obs as select Pointn(exteriorring(obstacles.geom ),
generate_series(1,npoints(obstacles.geom)-1)) as geom,
nextval('wp_seq3') as id from obstacles, place where obstacles.geom &&
place.geometry and intersects(place.geometry,obstacles.geom) order by
distance (Pointn(exteriorring( obstacles.geom),
generate_series(1,npoints(obstacles.geom)-1)),GeomFromText('POINT(3.2
-35.9)',-1));


But id is not from ordered from 1. It seems that it creates table firts
to order later... How can I get id ordered?? I tried to do alter table
with generate series, but i coudn't make it work... 

Thanks

-- 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Manuel                                              
                                                          
manuelfgm at gmail.com                     
http://manuelfgm.blogspot.com         
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070720/6dc769de/attachment.html>


More information about the postgis-users mailing list