Divide a path into N sections using Java or PostgreSQL/PostGIS

Posted by Guido on Stack Overflow See other posts from Stack Overflow or by Guido
Published on 2010-05-03T19:00:15Z Indexed on 2010/05/03 19:48 UTC
Read the original article Hit count: 338

Filed under:
|
|

Imagine a GPS tracking system that is following the position of several objects. The points are stored in a database (PostgreSQL + PostGIS).

Each path is composed by a different number of points. That is the reason why, in order to compare a pair of paths, I need to divide every path in a set of 100 points. Do you know any PostGIS function that already implement this algorithm? I've not been able to find it.

If not, I'd like to solve it using Java. In this case I'd like to know an efficient and easy to implement algorithm to divide a path into N points.

The most simple example could be to divide this path into three points:

position 1 : x=1, y=2
position 2 : x=1, y=3

And the result should be:

position 1 : x=1, y=2 (starting point)
position 2 : x=5, y=2.5
position 3 : x=9, y=3 (end point)

Edit: By 'compare a pair of paths' I mean to calculate the distance between two paths. I plan to divide each path in 100 points, and sum the euclidean distance between each one of these points as the distance between the two paths.

© Stack Overflow or respective owner

Related posts about geometry

Related posts about postgis