On Apr 3, 12:07 am, The Net Duck <[email protected]> wrote:
> HI
> I would like to be able to do two things and I don't know if it's
> possible with google maps api or if I need to build something myself.
>
> thing 1)
> I would like to be able to "thin out" coordinates on a poly line
> based on zoom level. This is because I don't need the amount of detail
> when I'm zoomed out and am serving this as a mobile friendly site so
> would like to use as little processes as possible.
>
> thing 2)
> I have many different polylines (I call them routes), and would
> like to only draw a polyline based on my maps "bounds". Is there a way
> to only draw a line this way? or is this something that I need to do
> by checking the coords that go into the creation of my polylines
> agents some "bounds" objects etc.
>
> Thanks so much!
> - The Net Duck
PolyCluster uses the following to perform point reduction:
x=l.x[i+1]-l.x[i-1];
y=l.y[i+1]-l.y[i-1];
z=x*(l.y[i]-l.y[i+1]+l.y[i]-l.y[i-1])-y*(l.x[i]-l.x[i+1]+l.x[i]-
l.x[i-1]);
z=(z*z)/(x*x+y*y);
where "z" is the square of the number of pixels away from the
"interpolation" line connecting the two immediate neighbors. You can
discard points for which "z" is less than the square of some
threshold. By using pixels rather than Lat/Lon coordinates,
projection distortion is avoided. The X & Y deltas are given the same
weight.
It is much quicker than Douglas-Peucker because it is non-recursive.
It can be done in a single pass. It is symmetric which means it
discards the same points in either direction. If two polys share a
common boundary, it will not produce gaps and/or overlaps. Douglas-
Peucker was designed for polylines but not for polygons.
You can see several demos at:
http://www.polyarc.us
An improved "US Highways" demo will be available soon.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.