I am building a C# program that needs to determine if a journey passes through a zone.
I have a database storing 50+ polygons (the zones) in the format of:
Lat | Lng | ZoneName
I'm using the Google Directions API and decoding the overview_polyline response to receive a collection of Lat & Long coordinates that represent 'the journey'.
So, I need to check if the route (the journey) intersects with any of the polygon zones I have stored within the database.
I wonder if I should take the following approach:
- Pull the zone coordinates out of the database to dynamically represent my polygon zone.
- For each journey step, determine if the lat & long coordinate is inside that polygon
I see point 2 could be achieved here.
But that could be quite some processing.
A short journey returned about 300 odd lat/long coordinate 'steps' for the polyline & each polygon has about 10 or more lat/long coordinates that comprise the shape boundaries.
Is there a more efficient way of doing this please?