MKPolygon area calculation

前端 未结 3 997
萌比男神i
萌比男神i 2020-12-01 17:39

I\'m trying to make an area calculation category for MKPolygon. I found some JS code https://github.com/mapbox/geojson-area/blob/master/index.js#L1 with a link to the algori

3条回答
  •  情深已故
    2020-12-01 18:02

    This may help to someone... You need to pass the shape edge points into below method and it returns the correct area of a polygon

    static double areaOfCurveWithPoints(const NSArray *shapeEdgePoints) {
    
        CGPoint initialPoint = [shapeEdgePoints.firstObject CGPointValue];
    
        CGMutablePathRef cgPath = CGPathCreateMutable();
        CGPathMoveToPoint(cgPath, &CGAffineTransformIdentity, initialPoint.x, initialPoint.y);
    
        for (int i = 1;i

提交回复
热议问题