I've imported a KML
file in my database postgis
. When I select a road I've the right result:
This is one road. There aren't a lot of rows so I could order them manually but some roads have more then 100.
So I would like to order the linestrings at the import.
I have this :
1 - I would like to merge the linestrings. It's possible with ST_Union
to do this but if I do it now, the result is very strange that's why I have to order the lines.
2 - So I have to order the linestrings, that's why I have a column position in my table. I know how to get the end and the first point of a linestring.
When I do this :
SELECT ST_AsText(ST_ClosestPoint(ST_GeomFromText('POINT(7.38770714271048 47.5497446465569)',4326),geometrie)),
ST_AsText(ST_ClosestPoint(geometrie,ST_GeomFromText('POINT(7.38770714271048 47.5497446465569)',4326)))
FROM sections
WHERE nom_voie = 'LA THERMALE';
7.38770714271048 47.5497446465569
is the endpoint
It returns all rows of the road LA THERMALE.
Is there another solution to merge the linestrings maybe without ordering ?
When I concatenate the linestrings the result is false: it relate the endpoint of the Line 1 to the start point of the Line 4 etc. I think it's because they aren't ordered.