/*private*/ void InteriorPointArea::addPolygon(const Geometry *geometry) { if (geometry->isEmpty()) return; Coordinate intPt; double width; auto_ptr<LineString> bisector ( horizontalBisector(geometry) ); if ( bisector->getLength() == 0.0 ) { width = 0; intPt = bisector->getCoordinateN(0); } else { auto_ptr<Geometry> intersections ( bisector->intersection(geometry) ); const Geometry *widestIntersection = widestGeometry(intersections.get()); const Envelope *env = widestIntersection->getEnvelopeInternal(); width=env->getWidth(); env->centre(intPt); } if (!foundInterior || width>maxWidth) { interiorPoint = intPt; maxWidth = width; foundInterior=true; } }
/** * Finds a reasonable point at which to label a Geometry. * @param geometry the geometry to analyze * @return the midpoint of the largest intersection between the geometry and * a line halfway down its envelope */ void InteriorPointArea::addPolygon(const Geometry *geometry) { LineString *bisector=horizontalBisector(geometry); Geometry *intersections=bisector->intersection(geometry); const Geometry *widestIntersection=widestGeometry(intersections); const Envelope *env=widestIntersection->getEnvelopeInternal(); double width=env->getWidth(); if (interiorPoint==NULL || width>maxWidth) { interiorPoint=centre(env); maxWidth = width; } //delete env; delete bisector; delete intersections; }