Thread: Need a little help with geometric query

Need a little help with geometric query

From
lxnf98mm@comcast.net
Date:
This is my first shot at using postgresql's geometric functions
I have a passel of lines defined by x1 y1 x2 y2
I created a table with type lseg and loaded it
I start by finding the line that has an end closest to 0,0
Now I want to find the next line that has an end closest to the first line's other end and so on
I want to find the shortest path
I see there are a lot of geometric operators but I am a bit baffled
Can someone offer suggestions or reading references

Thanks
Richard


Re: Need a little help with geometric query

From
Samuel Gendler
Date:


On Thu, Aug 25, 2011 at 3:56 PM, <lxnf98mm@comcast.net> wrote:
This is my first shot at using postgresql's geometric functions
I have a passel of lines defined by x1 y1 x2 y2
I created a table with type lseg and loaded it
I start by finding the line that has an end closest to 0,0
Now I want to find the next line that has an end closest to the first line's other end and so on
I want to find the shortest path
I see there are a lot of geometric operators but I am a bit baffled
Can someone offer suggestions or reading references

Forget about the built-in geometry types and operators in postgres.  You really want to take a look at postGIS for doing geometric calculations.  It has a much more diverse set of operators and functions and adheres to various GIS standards which will allow your db to interact with other GIS tools as well. It is quite easy to learn and there is an excellent book which, I believe, also has an electronic edition available so you can start reading immediately.  Finding a geometry that is 'closest' to a particular point or to another 2D geometry (or even 3D in the upcoming version) is relatively trivial.  I'm sure there is a function, or at least a common technique, for finding a shortest path between 2 points, since GIS is often used for mapping applications. It's not my specialty, so I'll leave the details to your research.