make geometry precision configurable for build
This commit is contained in:
parent
486a8136fd
commit
8446db5c4b
25 changed files with 222 additions and 208 deletions
|
|
@ -2,6 +2,8 @@
|
|||
// Chair of Algorithms and Data Structures.
|
||||
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
|
||||
|
||||
#include "pfaedle/Def.h"
|
||||
#include "util/geo/Geo.h"
|
||||
#include "pfaedle/router/EdgePL.h"
|
||||
#include "pfaedle/router/Router.h"
|
||||
#include "util/String.h"
|
||||
|
|
@ -18,13 +20,13 @@ EdgeList* EdgePL::getEdges() { return &_edges; }
|
|||
const EdgeList& EdgePL::getEdges() const { return _edges; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const DPoint& EdgePL::frontHop() const {
|
||||
const POINT& EdgePL::frontHop() const {
|
||||
if (!_edges.size()) return *_end->pl().getGeom();
|
||||
return _edges.back()->pl().frontHop();
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const DPoint& EdgePL::backHop() const {
|
||||
const POINT& EdgePL::backHop() const {
|
||||
if (!_edges.size()) return *_start->pl().getGeom();
|
||||
return _edges.front()->pl().backHop();
|
||||
}
|
||||
|
|
@ -36,7 +38,7 @@ const Node* EdgePL::backNode() const { return _end; }
|
|||
const Node* EdgePL::frontNode() const { return _start; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const util::geo::DLine* EdgePL::getGeom() const {
|
||||
const LINE* EdgePL::getGeom() const {
|
||||
if (!_edges.size()) return 0;
|
||||
if (!_geom.size()) {
|
||||
const trgraph::Node* l = _start;
|
||||
|
|
@ -74,7 +76,6 @@ const EdgeCost& EdgePL::getCost() const { return _cost; }
|
|||
// _____________________________________________________________________________
|
||||
void EdgePL::setCost(const router::EdgeCost& c) { _cost = c; }
|
||||
|
||||
|
||||
// _____________________________________________________________________________
|
||||
util::json::Dict EdgePL::getAttrs() const {
|
||||
util::json::Dict obj;
|
||||
|
|
|
|||
|
|
@ -7,21 +7,20 @@
|
|||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "pfaedle/Def.h"
|
||||
#include "pfaedle/router/Misc.h"
|
||||
#include "util/geo/GeoGraph.h"
|
||||
#include "util/geo/Geo.h"
|
||||
#include "util/geo/GeoGraph.h"
|
||||
|
||||
using util::geograph::GeoEdgePL;
|
||||
using util::geo::DPoint;
|
||||
using util::geo::DLine;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace router {
|
||||
|
||||
class EdgePL : public GeoEdgePL<double> {
|
||||
class EdgePL : public GeoEdgePL<PFAEDLE_PRECISION> {
|
||||
public:
|
||||
EdgePL() : _cost(), _start(0), _end(0), _startE(0), _endE(0) {}
|
||||
const util::geo::DLine* getGeom() const;
|
||||
const LINE* getGeom() const;
|
||||
util::json::Dict getAttrs() const;
|
||||
router::EdgeList* getEdges();
|
||||
const router::EdgeList& getEdges() const;
|
||||
|
|
@ -31,8 +30,8 @@ class EdgePL : public GeoEdgePL<double> {
|
|||
void setEndEdge(const trgraph::Edge* s);
|
||||
const router::EdgeCost& getCost() const;
|
||||
void setCost(const router::EdgeCost& c);
|
||||
const DPoint& frontHop() const;
|
||||
const DPoint& backHop() const;
|
||||
const POINT& frontHop() const;
|
||||
const POINT& backHop() const;
|
||||
const trgraph::Node* frontNode() const;
|
||||
const trgraph::Node* backNode() const;
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ class EdgePL : public GeoEdgePL<double> {
|
|||
const trgraph::Node* _end;
|
||||
const trgraph::Edge* _startE;
|
||||
const trgraph::Edge* _endE;
|
||||
mutable DLine _geom;
|
||||
mutable LINE _geom;
|
||||
};
|
||||
} // namespace router
|
||||
} // namespace pfaedle
|
||||
|
|
|
|||
|
|
@ -9,19 +9,21 @@
|
|||
#include <string>
|
||||
#include "pfaedle/trgraph/Graph.h"
|
||||
#include "util/geo/GeoGraph.h"
|
||||
#include "util/geo/Geo.h"
|
||||
#include "pfaedle/Def.h"
|
||||
|
||||
using util::geograph::GeoNodePL;
|
||||
using util::geo::DPoint;
|
||||
|
||||
|
||||
namespace pfaedle {
|
||||
namespace router {
|
||||
|
||||
class NodePL : public GeoNodePL<double> {
|
||||
class NodePL : public GeoNodePL<PFAEDLE_PRECISION> {
|
||||
public:
|
||||
NodePL() : _n(0) {}
|
||||
NodePL(const pfaedle::trgraph::Node* n) : _n(n) {} // NOLINT
|
||||
|
||||
const DPoint* getGeom() const {
|
||||
const POINT* getGeom() const {
|
||||
return !_n ? 0 : _n->pl().getGeom();
|
||||
}
|
||||
util::json::Dict getAttrs() const {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ NDistHeur::NDistHeur(const RoutingOpts& rOpts,
|
|||
|
||||
x /= c;
|
||||
y /= c;
|
||||
_center = DPoint(x, y);
|
||||
_center = POINT(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 = DPoint(x, y);
|
||||
_center = POINT(x, y);
|
||||
|
||||
for (auto to : tos) {
|
||||
double cur = webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include "pfaedle/trgraph/Graph.h"
|
||||
#include "util/graph/Dijkstra.h"
|
||||
#include "util/graph/EDijkstra.h"
|
||||
#include "util/geo/Geo.h"
|
||||
#include "pfaedle/Def.h"
|
||||
|
||||
using util::graph::EDijkstra;
|
||||
using util::graph::Dijkstra;
|
||||
|
|
@ -100,7 +102,7 @@ struct DistHeur
|
|||
|
||||
const RoutingOpts& _rOpts;
|
||||
uint8_t _lvl;
|
||||
DPoint _center;
|
||||
POINT _center;
|
||||
double _maxCentD;
|
||||
EdgeCost operator()(const trgraph::Edge* a,
|
||||
const std::set<trgraph::Edge*>& b) const;
|
||||
|
|
@ -111,7 +113,7 @@ struct NDistHeur
|
|||
NDistHeur(const RoutingOpts& rOpts, const std::set<trgraph::Node*>& tos);
|
||||
|
||||
const RoutingOpts& _rOpts;
|
||||
DPoint _center;
|
||||
POINT _center;
|
||||
double _maxCentD;
|
||||
EdgeCost operator()(const trgraph::Node* a,
|
||||
const std::set<trgraph::Node*>& b) const;
|
||||
|
|
|
|||
|
|
@ -14,20 +14,22 @@
|
|||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||
#include "pfaedle/Def.h"
|
||||
#include "pfaedle/eval/Collector.h"
|
||||
#include "pfaedle/osm/OsmBuilder.h"
|
||||
#include "pfaedle/router/ShapeBuilder.h"
|
||||
#include "pfaedle/trgraph/StatGroup.h"
|
||||
#include "util/geo/Geo.h"
|
||||
#include "util/geo/output/GeoGraphJsonOutput.h"
|
||||
#include "util/geo/output/GeoJsonOutput.h"
|
||||
#include "util/graph/EDijkstra.h"
|
||||
#include "util/log/Log.h"
|
||||
|
||||
using util::geo::DPoint;
|
||||
using util::geo::extendBox;
|
||||
using util::geo::DBox;
|
||||
using util::geo::DPoint;
|
||||
using util::geo::minbox;
|
||||
using util::geo::DLine;
|
||||
|
||||
using util::geo::webMercMeterDist;
|
||||
using util::geo::webMercToLatLng;
|
||||
using util::geo::latLngToWebMerc;
|
||||
|
|
@ -91,11 +93,11 @@ const NodeCandGroup& ShapeBuilder::getNodeCands(const Stop* s) const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
DLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
|
||||
const router::RoutingAttrs& rAttrs) {
|
||||
LINE ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
|
||||
const router::RoutingAttrs& rAttrs) {
|
||||
const router::EdgeListHops& res = route(ncr, rAttrs);
|
||||
|
||||
DLine l;
|
||||
LINE l;
|
||||
for (const auto& hop : res) {
|
||||
const trgraph::Node* last = hop.start;
|
||||
if (hop.edges.size() == 0) {
|
||||
|
|
@ -118,7 +120,7 @@ DLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
DLine ShapeBuilder::shapeL(Trip* trip) {
|
||||
LINE ShapeBuilder::shapeL(Trip* trip) {
|
||||
return shapeL(getNCR(trip), getRAttrs(trip));
|
||||
}
|
||||
|
||||
|
|
@ -218,8 +220,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
|||
{
|
||||
LOG(INFO) << "@ " << j << " / " << clusters.size() << " ("
|
||||
<< (static_cast<int>((j * 1.0) / clusters.size() * 100))
|
||||
<< "%, "
|
||||
<< (EDijkstra::ITERS - oiters) << " iters, "
|
||||
<< "%, " << (EDijkstra::ITERS - oiters) << " iters, "
|
||||
/**
|
||||
TODO: this is actually misleading. We are counting the
|
||||
Dijkstra iterations, but the measuring them against
|
||||
|
|
@ -275,16 +276,17 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
|||
LOG(INFO) << "Matched " << totNumTrips << " trips in " << clusters.size()
|
||||
<< " clusters.";
|
||||
LOG(DEBUG) << "Took " << (EDijkstra::ITERS - totiters)
|
||||
<< " iterations in total.";
|
||||
<< " iterations in total.";
|
||||
LOG(DEBUG) << "Took " << TOOK(t2, TIME()) << " ms in total.";
|
||||
LOG(DEBUG) << "Total avg. tput "
|
||||
<< (static_cast<double>(EDijkstra::ITERS - totiters)) /
|
||||
TOOK(t2, TIME())
|
||||
<< " iters/sec";
|
||||
<< (static_cast<double>(EDijkstra::ITERS - totiters)) /
|
||||
TOOK(t2, TIME())
|
||||
<< " iters/sec";
|
||||
LOG(DEBUG) << "Total avg. trip tput "
|
||||
<< (clusters.size() / (TOOK(t2, TIME()) / 1000)) << " trips/sec";
|
||||
<< (clusters.size() / (TOOK(t2, TIME()) / 1000)) << " trips/sec";
|
||||
LOG(DEBUG) << "Avg hop distance was "
|
||||
<< (totAvgDist / static_cast<double>(clusters.size())) << " meters";
|
||||
<< (totAvgDist / static_cast<double>(clusters.size()))
|
||||
<< " meters";
|
||||
|
||||
if (_cfg.buildTransitGraph) {
|
||||
LOG(INFO) << "Building transit network graph...";
|
||||
|
|
@ -321,12 +323,12 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
|||
double dist = -1;
|
||||
double lastDist = -1;
|
||||
hopDists->push_back(0);
|
||||
DPoint last(0, 0);
|
||||
POINT last(0, 0);
|
||||
for (const auto& hop : shp.hops) {
|
||||
const trgraph::Node* l = hop.start;
|
||||
if (hop.edges.size() == 0) {
|
||||
DPoint ll = webMercToLatLng<double>(hop.start->pl().getGeom()->getX(),
|
||||
hop.start->pl().getGeom()->getY());
|
||||
POINT ll = webMercToLatLng<PFAEDLE_PRECISION>(
|
||||
hop.start->pl().getGeom()->getX(), hop.start->pl().getGeom()->getY());
|
||||
|
||||
if (dist > -0.5)
|
||||
dist += webMercMeterDist(last, *hop.start->pl().getGeom());
|
||||
|
|
@ -345,8 +347,8 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
|||
last = *hop.end->pl().getGeom();
|
||||
|
||||
if (dist - lastDist > 0.01) {
|
||||
ll = webMercToLatLng<double>(hop.end->pl().getGeom()->getX(),
|
||||
hop.end->pl().getGeom()->getY());
|
||||
ll = webMercToLatLng<PFAEDLE_PRECISION>(
|
||||
hop.end->pl().getGeom()->getX(), hop.end->pl().getGeom()->getY());
|
||||
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||
seq++;
|
||||
lastDist = dist;
|
||||
|
|
@ -356,14 +358,15 @@ 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 DPoint& cur = (*e->pl().getGeom())[i];
|
||||
const POINT& cur = (*e->pl().getGeom())[i];
|
||||
if (dist > -0.5)
|
||||
dist += webMercMeterDist(last, cur);
|
||||
else
|
||||
dist = 0;
|
||||
last = cur;
|
||||
if (dist - lastDist > 0.01) {
|
||||
DPoint ll = webMercToLatLng<double>(cur.getX(), cur.getY());
|
||||
POINT ll =
|
||||
webMercToLatLng<PFAEDLE_PRECISION>(cur.getX(), cur.getY());
|
||||
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||
seq++;
|
||||
lastDist = dist;
|
||||
|
|
@ -371,14 +374,15 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
|||
}
|
||||
} else {
|
||||
for (int64_t i = e->pl().getGeom()->size() - 1; i >= 0; i--) {
|
||||
const DPoint& cur = (*e->pl().getGeom())[i];
|
||||
const POINT& cur = (*e->pl().getGeom())[i];
|
||||
if (dist > -0.5)
|
||||
dist += webMercMeterDist(last, cur);
|
||||
else
|
||||
dist = 0;
|
||||
last = cur;
|
||||
if (dist - lastDist > 0.01) {
|
||||
DPoint ll = webMercToLatLng<double>(cur.getX(), cur.getY());
|
||||
POINT ll =
|
||||
webMercToLatLng<PFAEDLE_PRECISION>(cur.getX(), cur.getY());
|
||||
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||
seq++;
|
||||
lastDist = dist;
|
||||
|
|
@ -452,10 +456,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())) {
|
||||
DBox cur = minbox<double>();
|
||||
DBox cur;
|
||||
for (const auto& st : t.second->getStopTimes()) {
|
||||
cur = extendBox(
|
||||
DPoint(st.getStop()->getLng(), st.getStop()->getLat()), cur);
|
||||
cur = extendBox(DPoint(st.getStop()->getLng(), st.getStop()->getLat()),
|
||||
cur);
|
||||
}
|
||||
box.add(cur);
|
||||
}
|
||||
|
|
@ -471,7 +475,6 @@ void ShapeBuilder::buildGraph() {
|
|||
osm::BBoxIdx box =
|
||||
getPaddedGtfsBox(_feed, 2500, _mots, _cfg.shapeTripId, _cfg.dropShapes);
|
||||
|
||||
|
||||
osmBuilder.read(_cfg.osmPath, _motCfg.osmBuildOpts, &_g, box, _cfg.gridSize,
|
||||
getFeedStops(), &_restr);
|
||||
|
||||
|
|
@ -511,9 +514,10 @@ double ShapeBuilder::avgHopDist(Trip* trip) const {
|
|||
prev = st.getStop();
|
||||
continue;
|
||||
}
|
||||
auto a = util::geo::latLngToWebMerc<double>(prev->getLat(), prev->getLng());
|
||||
auto b = util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng());
|
||||
auto a = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(prev->getLat(),
|
||||
prev->getLng());
|
||||
auto b = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(
|
||||
st.getStop()->getLat(), st.getStop()->getLng());
|
||||
sum += util::geo::webMercMeterDist(a, b);
|
||||
|
||||
prev = st.getStop();
|
||||
|
|
@ -573,8 +577,10 @@ bool ShapeBuilder::routingEqual(const Stop* a, const Stop* b) {
|
|||
auto trackb = _motCfg.osmBuildOpts.trackNormzer(b->getPlatformCode());
|
||||
if (tracka != trackb) return false;
|
||||
|
||||
DPoint ap = util::geo::latLngToWebMerc<double>(a->getLat(), a->getLng());
|
||||
DPoint bp = util::geo::latLngToWebMerc<double>(b->getLat(), b->getLng());
|
||||
POINT ap =
|
||||
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(a->getLat(), a->getLng());
|
||||
POINT bp =
|
||||
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(b->getLat(), b->getLng());
|
||||
|
||||
double d = util::geo::webMercMeterDist(ap, bp);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||
#include "pfaedle/Def.h"
|
||||
#include "pfaedle/config/MotConfig.h"
|
||||
#include "pfaedle/config/PfaedleConfig.h"
|
||||
#include "pfaedle/eval/Collector.h"
|
||||
|
|
@ -20,6 +21,7 @@
|
|||
#include "pfaedle/router/Misc.h"
|
||||
#include "pfaedle/router/Router.h"
|
||||
#include "pfaedle/trgraph/Graph.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
||||
namespace pfaedle {
|
||||
namespace router {
|
||||
|
|
@ -28,8 +30,6 @@ 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;
|
||||
|
|
@ -57,9 +57,9 @@ class ShapeBuilder {
|
|||
|
||||
const NodeCandGroup& getNodeCands(const Stop* s) const;
|
||||
|
||||
DLine shapeL(const router::NodeCandRoute& ncr,
|
||||
const router::RoutingAttrs& rAttrs);
|
||||
DLine shapeL(Trip* trip);
|
||||
LINE shapeL(const router::NodeCandRoute& ncr,
|
||||
const router::RoutingAttrs& rAttrs);
|
||||
LINE shapeL(Trip* trip);
|
||||
|
||||
pfaedle::router::Shape shape(Trip* trip) const;
|
||||
pfaedle::router::Shape shape(Trip* trip);
|
||||
|
|
@ -67,8 +67,7 @@ class ShapeBuilder {
|
|||
const trgraph::Graph* getGraph() const;
|
||||
|
||||
static osm::BBoxIdx getPaddedGtfsBox(const Feed* feed, double pad,
|
||||
const MOTs& mots,
|
||||
const std::string& tid,
|
||||
const MOTs& mots, const std::string& tid,
|
||||
bool dropShapes);
|
||||
|
||||
private:
|
||||
|
|
@ -103,7 +102,7 @@ class ShapeBuilder {
|
|||
std::string getFreeShapeId(Trip* t);
|
||||
|
||||
ad::cppgtfs::gtfs::Shape* getGtfsShape(const Shape& shp, Trip* t,
|
||||
std::vector<double>* hopDists);
|
||||
std::vector<double>* hopDists);
|
||||
|
||||
void setShape(Trip* t, ad::cppgtfs::gtfs::Shape* s,
|
||||
const std::vector<double>& dists);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue