Reputation: 1901
Is there a way to return linestrings from my postgis database in this type of format?
Line: 1, "Road" 35.62200200, -88.98259200 35.62203500, -88.98240800 35.62202700, -88.98231000 35.62180000, -88.98163400 35.62175700, -88.98149000 35.62172500, -88.97881200 35.62172000, -88.97798500 35.62169800, -88.97752400 35.62170300, -88.97736200 35.62173900, -88.97723200 35.62180600, -88.97715200 35.62292600, -88.97608000 35.62467700, -88.97441600 35.62482100, -88.97429800 End:
Upvotes: 2
Views: 1166
Reputation: 1901
This worked for me its a custom format, or is it known? There are several geometry output functions, and you can always parse their output into something new, for example:
SELECT 'Line: ' || id || ', ' ||
trim(translate(ST_AsText(ST_FlipCoordinates(ST_Transform(the_geom, 4326))),
'MULTILINESTRINGZM()', '')) || ' End:' AS output
FROM nqatrkl;
Or you can dump the points and tinker around with them some other way:
SELECT id, time, (d).path, (d).path[1] AS part,
ST_Y((d).geom) AS lat, ST_X((d).geom) AS lon
FROM (SELECT id, time, ST_DumpPoints(ST_Transform(the_geom, 4326)) AS d
FROM nqatrkl) AS foo
ORDER BY (d).path;
Upvotes: 0
Reputation: 43642
Do you have a custom format, or is it known? There are several geometry output functions, and you can always parse their output into something new, for example:
SELECT 'Line: ' || id || ', ' ||
trim(translate(ST_AsText(ST_FlipCoordinates(ST_Transform(the_geom, 4326))),
'MULTILINESTRINGZM()', '')) || ' End:' AS output
FROM nqatrkl;
Or you can dump the points and tinker around with them some other way:
SELECT id, time, (d).path, (d).path[1] AS part,
ST_Y((d).geom) AS lat, ST_X((d).geom) AS lon
FROM (SELECT id, time, ST_DumpPoints(ST_Transform(the_geom, 4326)) AS d
FROM nqatrkl) AS foo
ORDER BY (d).path;
Upvotes: 0
Reputation: 1191
you should concat the xy's
LINESTRING('|| s."X" ||' '||s."Y" ||','|| s."X" || ' '||s."Y" || ')'',2309)
hope too be usefull for you :)
Upvotes: 4