On Feb 11, 2:33 pm, Paulo JF Silva <[email protected]> wrote:
> Maybe I didn't explain correctly but that solution doesn't work for me
> as I want to show polylines that have *some* part of it in the
> viewport, not that are completely inside the viewport.

I don't think the solution is trivial, but it can be done with some
computation since your case of two-point straight lines makes it
easier.

Each of your lines can be reduced to an equation of the form y=mx+c,
and you have two points, say A at (xa,ya) and B at (xb,yb). Each of
the lines of the bounding box (viewport) is also a line -- say w,e,s,n
for west-longitude, east-longitude, south-latitude, north-latitude.

If the line AB passes through the left-hand side of the viewport, then
there will be a solution for y=mx+c where x=w and y lies between s and
n, and w-xa and xb-w are of the same sign. Do similar tests for each
side of the viewport. If the line passes through any of the sides,
some part of it will be inside the viewport and you need to show it.

Testing edge w: Show the line if s <= mw+c <= n and (w-xa)/(xb-w) > 0

If xa and xb are both between w and e, AND ya and yb are both between
s and n, the line is entirely within the viewport.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-api?hl=en.

Reply via email to