19 #ifndef GEOS_ALGORITHM_CENTRALENDPOINTINTERSECTOR_H
20 #define GEOS_ALGORITHM_CENTRALENDPOINTINTERSECTOR_H
22 #include <geos/export.h>
23 #include <geos/geom/Coordinate.h>
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
62 class GEOS_DLL CentralEndpointIntersector {
66 static const geom::Coordinate&
67 getIntersection(
const geom::Coordinate& p00,
68 const geom::Coordinate& p01,
const geom::Coordinate& p10,
69 const geom::Coordinate& p11)
71 CentralEndpointIntersector intor(p00, p01, p10, p11);
72 return intor.getIntersection();
75 CentralEndpointIntersector(
const geom::Coordinate& p00,
76 const geom::Coordinate& p01,
77 const geom::Coordinate& p10,
78 const geom::Coordinate& p11)
89 const geom::Coordinate&
90 getIntersection()
const
100 std::vector<geom::Coordinate> _pts;
102 geom::Coordinate _intPt;
107 geom::Coordinate centroid = average(_pts);
108 _intPt = findNearestPoint(centroid, _pts);
111 static geom::Coordinate
113 const std::vector<geom::Coordinate>& pts)
115 geom::Coordinate avg(0, 0);
116 size_t n = pts.size();
120 for(std::size_t i = 0; i < n; ++i) {
140 findNearestPoint(
const geom::Coordinate& p,
141 const std::vector<geom::Coordinate>& pts)
const
143 double minDistSq = std::numeric_limits<double>::max();
144 geom::Coordinate result = geom::Coordinate::getNull();
145 for(std::size_t i = 0, n = pts.size(); i < n; ++i) {
146 double distSq = p.distanceSquared(pts[i]);
147 if(distSq < minDistSq) {
163 #endif // GEOS_ALGORITHM_CENTRALENDPOINTINTERSECTOR_H