2

I have a polygon and want to create a new polygon inside it which is spaced exactly 5 metres from the edge all around.

My thinking is to calculate the centroid, then get each point of the outer polygon and move it 5 metres towards the centroid.

Using the google.maps.geometry.spherical functions I should be able to computeHeading() to get the direction towards the centroid, then computeOffset() using the distance and the heading (direction).

This would move all of the vertices in by 5 metres. Would this mean that all my lines would automatically be spaced at 5 metres apart or would it depend on angles? I can do the JavaScript, not sure about the geometry. Is there a better approach?

Chris Smith
  • 480
  • 5
  • 12
  • Possibly the same as https://stackoverflow.com/questions/13248896/offsetting-polygons-in-javascript – dbc Dec 03 '14 at 23:19
  • 1
    You need to offset each edge of the polygon along its own normal vector, not towards the centroid, then trim or extend the corners to miter the polygon. It's nontrivial, and the library mentioned here may help: http://stackoverflow.com/questions/13248896/offsetting-polygons-in-javascript – dbc Dec 03 '14 at 23:24
  • Thanks @dbc. It's a lot more complicated than I had imagined, which is very useful to know in itself. – Chris Smith Dec 04 '14 at 10:29

0 Answers0