rubydio
rubydio

Reputation: 115

Enlarge polygon in Java by given distance

Given a polygon in Java I'm looking to add to it a security margin (extra radius) of X meters around, my polygon is a set of coordinates (latitude, longitude and altitude) of course.

Example:

            <coordinates>
              -0.4152899,39.4792891,0
              -0.4156305,39.4785997,0
              -0.4154294,39.478521,0
              -0.4150941,39.478935,0
              -0.4150914,39.4791048,0
              -0.4152899,39.4792891,0
            </coordinates>

I want it to be scaled X meters around. How could I achieve this? Thanks in advance

Upvotes: 1

Views: 115

Answers (1)

Fredrik Persson
Fredrik Persson

Reputation: 231

The most basic way i can come up with here is to calulate the centre point the polygon. Then Extend the polygon points away from the centre with X distance.

It probably won't give you a perfect 1m "barrier" around the polygon but it should be somewhat effective. I will probably require some math to figure out as well.

Upvotes: 1

Related Questions