문제

I'm converting a KML file to a polygon stored on my database thanks to RGeo

I need the centroid: @area.centroid and I would like to find the approximative radius on my shape. I don't know if it's possible. My database field is a geometry. That means I can store polygons AND multi-polygons. The type of my area is RGeo::Geos::CAPIMultiPolygonImpl

Finally I think I need the check if the area is a simple polygon or a multiple. If it's a simple one, I would like to find the radius. Else nothing.

Thank you for your help !

도움이 되었습니까?

해결책

I finally did like below:

  1. Convexe Hull
  2. Centroid of this Convexe Hull
  3. minimum distance between Convexe Hull points (thanks to exterior_ring function) and the centroid

By the way I don't know why I had to take the minimum. It was to adapt my scale. I don't really understand how the centroid of a polygon (which could have really strange shape) can be found.

Anyway, it's working thanks to the 3 steps written previously.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top