6

I know there are various discussions on SO about line intersections and the math behind it. I am familiar with the math.

This post nicely explains an algorithm one can implement: Determine if two lines intersect

However, I was wondering whether one can do this directly in Google Maps. I am drawing various lines on a Google Maps and my aim is to determine how many lines any given line crosses/intersects and if so where geographically does the intersection occur. I want to auto render the lines with a set criteria that penalizes intersections and factoring in other optimization criteria. Computation speed is a factor as I have thousands of lines.

Below is an example picture of my application with lines interesting.

enter image description here

codingknob
  • 11,108
  • 25
  • 89
  • 126
  • But if you're the one drawing the lines, why delegate the intersection calculation to google maps? Even if it was possible, you might lose control over the points it generates (not familiar with the API, just general experience) – Tomáš Zato May 22 '18 at 15:16
  • How is this question very broad? There hasnt been a single SO post that explicitly walks a user through fast/efficient detection of whether lines interest when you have a universe of thousands of lines. Not a single SO post does this for a universe of 2 lines. So how is this a broad question? – codingknob May 22 '18 at 16:53
  • @TomášZato Appreciate the suggestion. I have tens of thousands of lines. So I think it may get computationally expensive if I'm doing this outside of Google Maps. I can try that way but it would be nice if Google Maps exposed this information. – codingknob May 22 '18 at 17:49
  • 1
    Can you calculate it on the fly only for the area displayed to the user, client side? – Tomáš Zato May 22 '18 at 18:35
  • I don't think that will work for the application requirements as that would require processing for every zoom and scroll up/down of the window for thousands of lines. I am investigating further. – codingknob May 22 '18 at 19:07

0 Answers0