0

I need to draw a maximum inscribed circle in a polygon. I found a library - https://github.com/PieceMaker/max-inscribed-circle - after little of googling. I have to do something wrong as my interpretation returns wrong result ( the circle should be more on right and radius looks strange to me ):

enter image description here

var coords = [
    [49.0138, 15],
    [49.0138, 15.0167],
    [49.0153, 15.0167]
];

var polygon = {
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [coords]
     },
     "properties": {
        "id": 1
     }
};

console.log(maxInscribedCircle(polygon, 7));

returns

{
  geometry: {
    coordinates: [49.0143, 15.011133333333333],
    type: "Point"
  },
  properties: {
    radius: 0.0004823742421792941,
    units: "degrees"
  }
}

I tried to switch [lat, lon] order, but I get same results.

The question Largest circle inside a non-convex polygon doesn't solve this issue as it describes different algorithm - it doesn't use https://github.com/PieceMaker/max-inscribed-circle library.

Any idea, why position is wrong? How to properly interpret radius - how can "degrees" be length units?

user3523426
  • 836
  • 3
  • 11
  • 26
  • Your coordinates (lat/lon) are in degrees in geodetic coordinates system, and result is expressed in degrees too. Note that one degree corresponds to different values in meters along meridian and along parallel (depending on latitude). – MBo Jun 14 '19 at 06:55
  • Possible duplicate of [Largest circle inside a non-convex polygon](https://stackoverflow.com/questions/4279478/largest-circle-inside-a-non-convex-polygon) – Eriks Klotins Jun 14 '19 at 07:43
  • MBo - OK, but it doen't explain ( or I don't get the point ), why the position is wrong - when you have a look on the picture, the circle should be more on east ( right ). I understand, that 1 degree lat cen be different than 1 degree lon and thet's why I am asking how to correctly interpret the radius in meters. – user3523426 Jun 14 '19 at 09:54
  • Eriks - yep, I found this asnwer, but it's not related to the libarary I use. It explains another algorithm, which is my plan "B" ;). – user3523426 Jun 14 '19 at 09:55

0 Answers0