Created
February 21, 2011 19:18
-
-
Save hamishcampbell/837545 to your computer and use it in GitHub Desktop.
Example statement to determine linear chainage from line segment (PostgreSQL + PostGIS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @lon = longitude of selected point | |
* @lat = latitude of selected point | |
*/ | |
SELECT | |
name, | |
CAST( | |
offset + | |
ST_Length(the_geom) * ST_Line_Locate_Point(the_geom, ST_Point(@lon, @lat)) | |
) AS Double) | |
AS chainage | |
FROM carriageway | |
ORDER BY ST_Distance(the_geom, ST_Point(@lon, @lat)) ASC | |
LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment