mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:00:06 +00:00
Moved to using (likely) public API in geos
This commit is contained in:
parent
f7abda15c8
commit
7581fcde5d
1 changed files with 8 additions and 9 deletions
|
|
@ -5,8 +5,7 @@
|
||||||
|
|
||||||
#include <GeographicLib/Gnomonic.hpp>
|
#include <GeographicLib/Gnomonic.hpp>
|
||||||
#include <geos/algorithm/PointLocation.h>
|
#include <geos/algorithm/PointLocation.h>
|
||||||
#include <geos/algorithm/distance/PointPairDistance.h>
|
#include <geos/operation/distance/DistanceOp.h>
|
||||||
#include <geos/algorithm/distance/DistanceToPoint.h>
|
|
||||||
#include <geos/geom/CoordinateSequence.h>
|
#include <geos/geom/CoordinateSequence.h>
|
||||||
#include <geos/geom/GeometryFactory.h>
|
#include <geos/geom/GeometryFactory.h>
|
||||||
|
|
||||||
|
|
@ -258,20 +257,19 @@ GetDistanceAreaPoint(const std::vector<common::Coordinate>& area,
|
||||||
// Get the closes point on the geometry
|
// Get the closes point on the geometry
|
||||||
auto geometryFactory = geos::geom::GeometryFactory::getDefaultInstance();
|
auto geometryFactory = geos::geom::GeometryFactory::getDefaultInstance();
|
||||||
auto lineString = geometryFactory->createLineString(sequence);
|
auto lineString = geometryFactory->createLineString(sequence);
|
||||||
|
auto zeroPoint = geometryFactory->createPoint(zero);
|
||||||
|
|
||||||
geos::algorithm::distance::PointPairDistance distancePair;
|
std::unique_ptr<geos::geom::CoordinateSequence> closestPoints =
|
||||||
geos::algorithm::distance::DistanceToPoint::computeDistance(
|
geos::operation::distance::DistanceOp::nearestPoints(lineString.get(),
|
||||||
*lineString, zero, distancePair);
|
zeroPoint.get());
|
||||||
|
|
||||||
geos::geom::CoordinateXY closestPoint = distancePair.getCoordinate(0);
|
|
||||||
|
|
||||||
double closestLat;
|
double closestLat;
|
||||||
double closestLon;
|
double closestLon;
|
||||||
|
|
||||||
gnomonic.Reverse(point.latitude_,
|
gnomonic.Reverse(point.latitude_,
|
||||||
point.longitude_,
|
point.longitude_,
|
||||||
closestPoint.x,
|
closestPoints->getX(0),
|
||||||
closestPoint.y,
|
closestPoints->getY(0),
|
||||||
closestLat,
|
closestLat,
|
||||||
closestLon);
|
closestLon);
|
||||||
|
|
||||||
|
|
@ -279,6 +277,7 @@ GetDistanceAreaPoint(const std::vector<common::Coordinate>& area,
|
||||||
point.longitude_,
|
point.longitude_,
|
||||||
closestLat,
|
closestLat,
|
||||||
closestLon);
|
closestLon);
|
||||||
|
|
||||||
}
|
}
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue