views:

169

answers:

1

As some of you may know, there is an encoding algorithm in Google maps API which optimizes polyline drawings in different zoom levels. It removes-adds the coordinates of a path according to the current zoom level and decreases-increases the drawing computation time. Specifically, I mean the algorithm in the GPolyline.fromEncoded method. In a different platform other than javascript I need an algorithm like that. Of course I don't think using a google style professional code. Is there another algorithm like that of which I can see the code and re-implement it according to the suitable platform? Or what are your suggestions to accomplish the optimization of path drawings in different zoom levels?

+1  A: 

What about the following.

  1. Pick a constant DetailRadius depending on the zoom level.
  2. Pick a start point on the polygon.
  3. Test if the next point of the polygon is inside or outside a circle with a radius of DetailRadius around the current point, that is if the distance between the current and the next point is smalleer or larger then DetailRadius.
    1. If the next point is outside the radius, move from the current to this point.
    2. If the next point is inside the radius, delete it and continue at 3. with the new next point.

One could also think about removing all points in the circle, not only neighoubrs of the current point. This will lead to further detail reduction, but it is computationaly more expensive and might lead to more geometric distortion because it will "push away points from the current point".

Daniel Brückner
that seems perfectly logical but I'll try this first and then give your answer a feedback. thanks
cocoatoucher