Union Polygons

2,071 views
Skip to first unread message

Diogo Outerelo da Silva

unread,
Feb 11, 2011, 10:19:46 PM2/11/11
to google-map...@googlegroups.com
Hello,
I have some days trying to make a "bound" to my polyline route but i still having problem. First i tried to use the route boxer like the google example (http://gmaps-samples-v3.googlecode.com/svn/trunk/routeboxer/routeboxer-v3.html) demo gallery, but with a large route and a great precision its make the browser stop, because make so many latlongbounds. So i was searching for another solution and i found from Marcelo Montagna here (http://gis5.com/pois_along_route/gm_pois_along_route.php), but its protected to copy. Then i start make my own code... 
There is the step that i think to my code:

1 - Make a circle around each point(lat, long) - like 12 points around each the latlong
2 - Get the most external point for each 2 latlong circle and make a polygon (fecho) - total = (points - 1) poligons
3 - union the poligons to make a unique polygon and apply a color and opacity

the problem is that i can`t find a algorithm to "union" this polygons. Someone know a algorithm that i can use or a API for google maps to make it with the polygons?

I can`t make another polyline with biggest stroke weight because i need the "bound" points to search for POI`s.

Thx in advance
-- 
,
Diogo

--

geoco...@gmail.com

unread,
Feb 12, 2011, 2:37:53 AM2/12/11
to Google Maps JavaScript API v3
On Feb 11, 7:19 pm, Diogo Outerelo da Silva <diogoouter...@gmail.com>
wrote:
> Hello,
> I have some days trying to make a "bound" to my polyline route but i still
> having problem. First i tried to use the route boxer like the google example
> (http://gmaps-samples-v3.googlecode.com/svn/trunk/routeboxer/routeboxe...)
> demo gallery, but with a large route and a great precision its make the
> browser stop, because make so many latlongbounds. So i was searching for
> another solution and i found from Marcelo Montagna here (http://gis5.com/pois_along_route/gm_pois_along_route.php), but its protected
> to copy. Then i start make my own code...
> There is the step that i think to my code:
>
> 1 - Make a circle around each point(lat, long) - like 12 points around each
> the latlong
> 2 - Get the most external point for each 2 latlong circle and make a polygon
> (fecho) - total = (points - 1) poligons
> 3 - union the poligons to make a unique polygon and apply a color and
> opacity
>
> the problem is that i can`t find a algorithm to "union" this polygons.
> Someone know a algorithm that i can use or a API for google maps to make it
> with the polygons?

You could do a convex hull of all the vertices.

-- Larry

Diogo Outerelo da Silva

unread,
Feb 12, 2011, 7:12:00 AM2/12/11
to google-map...@googlegroups.com
i use convex hull to get the external points of each polygon. the problem is to union the polygons. if i use  the convex hull in all points i will not get a right route.
The image1 of the attach is what i will get if i do the convex hull with all points. The image2 is what i am doing in the code. I need to union/merge the polygons.

--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.




--
Atc,
Diogo

--
convex hull.png

Rossko

unread,
Feb 12, 2011, 11:47:43 AM2/12/11
to Google Maps JavaScript API v3
> The image1 of the attach is what i will get if i do the convex hull with all
> points. The image2 is what i am doing in the code. I need to union/merge the
> polygons.

I see the problem, it will be quite a challenge to get a single
polygon as you want. Do you think the performance will be any better
than with routeboxer?

I think there is a method to generate a "thick polyline", by
calculating the bearing from each vertex to the next, and setting out
points at a perpendicular distance either side.

Esa

unread,
Feb 12, 2011, 12:34:47 PM2/12/11
to Google Maps JavaScript API v3
Bill Chadwick's demo page is a great resource for this kind of
problem.
http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm
See the bottom of the page. Distance to Polyline and Parallel
Polylines.

The syntax is for API v2 though.

Diogo Outerelo da Silva

unread,
Feb 15, 2011, 6:47:37 AM2/15/11
to google-map...@googlegroups.com
Hello,
   @Rossko
        Thx for answer
        Router boxer with a precision of 500 meters and a route with 3000km in diagonal make more than 1000 bounds. 
       
   @Esa 
        Thx for answer
        I saw the example, but i needed a polygon to draw on map. With the polygon i can calcule if a latlong is in the route. 
        

After i search more i found a API called JTS, for java. This API have the convex hull algorithm, that i already had, and the union of polygons. Now i am using this API to calculate the polygon and return to draw on client( image in attach).

Thx for help guys

,
Diogo

bounds.png
Reply all
Reply to author
Forward
0 new messages