enter image description here

I have few points from server and I want to draw a line with this point on road. But the leaflet drawing point to point line as shown in picture in orange color. But I want to draw the line according to the blue line. How it can be done?


  • 3
    From your illustration it looks like you don't have any point in the crossing. Then, how can you expect the line to go there? – Nicklas Avén Apr 3 '13 at 10:25
  • This is the issue.... – Devils Dream Apr 3 '13 at 10:31
  • well, then your question is about how to get the point in the road crossing, right? Then, what is your problem? Is it to find out the coordinates of the road-crossing, or is it how to get that coordinates into the linestring in PostGIS? – Nicklas Avén Apr 3 '13 at 10:35
  • Why don't you just get the lines from the server? – Alex Leith Apr 8 '13 at 4:46

pgRouting could be a solution (Official website), are you tried it as PostgreSQL extension?, it could do the trick... But, you needs a good vectorial layer "road".

It's only a idea... :)


If you know all of your roads are pure N/S and E/W you could use the two points on either side of the intersection to come up with the intermediate point. In other words, if the last point before the turn is X1,Y1 and the point after the turn is X2,Y2, you could insert a point X1,Y2 which would be the intersection. Of course, this only works if you have all right angles in your routes and they are all completely N/S or E/W. Another option which could work or straight lines without requiring N/S and E/W routes would be to find a line for each route and then find the intersection. You would need a second point on the route after the turn though. Otherwise, you simply do not have the data for the point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.