[postgis-users] RE : Linestring intersections + intersection order

Nicolas Ribot nicolas.ribot at gmail.com
Mon Jun 18 01:48:19 PDT 2012


> Hello,
>
> I think you could order your points using st_distance. Something like this request should work :
>
>
> select
> st_distance(st_startpoint(a.the_geom), st_intersection(a.the_geom, b.the_geom)),
> st_intersection(a.the_geom, b.the_geom) the_geom
>
> from my_single_linestring a, my_table_of_linestrings b
>
> where st_intersects (a.the_geom, b.the_geom)
>
> order by st_distance(st_startpoint(a.the_geom), st_intersection(a.the_geom, b.the_geom))
>
> I don't know how to have a simple id (1, 2, 3, ..., n) without creating a new table with serial column or using a plpg function with a loop.
>

Hi Hugues :)
By creating a sequence and calling nextval('sequence'), you will be
able to generate a series of numbers.

Nico



More information about the postgis-users mailing list