[postgis-users] Select a point that belongs to a linestring

andrea.alri90 at gmail.com andrea.alri90 at gmail.com
Tue Aug 13 09:51:36 PDT 2013


Hi everybody, I'm new in PostGIS world and I'm in trouble with points and
linestring. As title said I have a problem verifying that a point belongs to
a linestring. I've created those table with those commands:

CREATE TABLE Punti (
  Nome VARCHAR(20) PRIMARY KEY,
  Point GEOMETRY(POINT, 26910) NOT NULL
);

CREATE TABLE Strade (
  Nome VARCHAR(20) PRIMARY KEY,
  Road GEOMETRY(LINESTRING, 26910) NOT NULL
);

Those are two of my inserts:
INSERT INTO Strade VALUES('Strada1', ST_GeomFromText('LINESTRING(50 20, 30
20)', 26910));
INSERT INTO Punti VALUES ('Punto1', ST_GeomFromText('POINT(43 23)', 26910));

I added a point in linestring Strada1:
UPDATE Strade 
SET road=ST_AddPoint(road,ST_GeomFromText('POINT(43 23)'), 1)
WHERE nome='Strada1';

And this is the problematic query:
SELECT Strade.nome, ST_Within(Punti.point, Strade.road)
FROM Strade, Punti
WHERE Strade.nome='Strada1' AND Punti.nome='Punto1';

I supposed ST_Within returns true but it returns false. As ST_Within also
ST_Contains, ST_ContainsProperly, and others returns false.
Can you tell where is my error and how to solve it?

Thaks a lot
Andrea



--
View this message in context: http://postgis.17.x6.nabble.com/Select-a-point-that-belongs-to-a-linestring-tp5003990.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list