suppose you are given the co-ordinates of starting and end points of a road
segment.
Is there any way to extract the other set of co-ordinates laying on the
road segment
?

An example +++++++++++++

Here's an approach using Spatialite:
You can use the spatialite functions DissolvePoints() or DissolveSegments()
to get each point or line segment along a LINESTRING. Here's an example:

(I created  in advance a sample LINESTRING called 'seg')
PRAGMA table_info("seg");
0    pk_uid    integer    0    NULL    1
1    label    text    0    NULL    0
2    Geometry    LINESTRING    0    NULL    0

SELECT * FROM seg;
1    a    BLOB sz=176 GEOMETRY
2    b    BLOB sz=112 GEOMETRY

(I have two simple LINESTRINGs)
SELECT AsText(Geometry) FROM seg;
LINESTRING(1 1, 2 1, 2 2, 3 2, 4 2, 5 3, 6 2, 7 1)
LINESTRING(2 2, 2 4, 4 4, 5 2)

Now, I want to choose one of the linestrings, based on it's start and end
points:
SELECT AsText(Geometry) FROM seg
    WHERE StartPoint(Geometry) = GeomFromText('POINT(1 1)', 4326) AND
                    EndPoint(Geometry) = GeomFromText('POINT(7 1)', 4326);
LINESTRING(1 1, 2 1, 2 2, 3 2, 4 2, 5 3, 6 2, 7 1)

and to break up the LINESTRING into its segments:
SELECT AsText(DissolveSegments(Geometry)) FROM seg
    WHERE StartPoint(Geometry) = GeomFromText('POINT(1 1)', 4326) AND
        EndPoint(Geometry) = GeomFromText('POINT(7 1)', 4326);
MULTILINESTRING((1 1, 2 1), (2 1, 2 2), (2 2, 3 2), (3 2, 4 2), (4 2, 5 3),
(5 3, 6 2), (6 2, 7 1))
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to