<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I forgot to mention that you should probably generate_series using
numpoints(exteriorring(geom)) and not npoints(...) since you are using
pointn(exteriorring(...)). <br>
<br>
The difference is that numpoints returns the number of points in a
linestring, npoints returns the number of points in an entire geometry.
So if your polygons have any holes in them, npoints would return more
points than are in the exterior ring, which you are iterating through
using pointn(...). Although pointn is safe guarded against referencing
out-of-bounds indexes, you may get null values in your table.<br>
<br>
-- Kevin<br>
<br>
Kevin Neufeld wrote:
<blockquote cite="mid:46A0DB29.8060508@refractions.net" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
You could try using sub-queries:<br>
  <tt>CREATE TABLE wp_obs AS<br>
SELECT nextval('wp_seq3') as id, geom<br>
FROM (<br>
  SELECT geom <br>
  FROM (  <br>
    SELECT Pointn(exteriorring(obstacles.geom ),
generate_series(1,npoints(obstacles.geom)-1)) AS geom<br>
    FROM obstacles, place <br>
    WHERE obstacles.geom && place.geometry <br>
    AND intersects(place.geometry, obstacles.geom)<br>
  ) AS foo<br>
  ORDER BY distance(foo.geom, GeomFromText('POINT(3.2 -35.9)',-1))<br>
) AS foo2;</tt><br>
  <br>
or alternatively, add the id to your table the after you populate it
with geometries in the right order:<br>
  <tt>ALTER TABLE wp_obs ADD id serial;<br>
  <br>
  </tt>Cheers,<br>
Kevin<br>
  <br>
--------<br>
Kevin Neufeld<br>
Refractions Research Inc.<br>
  <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:kneufeld@refractions.net">kneufeld@refractions.net</a><br>
(250) 383-3022<br>
  <br>
  <br>
Manu wrote:
  <blockquote
 cite="mid:c9e0fdbb0707200410g387703aenac1b9ac0450d563@mail.gmail.com"
 type="cite">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.<br>
    <br>
I made this:<br>
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));<br clear="all">
    <br>
    <br>
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... <br>
    <br>
Thanks<br clear="all">
    <br>
-- <br>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br>
Manuel                                              <br>
                                                          <br>
    <a moz-do-not-send="true" href="mailto:manuelfgm@gmail.com">manuelfgm@gmail.com</a>                    
    <br>
    <a moz-do-not-send="true" href="http://manuelfgm.blogspot.com">http://manuelfgm.blogspot.com</a>        
    <br>
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    <pre wrap=""><hr size="4" width="90%">
_______________________________________________
postgis-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
  </pre>
  </blockquote>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
  </pre>
</blockquote>
</body>
</html>