Streamlining Geolocation Data for Efficient Route Mapping: How to Simplify Coordinates for Improved Accuracy?

31 views Asked by At

I'm facing a challenge in my project and would like to ask for some assistance. I need to implement a functionality that captures the user's location in my application using the library

https://github.com/capacitor-community/background-geolocation
background-geolocation

The goal is to store the user's entire route during the use of the application and, ultimately, display the exact route that they traveled. Currently, I'm using the open-source API

https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/post
openrouteservice

to generate the traveled route. However, this** API has a limit of 70 coordinate points**, while the background-geolocation library returns the location every 50 meters to ensure greater precision, resulting in thousands of coordinates for a simple 5 km trip.

I would like to know how I can optimize my array of coordinates to eliminate unnecessary ones, such as coordinates in a straight line on a highway. The focus is on identifying the most relevant points, such as map intersections, changes in direction, and entering a new street. I would greatly appreciate any guidance or suggestions on this matter.

I've increased the distance between the points where the background-geolocation library collects data, but this has resulted in a lack of precision, particularly in densely populated areas with numerous intersections. Ultimately, my application displayed an incorrect route.

1

There are 1 answers

1
Carlos Eduardo On

I found a solution to my problem, there is an algorithm called Douglas-Peucker that removes unnecessary points