use double precision

This commit is contained in:
Patrick Brosi 2018-08-10 15:21:27 +02:00
parent 967963e180
commit 486a8136fd
24 changed files with 186 additions and 177 deletions

View file

@ -18,13 +18,13 @@ EdgeList* EdgePL::getEdges() { return &_edges; }
const EdgeList& EdgePL::getEdges() const { return _edges; }
// _____________________________________________________________________________
const FPoint& EdgePL::frontHop() const {
const DPoint& EdgePL::frontHop() const {
if (!_edges.size()) return *_end->pl().getGeom();
return _edges.back()->pl().frontHop();
}
// _____________________________________________________________________________
const FPoint& EdgePL::backHop() const {
const DPoint& EdgePL::backHop() const {
if (!_edges.size()) return *_start->pl().getGeom();
return _edges.front()->pl().backHop();
}
@ -36,7 +36,7 @@ const Node* EdgePL::backNode() const { return _end; }
const Node* EdgePL::frontNode() const { return _start; }
// _____________________________________________________________________________
const util::geo::FLine* EdgePL::getGeom() const {
const util::geo::DLine* EdgePL::getGeom() const {
if (!_edges.size()) return 0;
if (!_geom.size()) {
const trgraph::Node* l = _start;

View file

@ -9,16 +9,19 @@
#include <string>
#include "pfaedle/router/Misc.h"
#include "util/geo/GeoGraph.h"
#include "util/geo/Geo.h"
using util::geograph::GeoEdgePL;
using util::geo::DPoint;
using util::geo::DLine;
namespace pfaedle {
namespace router {
class EdgePL : public GeoEdgePL<float> {
class EdgePL : public GeoEdgePL<double> {
public:
EdgePL() : _cost(), _start(0), _end(0), _startE(0), _endE(0) {}
const util::geo::FLine* getGeom() const;
const util::geo::DLine* getGeom() const;
util::json::Dict getAttrs() const;
router::EdgeList* getEdges();
const router::EdgeList& getEdges() const;
@ -28,8 +31,8 @@ class EdgePL : public GeoEdgePL<float> {
void setEndEdge(const trgraph::Edge* s);
const router::EdgeCost& getCost() const;
void setCost(const router::EdgeCost& c);
const FPoint& frontHop() const;
const FPoint& backHop() const;
const DPoint& frontHop() const;
const DPoint& backHop() const;
const trgraph::Node* frontNode() const;
const trgraph::Node* backNode() const;
@ -41,7 +44,7 @@ class EdgePL : public GeoEdgePL<float> {
const trgraph::Node* _end;
const trgraph::Edge* _startE;
const trgraph::Edge* _endE;
mutable util::geo::FLine _geom;
mutable DLine _geom;
};
} // namespace router
} // namespace pfaedle

View file

@ -165,8 +165,8 @@ inline bool operator>(const EdgeCost& a, const EdgeCost& b) {
return a.getValue() > b.getValue();
}
inline int angSmaller(const FPoint& f, const FPoint& m, const FPoint& t,
template<typename F>
inline bool angSmaller(const Point<F>& f, const Point<F>& m, const Point<F>& t,
double ang) {
if (util::geo::innerProd(m, f, t) < ang) return 1;
return 0;

View file

@ -11,16 +11,17 @@
#include "util/geo/GeoGraph.h"
using util::geograph::GeoNodePL;
using util::geo::DPoint;
namespace pfaedle {
namespace router {
class NodePL : public GeoNodePL<float> {
class NodePL : public GeoNodePL<double> {
public:
NodePL() : _n(0) {}
NodePL(const pfaedle::trgraph::Node* n) : _n(n) {} // NOLINT
const util::geo::FPoint* getGeom() const {
const DPoint* getGeom() const {
return !_n ? 0 : _n->pl().getGeom();
}
util::json::Dict getAttrs() const {

View file

@ -132,7 +132,7 @@ NDistHeur::NDistHeur(const RoutingOpts& rOpts,
x /= c;
y /= c;
_center = FPoint(x, y);
_center = DPoint(x, y);
for (auto to : tos) {
double cur = webMercMeterDist(*to->pl().getGeom(), _center);
@ -154,7 +154,7 @@ DistHeur::DistHeur(uint8_t minLvl, const RoutingOpts& rOpts,
x /= c;
y /= c;
_center = FPoint(x, y);
_center = DPoint(x, y);
for (auto to : tos) {
double cur = webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *

View file

@ -100,7 +100,7 @@ struct DistHeur
const RoutingOpts& _rOpts;
uint8_t _lvl;
FPoint _center;
DPoint _center;
double _maxCentD;
EdgeCost operator()(const trgraph::Edge* a,
const std::set<trgraph::Edge*>& b) const;
@ -111,7 +111,7 @@ struct NDistHeur
NDistHeur(const RoutingOpts& rOpts, const std::set<trgraph::Node*>& tos);
const RoutingOpts& _rOpts;
FPoint _center;
DPoint _center;
double _maxCentD;
EdgeCost operator()(const trgraph::Node* a,
const std::set<trgraph::Node*>& b) const;

View file

@ -23,11 +23,11 @@
#include "util/graph/EDijkstra.h"
#include "util/log/Log.h"
using util::geo::FPoint;
using util::geo::DPoint;
using util::geo::extendBox;
using util::geo::Box;
using util::geo::DBox;
using util::geo::minbox;
using util::geo::FLine;
using util::geo::DLine;
using util::geo::webMercMeterDist;
using util::geo::webMercToLatLng;
using util::geo::latLngToWebMerc;
@ -91,11 +91,11 @@ const NodeCandGroup& ShapeBuilder::getNodeCands(const Stop* s) const {
}
// _____________________________________________________________________________
FLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
DLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
const router::RoutingAttrs& rAttrs) {
const router::EdgeListHops& res = route(ncr, rAttrs);
FLine l;
DLine l;
for (const auto& hop : res) {
const trgraph::Node* last = hop.start;
if (hop.edges.size() == 0) {
@ -118,7 +118,7 @@ FLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
}
// _____________________________________________________________________________
FLine ShapeBuilder::shapeL(Trip* trip) {
DLine ShapeBuilder::shapeL(Trip* trip) {
return shapeL(getNCR(trip), getRAttrs(trip));
}
@ -321,11 +321,11 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
double dist = -1;
double lastDist = -1;
hopDists->push_back(0);
FPoint last(0, 0);
DPoint last(0, 0);
for (const auto& hop : shp.hops) {
const trgraph::Node* l = hop.start;
if (hop.edges.size() == 0) {
FPoint ll = webMercToLatLng<float>(hop.start->pl().getGeom()->getX(),
DPoint ll = webMercToLatLng<double>(hop.start->pl().getGeom()->getX(),
hop.start->pl().getGeom()->getY());
if (dist > -0.5)
@ -345,7 +345,7 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
last = *hop.end->pl().getGeom();
if (dist - lastDist > 0.01) {
ll = webMercToLatLng<float>(hop.end->pl().getGeom()->getX(),
ll = webMercToLatLng<double>(hop.end->pl().getGeom()->getX(),
hop.end->pl().getGeom()->getY());
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
seq++;
@ -356,14 +356,14 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
const auto* e = *i;
if ((e->getFrom() == l) ^ e->pl().isRev()) {
for (size_t i = 0; i < e->pl().getGeom()->size(); i++) {
const FPoint& cur = (*e->pl().getGeom())[i];
const DPoint& cur = (*e->pl().getGeom())[i];
if (dist > -0.5)
dist += webMercMeterDist(last, cur);
else
dist = 0;
last = cur;
if (dist - lastDist > 0.01) {
FPoint ll = webMercToLatLng<float>(cur.getX(), cur.getY());
DPoint ll = webMercToLatLng<double>(cur.getX(), cur.getY());
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
seq++;
lastDist = dist;
@ -371,14 +371,14 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
}
} else {
for (int64_t i = e->pl().getGeom()->size() - 1; i >= 0; i--) {
const FPoint& cur = (*e->pl().getGeom())[i];
const DPoint& cur = (*e->pl().getGeom())[i];
if (dist > -0.5)
dist += webMercMeterDist(last, cur);
else
dist = 0;
last = cur;
if (dist - lastDist > 0.01) {
FPoint ll = webMercToLatLng<float>(cur.getX(), cur.getY());
DPoint ll = webMercToLatLng<double>(cur.getX(), cur.getY());
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
seq++;
lastDist = dist;
@ -452,10 +452,10 @@ BBoxIdx ShapeBuilder::getPaddedGtfsBox(const Feed* feed, double pad,
if (tid.empty() && t.second->getShape() && !dropShapes) continue;
if (t.second->getStopTimes().size() < 2) continue;
if (mots.count(t.second->getRoute()->getType())) {
Box<float> cur = minbox<float>();
DBox cur = minbox<double>();
for (const auto& st : t.second->getStopTimes()) {
cur = extendBox(
Point<float>(st.getStop()->getLng(), st.getStop()->getLat()), cur);
DPoint(st.getStop()->getLng(), st.getStop()->getLat()), cur);
}
box.add(cur);
}
@ -511,8 +511,8 @@ double ShapeBuilder::avgHopDist(Trip* trip) const {
prev = st.getStop();
continue;
}
auto a = util::geo::latLngToWebMerc<float>(prev->getLat(), prev->getLng());
auto b = util::geo::latLngToWebMerc<float>(st.getStop()->getLat(),
auto a = util::geo::latLngToWebMerc<double>(prev->getLat(), prev->getLng());
auto b = util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
st.getStop()->getLng());
sum += util::geo::webMercMeterDist(a, b);
@ -573,8 +573,8 @@ bool ShapeBuilder::routingEqual(const Stop* a, const Stop* b) {
auto trackb = _motCfg.osmBuildOpts.trackNormzer(b->getPlatformCode());
if (tracka != trackb) return false;
FPoint ap = util::geo::latLngToWebMerc<float>(a->getLat(), a->getLng());
FPoint bp = util::geo::latLngToWebMerc<float>(b->getLat(), b->getLng());
DPoint ap = util::geo::latLngToWebMerc<double>(a->getLat(), a->getLng());
DPoint bp = util::geo::latLngToWebMerc<double>(b->getLat(), b->getLng());
double d = util::geo::webMercMeterDist(ap, bp);

View file

@ -28,6 +28,8 @@ using ad::cppgtfs::gtfs::Stop;
using ad::cppgtfs::gtfs::Trip;
using ad::cppgtfs::gtfs::Feed;
using util::geo::DLine;
struct Shape {
router::EdgeListHops hops;
double avgHopDist;
@ -55,9 +57,9 @@ class ShapeBuilder {
const NodeCandGroup& getNodeCands(const Stop* s) const;
util::geo::FLine shapeL(const router::NodeCandRoute& ncr,
DLine shapeL(const router::NodeCandRoute& ncr,
const router::RoutingAttrs& rAttrs);
util::geo::FLine shapeL(Trip* trip);
DLine shapeL(Trip* trip);
pfaedle::router::Shape shape(Trip* trip) const;
pfaedle::router::Shape shape(Trip* trip);