Summary
In this article I showed you how to reduce the number of points in path or shape that is to be rendered on a map using the Douglas-Peucker algorithm.The primary reason for doing so is because mobile devices have limited capacity, and may struggle to show lines that have an extremely large number of points when lower-quality representation of the line is sufficient.
To demonstrate this in action, I used the shapes data from a General Transit Feed Specification (GTFS) data file. In the example, we reduced a shape made up 400 points to 70 points and rendered both on a map using the Google Maps API. In both instances the shape looked the same, yet the shape using only 70 points can be rendered far more easily on a device with limited capabilities.
Further Reading
- Douglas-Peucker algorithm on Wikipedia
- General Transit Feed Specification
- Google Maps JavaScript API
Other Options
- Download a PDF version of this article
- Put your PHP knowledge to the test with our online and iPad/iPhone quizzes
- View or post comments for this article
- Browse similar articles by tag: KML, Maps, PHP
No comments:
Post a Comment