make geometry precision configurable for build
This commit is contained in:
parent
486a8136fd
commit
8446db5c4b
25 changed files with 222 additions and 208 deletions
|
@ -50,6 +50,8 @@ else ()
|
||||||
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPFAEDLE_PRECISION=${PFAEDLE_PRECISION}")
|
||||||
|
|
||||||
# http://brianmilco.blogspot.de/2012/11/cmake-automatically-use-git-tags-as.html
|
# http://brianmilco.blogspot.de/2012/11/cmake-automatically-use-git-tags-as.html
|
||||||
include(GetGitRevisionDescription)
|
include(GetGitRevisionDescription)
|
||||||
git_get_tag(VERSION_GIT)
|
git_get_tag(VERSION_GIT)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/_config.h"
|
#include "pfaedle/_config.h"
|
||||||
#include "pfaedle/config/ConfigReader.h"
|
#include "pfaedle/config/ConfigReader.h"
|
||||||
#include "util/String.h"
|
#include "util/String.h"
|
||||||
|
@ -27,7 +28,8 @@ static const char* AUTHORS = "Patrick Brosi <brosi@informatik.uni-freiburg.de>";
|
||||||
void ConfigReader::help(const char* bin) {
|
void ConfigReader::help(const char* bin) {
|
||||||
std::cout
|
std::cout
|
||||||
<< std::setfill(' ') << std::left << "pfaedle GTFS map matcher\n"
|
<< std::setfill(' ') << std::left << "pfaedle GTFS map matcher\n"
|
||||||
<< VERSION_FULL << " (built " << __DATE__ << " " << __TIME__ << ")\n\n"
|
<< VERSION_FULL << " (built " << __DATE__ << " " << __TIME__
|
||||||
|
<< " with geometry precision <" << PFAEDLE_PRECISION_STR << ">)\n\n"
|
||||||
<< "(C) " << YEAR << " " << COPY << "\n"
|
<< "(C) " << YEAR << " " << COPY << "\n"
|
||||||
<< "Authors: " << AUTHORS << "\n\n"
|
<< "Authors: " << AUTHORS << "\n\n"
|
||||||
<< "Usage: " << bin << " -x <OSM FILE> -c <CFG FILE> <GTFS FEED>\n\n"
|
<< "Usage: " << bin << " -x <OSM FILE> -c <CFG FILE> <GTFS FEED>\n\n"
|
||||||
|
@ -170,7 +172,8 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
std::cout << "pfaedle " << VERSION_FULL << " (built " << __DATE__ << " "
|
std::cout << "pfaedle " << VERSION_FULL << " (built " << __DATE__ << " "
|
||||||
<< __TIME__ << ")\n"
|
<< __TIME__ << " with geometry precision <"
|
||||||
|
<< PFAEDLE_PRECISION_STR << ">)\n"
|
||||||
<< "(C) " << YEAR << " " << COPY << "\n"
|
<< "(C) " << YEAR << " " << COPY << "\n"
|
||||||
<< "Authors: " << AUTHORS << "\nGNU General Public "
|
<< "Authors: " << AUTHORS << "\nGNU General Public "
|
||||||
"License v3.0\n";
|
"License v3.0\n";
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/eval/Collector.h"
|
#include "pfaedle/eval/Collector.h"
|
||||||
#include "pfaedle/eval/Result.h"
|
#include "pfaedle/eval/Result.h"
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
@ -15,9 +16,8 @@
|
||||||
#include "util/geo/output/GeoJsonOutput.h"
|
#include "util/geo/output/GeoJsonOutput.h"
|
||||||
#include "util/log/Log.h"
|
#include "util/log/Log.h"
|
||||||
|
|
||||||
using util::geo::DLine;
|
|
||||||
using util::geo::PolyLine;
|
using util::geo::PolyLine;
|
||||||
using util::geo::DPoint;
|
|
||||||
using ad::cppgtfs::gtfs::Trip;
|
using ad::cppgtfs::gtfs::Trip;
|
||||||
using ad::cppgtfs::gtfs::Shape;
|
using ad::cppgtfs::gtfs::Shape;
|
||||||
using pfaedle::eval::Collector;
|
using pfaedle::eval::Collector;
|
||||||
|
@ -46,12 +46,12 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
||||||
double unmatchedSegmentsLength;
|
double unmatchedSegmentsLength;
|
||||||
|
|
||||||
std::vector<double> oldDists;
|
std::vector<double> oldDists;
|
||||||
DLine oldL = getWebMercLine(
|
LINE oldL = getWebMercLine(
|
||||||
oldS, t->getStopTimes().begin()->getShapeDistanceTravelled(),
|
oldS, t->getStopTimes().begin()->getShapeDistanceTravelled(),
|
||||||
(--t->getStopTimes().end())->getShapeDistanceTravelled(), &oldDists);
|
(--t->getStopTimes().end())->getShapeDistanceTravelled(), &oldDists);
|
||||||
|
|
||||||
std::vector<double> newDists;
|
std::vector<double> newDists;
|
||||||
DLine newL = getWebMercLine(newS, -1, -1, &newDists);
|
LINE newL = getWebMercLine(newS, -1, -1, &newDists);
|
||||||
|
|
||||||
std::ofstream fstr(_evalOutPath + "/trip-" + t->getId() + ".json");
|
std::ofstream fstr(_evalOutPath + "/trip-" + t->getId() + ".json");
|
||||||
GeoJsonOutput gjout(fstr);
|
GeoJsonOutput gjout(fstr);
|
||||||
|
@ -61,8 +61,8 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
||||||
|
|
||||||
// cut both result at the beginning and end to clear evaluation from
|
// cut both result at the beginning and end to clear evaluation from
|
||||||
// loops at the end
|
// loops at the end
|
||||||
PolyLine<double> oldStart = oldSegs[0];
|
POLYLINE oldStart = oldSegs[0];
|
||||||
PolyLine<double> newStart = newSegs[0];
|
POLYLINE newStart = newSegs[0];
|
||||||
auto oldStartNew =
|
auto oldStartNew =
|
||||||
oldStart.getSegment(oldStart.projectOn(newSegs[0][0]).totalPos, 1);
|
oldStart.getSegment(oldStart.projectOn(newSegs[0][0]).totalPos, 1);
|
||||||
auto newStartNew =
|
auto newStartNew =
|
||||||
|
@ -77,8 +77,8 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
||||||
newSegs[0] = newStartNew.getLine();
|
newSegs[0] = newStartNew.getLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyLine<double> oldEnd = oldSegs[oldSegs.size() - 1];
|
POLYLINE oldEnd = oldSegs[oldSegs.size() - 1];
|
||||||
PolyLine<double> newEnd = newSegs[oldSegs.size() - 1];
|
POLYLINE newEnd = newSegs[oldSegs.size() - 1];
|
||||||
auto oldEndNew =
|
auto oldEndNew =
|
||||||
oldEnd.getSegment(0, oldEnd.projectOn(newSegs.back().back()).totalPos);
|
oldEnd.getSegment(0, oldEnd.projectOn(newSegs.back().back()).totalPos);
|
||||||
auto newEndNew =
|
auto newEndNew =
|
||||||
|
@ -103,8 +103,8 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
||||||
}
|
}
|
||||||
|
|
||||||
// new lines build from cleaned-up shapes
|
// new lines build from cleaned-up shapes
|
||||||
DLine oldLCut;
|
LINE oldLCut;
|
||||||
DLine newLCut;
|
LINE newLCut;
|
||||||
|
|
||||||
for (auto oldL : oldSegs) {
|
for (auto oldL : oldSegs) {
|
||||||
gjout.print(oldL, util::json::Dict{{"ver", "old"}});
|
gjout.print(oldL, util::json::Dict{{"ver", "old"}});
|
||||||
|
@ -166,31 +166,30 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
||||||
<< " A_L/L = " << unmatchedSegmentsLength << "/" << totL << " = "
|
<< " A_L/L = " << unmatchedSegmentsLength << "/" << totL << " = "
|
||||||
<< unmatchedSegmentsLength / totL << " d_f = " << fd;
|
<< unmatchedSegmentsLength / totL << " d_f = " << fd;
|
||||||
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
std::vector<DLine> Collector::segmentize(
|
std::vector<LINE> Collector::segmentize(
|
||||||
const Trip* t, const DLine& shape, const std::vector<double>& dists,
|
const Trip* t, const LINE& shape, const std::vector<double>& dists,
|
||||||
const std::vector<double>* newTripDists) {
|
const std::vector<double>* newTripDists) {
|
||||||
std::vector<DLine> ret;
|
std::vector<LINE> ret;
|
||||||
|
|
||||||
if (t->getStopTimes().size() < 2) return ret;
|
if (t->getStopTimes().size() < 2) return ret;
|
||||||
|
|
||||||
util::geo::PolyLine<double> pl(shape);
|
POLYLINE pl(shape);
|
||||||
std::vector<std::pair<DPoint, double> > cuts;
|
std::vector<std::pair<POINT, double> > cuts;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (auto st : t->getStopTimes()) {
|
for (auto st : t->getStopTimes()) {
|
||||||
if (newTripDists) {
|
if (newTripDists) {
|
||||||
cuts.push_back(std::pair<DPoint, double>(
|
cuts.push_back(std::pair<POINT, double>(
|
||||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(st.getStop()->getLat(),
|
||||||
st.getStop()->getLng()),
|
st.getStop()->getLng()),
|
||||||
(*newTripDists)[i]));
|
(*newTripDists)[i]));
|
||||||
} else {
|
} else {
|
||||||
cuts.push_back(std::pair<DPoint, double>(
|
cuts.push_back(std::pair<POINT, double>(
|
||||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(st.getStop()->getLat(),
|
||||||
st.getStop()->getLng()),
|
st.getStop()->getLng()),
|
||||||
st.getShapeDistanceTravelled()));
|
st.getShapeDistanceTravelled()));
|
||||||
}
|
}
|
||||||
|
@ -200,8 +199,7 @@ std::vector<DLine> Collector::segmentize(
|
||||||
// get first half of geometry, and search for start point there!
|
// get first half of geometry, and search for start point there!
|
||||||
size_t before = std::upper_bound(dists.begin(), dists.end(), cuts[1].second) -
|
size_t before = std::upper_bound(dists.begin(), dists.end(), cuts[1].second) -
|
||||||
dists.begin();
|
dists.begin();
|
||||||
util::geo::PolyLine<double> l(
|
POLYLINE l(LINE(shape.begin(), shape.begin() + before + 1));
|
||||||
DLine(shape.begin(), shape.begin() + before + 1));
|
|
||||||
auto lastLp = l.projectOn(cuts.front().first);
|
auto lastLp = l.projectOn(cuts.front().first);
|
||||||
|
|
||||||
for (size_t i = 1; i < cuts.size(); i++) {
|
for (size_t i = 1; i < cuts.size(); i++) {
|
||||||
|
@ -212,8 +210,7 @@ std::vector<DLine> Collector::segmentize(
|
||||||
dists.begin();
|
dists.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
util::geo::PolyLine<double> beforePl(
|
POLYLINE beforePl(LINE(shape.begin(), shape.begin() + before));
|
||||||
DLine(shape.begin(), shape.begin() + before));
|
|
||||||
|
|
||||||
auto curLp = beforePl.projectOnAfter(cuts[i].first, lastLp.lastIndex);
|
auto curLp = beforePl.projectOnAfter(cuts[i].first, lastLp.lastIndex);
|
||||||
|
|
||||||
|
@ -226,14 +223,14 @@ std::vector<DLine> Collector::segmentize(
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
DLine Collector::getWebMercLine(const Shape* s, double from, double t) {
|
LINE Collector::getWebMercLine(const Shape* s, double from, double t) {
|
||||||
return getWebMercLine(s, from, t, 0);
|
return getWebMercLine(s, from, t, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
DLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
LINE Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||||
std::vector<double>* dists) {
|
std::vector<double>* dists) {
|
||||||
DLine ret;
|
LINE ret;
|
||||||
|
|
||||||
auto i = s->getPoints().begin();
|
auto i = s->getPoints().begin();
|
||||||
|
|
||||||
|
@ -243,7 +240,7 @@ DLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||||
if ((from < 0 || (p.travelDist - from) > -0.01)) {
|
if ((from < 0 || (p.travelDist - from) > -0.01)) {
|
||||||
if (to >= 0 && (p.travelDist - to) > 0.01) break;
|
if (to >= 0 && (p.travelDist - to) > 0.01) break;
|
||||||
|
|
||||||
DPoint mercP = util::geo::latLngToWebMerc<double>(p.lat, p.lng);
|
POINT mercP = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(p.lat, p.lng);
|
||||||
|
|
||||||
ret.push_back(mercP);
|
ret.push_back(mercP);
|
||||||
if (dists) dists->push_back(p.travelDist);
|
if (dists) dists->push_back(p.travelDist);
|
||||||
|
@ -393,8 +390,8 @@ void Collector::printStats(std::ostream* os) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
std::pair<size_t, double> Collector::getDa(const std::vector<DLine>& a,
|
std::pair<size_t, double> Collector::getDa(const std::vector<LINE>& a,
|
||||||
const std::vector<DLine>& b) {
|
const std::vector<LINE>& b) {
|
||||||
assert(a.size() == b.size());
|
assert(a.size() == b.size());
|
||||||
std::pair<size_t, double> ret{0, 0};
|
std::pair<size_t, double> ret{0, 0};
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/eval/Result.h"
|
#include "pfaedle/eval/Result.h"
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
|
||||||
using ad::cppgtfs::gtfs::Trip;
|
using ad::cppgtfs::gtfs::Trip;
|
||||||
using ad::cppgtfs::gtfs::Shape;
|
using ad::cppgtfs::gtfs::Shape;
|
||||||
using util::geo::DLine;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace eval {
|
namespace eval {
|
||||||
|
@ -57,8 +57,8 @@ class Collector {
|
||||||
// Return the averaged average frechet distance
|
// Return the averaged average frechet distance
|
||||||
double getAvgDist() const;
|
double getAvgDist() const;
|
||||||
|
|
||||||
static DLine getWebMercLine(const Shape* s, double from, double to);
|
static LINE getWebMercLine(const Shape* s, double from, double to);
|
||||||
static DLine getWebMercLine(const Shape* s, double from, double to,
|
static LINE getWebMercLine(const Shape* s, double from, double to,
|
||||||
std::vector<double>* dists);
|
std::vector<double>* dists);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -78,10 +78,10 @@ class Collector {
|
||||||
|
|
||||||
std::vector<double> _dfBins;
|
std::vector<double> _dfBins;
|
||||||
|
|
||||||
static std::pair<size_t, double> getDa(const std::vector<DLine>& a,
|
static std::pair<size_t, double> getDa(const std::vector<LINE>& a,
|
||||||
const std::vector<DLine>& b);
|
const std::vector<LINE>& b);
|
||||||
|
|
||||||
static std::vector<DLine> segmentize(const Trip* t, const DLine& shape,
|
static std::vector<LINE> segmentize(const Trip* t, const LINE& shape,
|
||||||
const std::vector<double>& dists,
|
const std::vector<double>& dists,
|
||||||
const std::vector<double>* newTripDists);
|
const std::vector<double>* newTripDists);
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,17 @@ namespace netgraph {
|
||||||
* A payload class for edges on a network graph - that is a graph
|
* A payload class for edges on a network graph - that is a graph
|
||||||
* that exactly represents a physical public transit network
|
* that exactly represents a physical public transit network
|
||||||
*/
|
*/
|
||||||
class EdgePL : public GeoEdgePL<double> {
|
class EdgePL : public GeoEdgePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
EdgePL() {}
|
EdgePL() {}
|
||||||
EdgePL(const util::geo::DLine& l, const std::set<const Trip*>& trips)
|
EdgePL(const LINE& l, const std::set<const Trip*>& trips)
|
||||||
: _l(l), _trips(trips) {
|
: _l(l), _trips(trips) {
|
||||||
for (const auto t : _trips) {
|
for (const auto t : _trips) {
|
||||||
_routeShortNames.insert(t->getRoute()->getShortName());
|
_routeShortNames.insert(t->getRoute()->getShortName());
|
||||||
_tripShortNames.insert(t->getShortname());
|
_tripShortNames.insert(t->getShortname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const util::geo::DLine* getGeom() const { return &_l; }
|
const LINE* getGeom() const { return &_l; }
|
||||||
util::json::Dict getAttrs() const {
|
util::json::Dict getAttrs() const {
|
||||||
util::json::Dict obj;
|
util::json::Dict obj;
|
||||||
obj["num_trips"] = static_cast<int>(_trips.size());
|
obj["num_trips"] = static_cast<int>(_trips.size());
|
||||||
|
@ -44,7 +44,7 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
util::geo::DLine _l;
|
LINE _l;
|
||||||
std::set<const Trip*> _trips;
|
std::set<const Trip*> _trips;
|
||||||
std::set<std::string> _routeShortNames;
|
std::set<std::string> _routeShortNames;
|
||||||
std::set<std::string> _tripShortNames;
|
std::set<std::string> _tripShortNames;
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
using util::geo::Point;
|
using util::geo::Point;
|
||||||
using util::geo::Line;
|
using util::geo::Line;
|
||||||
using util::geo::DPoint;
|
|
||||||
using util::geo::DLine;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace netgraph {
|
namespace netgraph {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "util/geo/GeoGraph.h"
|
#include "util/geo/GeoGraph.h"
|
||||||
|
|
||||||
using util::geograph::GeoNodePL;
|
using util::geograph::GeoNodePL;
|
||||||
using util::geo::DPoint;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace netgraph {
|
namespace netgraph {
|
||||||
|
@ -20,18 +20,18 @@ namespace netgraph {
|
||||||
* A payload class for edges on a network graph - that is a graph
|
* A payload class for edges on a network graph - that is a graph
|
||||||
* that exactly represents a physical public transit network
|
* that exactly represents a physical public transit network
|
||||||
*/
|
*/
|
||||||
class NodePL : public GeoNodePL<double> {
|
class NodePL : public GeoNodePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
NodePL() {}
|
NodePL() {}
|
||||||
NodePL(const util::geo::DPoint& geom) { _geom = geom; } // NOLINT
|
NodePL(const POINT& geom) { _geom = geom; } // NOLINT
|
||||||
|
|
||||||
const DPoint* getGeom() const { return &_geom; }
|
const POINT* getGeom() const { return &_geom; }
|
||||||
util::json::Dict getAttrs() const {
|
util::json::Dict getAttrs() const {
|
||||||
return util::json::Dict();
|
return util::json::Dict();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DPoint _geom;
|
POINT _geom;
|
||||||
};
|
};
|
||||||
} // namespace netgraph
|
} // namespace netgraph
|
||||||
} // namespace pfaedle
|
} // namespace pfaedle
|
||||||
|
|
|
@ -29,12 +29,12 @@ bool BBoxIdx::contains(const Point<double>& p) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
util::geo::Box<double> BBoxIdx::getFullWebMercBox() const {
|
BOX BBoxIdx::getFullWebMercBox() const {
|
||||||
return util::geo::DBox(
|
return BOX(
|
||||||
util::geo::latLngToWebMerc<double>(_root.box.getLowerLeft().getY(),
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(
|
||||||
_root.box.getLowerLeft().getX()),
|
_root.box.getLowerLeft().getY(), _root.box.getLowerLeft().getX()),
|
||||||
util::geo::latLngToWebMerc<double>(_root.box.getUpperRight().getY(),
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(
|
||||||
_root.box.getUpperRight().getX()));
|
_root.box.getUpperRight().getY(), _root.box.getUpperRight().getX()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define PFAEDLE_OSM_BBOXIDX_H_
|
#define PFAEDLE_OSM_BBOXIDX_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
|
@ -35,7 +36,7 @@ class BBoxIdx {
|
||||||
bool contains(const Point<double>& box) const;
|
bool contains(const Point<double>& box) const;
|
||||||
|
|
||||||
// Return the full total bounding box of this index
|
// Return the full total bounding box of this index
|
||||||
util::geo::Box<double> getFullWebMercBox() const;
|
BOX getFullWebMercBox() const;
|
||||||
|
|
||||||
// Return the size of this index
|
// Return the size of this index
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/osm/BBoxIdx.h"
|
#include "pfaedle/osm/BBoxIdx.h"
|
||||||
#include "pfaedle/osm/Osm.h"
|
#include "pfaedle/osm/Osm.h"
|
||||||
#include "pfaedle/osm/OsmBuilder.h"
|
#include "pfaedle/osm/OsmBuilder.h"
|
||||||
|
@ -136,7 +137,7 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
|
|
||||||
for (double d : opts.maxSnapDistances) {
|
for (double d : opts.maxSnapDistances) {
|
||||||
for (auto s : orphanStations) {
|
for (auto s : orphanStations) {
|
||||||
DPoint geom = *s->pl().getGeom();
|
POINT geom = *s->pl().getGeom();
|
||||||
NodePL pl = s->pl();
|
NodePL pl = s->pl();
|
||||||
pl.getSI()->setIsFromOsm(false);
|
pl.getSI()->setIsFromOsm(false);
|
||||||
const auto& r = snapStation(g, &pl, &eg, &sng, opts, res, false, d);
|
const auto& r = snapStation(g, &pl, &eg, &sng, opts, res, false, d);
|
||||||
|
@ -374,7 +375,8 @@ void OsmBuilder::readWriteWays(xml::File* i, util::xml::XmlWriter* o,
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
NodePL OsmBuilder::plFromGtfs(const Stop* s, const OsmReadOpts& ops) const {
|
NodePL OsmBuilder::plFromGtfs(const Stop* s, const OsmReadOpts& ops) const {
|
||||||
NodePL ret(util::geo::latLngToWebMerc<double>(s->getLat(), s->getLng()),
|
NodePL ret(
|
||||||
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(s->getLat(), s->getLng()),
|
||||||
StatInfo(ops.statNormzer(s->getName()),
|
StatInfo(ops.statNormzer(s->getName()),
|
||||||
ops.trackNormzer(s->getPlatformCode()), false));
|
ops.trackNormzer(s->getPlatformCode()), false));
|
||||||
|
|
||||||
|
@ -705,7 +707,7 @@ void OsmBuilder::readNodes(xml::File* xml, Graph* g, const RelLst& rels,
|
||||||
keepAttrs, fl))
|
keepAttrs, fl))
|
||||||
.id) {
|
.id) {
|
||||||
Node* n = 0;
|
Node* n = 0;
|
||||||
auto pos = util::geo::latLngToWebMerc<double>(nd.lat, nd.lng);
|
auto pos = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(nd.lat, nd.lng);
|
||||||
if (nodes->count(nd.id)) {
|
if (nodes->count(nd.id)) {
|
||||||
n = (*nodes)[nd.id];
|
n = (*nodes)[nd.id];
|
||||||
n->pl().setGeom(pos);
|
n->pl().setGeom(pos);
|
||||||
|
@ -930,7 +932,7 @@ std::string OsmBuilder::getAttr(const DeepAttrRule& s, osmid id,
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
Nullable<StatInfo> OsmBuilder::getStatInfo(Node* node, osmid nid,
|
Nullable<StatInfo> OsmBuilder::getStatInfo(Node* node, osmid nid,
|
||||||
const DPoint& pos, const AttrMap& m,
|
const POINT& pos, const AttrMap& m,
|
||||||
StAttrGroups* groups,
|
StAttrGroups* groups,
|
||||||
const RelMap& nodeRels,
|
const RelMap& nodeRels,
|
||||||
const RelLst& rels,
|
const RelLst& rels,
|
||||||
|
@ -994,7 +996,7 @@ double OsmBuilder::dist(const Node* a, const Node* b) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
double OsmBuilder::webMercDistFactor(const util::geo::DPoint& a) const {
|
double OsmBuilder::webMercDistFactor(const POINT& a) const {
|
||||||
// euclidean distance on web mercator is in meters on equator,
|
// euclidean distance on web mercator is in meters on equator,
|
||||||
// and proportional to cos(lat) in both y directions
|
// and proportional to cos(lat) in both y directions
|
||||||
|
|
||||||
|
@ -1035,7 +1037,7 @@ void OsmBuilder::fixGaps(Graph* g, NodeGrid* ng) const {
|
||||||
otherN = (*nb->getAdjListOut().begin())->getOtherNd(nb);
|
otherN = (*nb->getAdjListOut().begin())->getOtherNd(nb);
|
||||||
else
|
else
|
||||||
otherN = (*nb->getAdjListIn().begin())->getOtherNd(nb);
|
otherN = (*nb->getAdjListIn().begin())->getOtherNd(nb);
|
||||||
DLine l;
|
LINE l;
|
||||||
l.push_back(*otherN->pl().getGeom());
|
l.push_back(*otherN->pl().getGeom());
|
||||||
l.push_back(*n->pl().getGeom());
|
l.push_back(*n->pl().getGeom());
|
||||||
|
|
||||||
|
@ -1057,7 +1059,7 @@ void OsmBuilder::fixGaps(Graph* g, NodeGrid* ng) const {
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
EdgeGrid OsmBuilder::buildEdgeIdx(Graph* g, size_t size,
|
EdgeGrid OsmBuilder::buildEdgeIdx(Graph* g, size_t size,
|
||||||
const Box<double>& webMercBox) const {
|
const BOX& webMercBox) const {
|
||||||
EdgeGrid ret(size, size, webMercBox, false);
|
EdgeGrid ret(size, size, webMercBox, false);
|
||||||
for (auto* n : *g->getNds()) {
|
for (auto* n : *g->getNds()) {
|
||||||
for (auto* e : n->getAdjListOut()) {
|
for (auto* e : n->getAdjListOut()) {
|
||||||
|
@ -1070,7 +1072,7 @@ EdgeGrid OsmBuilder::buildEdgeIdx(Graph* g, size_t size,
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
NodeGrid OsmBuilder::buildNodeIdx(Graph* g, size_t size,
|
NodeGrid OsmBuilder::buildNodeIdx(Graph* g, size_t size,
|
||||||
const Box<double>& webMercBox,
|
const BOX& webMercBox,
|
||||||
bool which) const {
|
bool which) const {
|
||||||
NodeGrid ret(size, size, webMercBox, false);
|
NodeGrid ret(size, size, webMercBox, false);
|
||||||
for (auto* n : *g->getNds()) {
|
for (auto* n : *g->getNds()) {
|
||||||
|
@ -1083,9 +1085,8 @@ NodeGrid OsmBuilder::buildNodeIdx(Graph* g, size_t size,
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si, const POINT& p,
|
||||||
const util::geo::DPoint& p, double maxD,
|
double maxD, int maxFullTurns, double minAngle,
|
||||||
int maxFullTurns, double minAngle,
|
|
||||||
const SearchFunc& sfunc) const {
|
const SearchFunc& sfunc) const {
|
||||||
// shortcuts
|
// shortcuts
|
||||||
double dFrom = webMercMeterDist(*e->getFrom()->pl().getGeom(), p);
|
double dFrom = webMercMeterDist(*e->getFrom()->pl().getGeom(), p);
|
||||||
|
@ -1125,10 +1126,10 @@ Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
||||||
if (cur.fromEdge &&
|
if (cur.fromEdge &&
|
||||||
cur.node->getInDeg() + cur.node->getOutDeg() >
|
cur.node->getInDeg() + cur.node->getOutDeg() >
|
||||||
2) { // only intersection angles
|
2) { // only intersection angles
|
||||||
const DPoint& toP = *cand->pl().getGeom();
|
const POINT& toP = *cand->pl().getGeom();
|
||||||
const DPoint& fromP =
|
const POINT& fromP =
|
||||||
*cur.fromEdge->getOtherNd(cur.node)->pl().getGeom();
|
*cur.fromEdge->getOtherNd(cur.node)->pl().getGeom();
|
||||||
const DPoint& nodeP = *cur.node->pl().getGeom();
|
const POINT& nodeP = *cur.node->pl().getGeom();
|
||||||
|
|
||||||
if (util::geo::innerProd(nodeP, fromP, toP) < minAngle) fullTurn = 1;
|
if (util::geo::innerProd(nodeP, fromP, toP) < minAngle) fullTurn = 1;
|
||||||
}
|
}
|
||||||
|
@ -1149,25 +1150,25 @@ Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
bool OsmBuilder::isBlocked(const Edge* e, const StatInfo* si,
|
bool OsmBuilder::isBlocked(const Edge* e, const StatInfo* si, const POINT& p,
|
||||||
const util::geo::DPoint& p, double maxD,
|
double maxD, int maxFullTurns,
|
||||||
int maxFullTurns, double minAngle) const {
|
double minAngle) const {
|
||||||
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, BlockSearch());
|
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, BlockSearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
Node* OsmBuilder::eqStatReach(const Edge* e, const StatInfo* si,
|
Node* OsmBuilder::eqStatReach(const Edge* e, const StatInfo* si, const POINT& p,
|
||||||
const util::geo::DPoint& p, double maxD,
|
double maxD, int maxFullTurns,
|
||||||
int maxFullTurns, double minAngle) const {
|
double minAngle) const {
|
||||||
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, EqSearch());
|
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, EqSearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
void OsmBuilder::getEdgCands(const DPoint& geom, EdgeCandPQ* ret, EdgeGrid* eg,
|
void OsmBuilder::getEdgCands(const POINT& geom, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||||
double d) const {
|
double d) const {
|
||||||
double distor = webMercDistFactor(geom);
|
double distor = webMercDistFactor(geom);
|
||||||
std::set<Edge*> neighs;
|
std::set<Edge*> neighs;
|
||||||
Box<double> box = util::geo::pad(util::geo::getBoundingBox(geom), d / distor);
|
BOX box = util::geo::pad(util::geo::getBoundingBox(geom), d / distor);
|
||||||
eg->get(box, &neighs);
|
eg->get(box, &neighs);
|
||||||
|
|
||||||
for (auto* e : neighs) {
|
for (auto* e : neighs) {
|
||||||
|
@ -1186,7 +1187,7 @@ std::set<Node*> OsmBuilder::getMatchingNds(const NodePL& s, NodeGrid* ng,
|
||||||
std::set<Node*> ret;
|
std::set<Node*> ret;
|
||||||
double distor = webMercDistFactor(*s.getGeom());
|
double distor = webMercDistFactor(*s.getGeom());
|
||||||
std::set<Node*> neighs;
|
std::set<Node*> neighs;
|
||||||
Box<double> box =
|
BOX box =
|
||||||
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
||||||
ng->get(box, &neighs);
|
ng->get(box, &neighs);
|
||||||
|
|
||||||
|
@ -1204,7 +1205,7 @@ std::set<Node*> OsmBuilder::getMatchingNds(const NodePL& s, NodeGrid* ng,
|
||||||
Node* OsmBuilder::getMatchingNd(const NodePL& s, NodeGrid* ng, double d) const {
|
Node* OsmBuilder::getMatchingNd(const NodePL& s, NodeGrid* ng, double d) const {
|
||||||
double distor = webMercDistFactor(*s.getGeom());
|
double distor = webMercDistFactor(*s.getGeom());
|
||||||
std::set<Node*> neighs;
|
std::set<Node*> neighs;
|
||||||
Box<double> box =
|
BOX box =
|
||||||
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
||||||
ng->get(box, &neighs);
|
ng->get(box, &neighs);
|
||||||
|
|
||||||
|
@ -1282,7 +1283,7 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
||||||
|
|
||||||
auto ne = g->addEdg(e->getFrom(), n, e->pl());
|
auto ne = g->addEdg(e->getFrom(), n, e->pl());
|
||||||
ne->pl().setLength(webMercDist(n, e->getFrom()));
|
ne->pl().setLength(webMercDist(n, e->getFrom()));
|
||||||
DLine l;
|
LINE l;
|
||||||
l.push_back(*e->getFrom()->pl().getGeom());
|
l.push_back(*e->getFrom()->pl().getGeom());
|
||||||
l.push_back(*n->pl().getGeom());
|
l.push_back(*n->pl().getGeom());
|
||||||
*ne->pl().getGeom() = l;
|
*ne->pl().getGeom() = l;
|
||||||
|
@ -1290,7 +1291,7 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
||||||
|
|
||||||
auto nf = g->addEdg(n, e->getTo(), e->pl());
|
auto nf = g->addEdg(n, e->getTo(), e->pl());
|
||||||
nf->pl().setLength(webMercDist(n, e->getTo()));
|
nf->pl().setLength(webMercDist(n, e->getTo()));
|
||||||
DLine ll;
|
LINE ll;
|
||||||
ll.push_back(*n->pl().getGeom());
|
ll.push_back(*n->pl().getGeom());
|
||||||
ll.push_back(*e->getTo()->pl().getGeom());
|
ll.push_back(*e->getTo()->pl().getGeom());
|
||||||
*nf->pl().getGeom() = ll;
|
*nf->pl().getGeom() = ll;
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
#ifndef PFAEDLE_OSM_OSMBUILDER_H_
|
#ifndef PFAEDLE_OSM_OSMBUILDER_H_
|
||||||
#define PFAEDLE_OSM_OSMBUILDER_H_
|
#define PFAEDLE_OSM_OSMBUILDER_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/osm/BBoxIdx.h"
|
#include "pfaedle/osm/BBoxIdx.h"
|
||||||
#include "pfaedle/osm/OsmFilter.h"
|
#include "pfaedle/osm/OsmFilter.h"
|
||||||
#include "pfaedle/osm/OsmIdSet.h"
|
#include "pfaedle/osm/OsmIdSet.h"
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
#include "pfaedle/trgraph/Normalizer.h"
|
#include "pfaedle/trgraph/Normalizer.h"
|
||||||
#include "pfaedle/trgraph/StatInfo.h"
|
#include "pfaedle/trgraph/StatInfo.h"
|
||||||
#include "util/Nullable.h"
|
#include "util/Nullable.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
#include "util/xml/XmlWriter.h"
|
#include "util/xml/XmlWriter.h"
|
||||||
#include "xml/File.h"
|
#include "xml/File.h"
|
||||||
|
|
||||||
|
@ -89,7 +91,6 @@ class OsmBuilder {
|
||||||
const BBoxIdx& box, size_t gridSize, router::FeedStops* fs,
|
const BBoxIdx& box, size_t gridSize, router::FeedStops* fs,
|
||||||
Restrictor* res);
|
Restrictor* res);
|
||||||
|
|
||||||
|
|
||||||
// Based on the list of options, read an OSM file from in and output an
|
// Based on the list of options, read an OSM file from in and output an
|
||||||
// OSM file to out which contains exactly the entities that are needed
|
// OSM file to out which contains exactly the entities that are needed
|
||||||
// from the file at in
|
// from the file at in
|
||||||
|
@ -162,7 +163,7 @@ class OsmBuilder {
|
||||||
OsmRel nextRel(xml::File* xml, const OsmFilter& filter,
|
OsmRel nextRel(xml::File* xml, const OsmFilter& filter,
|
||||||
const AttrKeySet& keepAttrs) const;
|
const AttrKeySet& keepAttrs) const;
|
||||||
|
|
||||||
Nullable<StatInfo> getStatInfo(Node* node, osmid nid, const DPoint& pos,
|
Nullable<StatInfo> getStatInfo(Node* node, osmid nid, const POINT& pos,
|
||||||
const AttrMap& m, StAttrGroups* groups,
|
const AttrMap& m, StAttrGroups* groups,
|
||||||
const RelMap& nodeRels, const RelLst& rels,
|
const RelMap& nodeRels, const RelLst& rels,
|
||||||
const OsmReadOpts& ops) const;
|
const OsmReadOpts& ops) const;
|
||||||
|
@ -172,14 +173,12 @@ class OsmBuilder {
|
||||||
void deleteOrphEdgs(Graph* g) const;
|
void deleteOrphEdgs(Graph* g) const;
|
||||||
double dist(const Node* a, const Node* b) const;
|
double dist(const Node* a, const Node* b) const;
|
||||||
double webMercDist(const Node* a, const Node* b) const;
|
double webMercDist(const Node* a, const Node* b) const;
|
||||||
double webMercDistFactor(const DPoint& a) const;
|
double webMercDistFactor(const POINT& a) const;
|
||||||
|
|
||||||
NodeGrid buildNodeIdx(Graph* g, size_t size,
|
NodeGrid buildNodeIdx(Graph* g, size_t size, const BOX& webMercBox,
|
||||||
const util::geo::Box<double>& webMercBox,
|
|
||||||
bool which) const;
|
bool which) const;
|
||||||
|
|
||||||
EdgeGrid buildEdgeIdx(Graph* g, size_t size,
|
EdgeGrid buildEdgeIdx(Graph* g, size_t size, const BOX& webMercBox) const;
|
||||||
const util::geo::Box<double>& webMercBox) const;
|
|
||||||
|
|
||||||
void fixGaps(Graph* g, NodeGrid* ng) const;
|
void fixGaps(Graph* g, NodeGrid* ng) const;
|
||||||
void collapseEdges(Graph* g) const;
|
void collapseEdges(Graph* g) const;
|
||||||
|
@ -190,7 +189,7 @@ class OsmBuilder {
|
||||||
uint32_t writeComps(Graph* g) const;
|
uint32_t writeComps(Graph* g) const;
|
||||||
bool edgesSim(const Edge* a, const Edge* b) const;
|
bool edgesSim(const Edge* a, const Edge* b) const;
|
||||||
const EdgePL& mergeEdgePL(Edge* a, Edge* b) const;
|
const EdgePL& mergeEdgePL(Edge* a, Edge* b) const;
|
||||||
void getEdgCands(const DPoint& s, EdgeCandPQ* ret, EdgeGrid* eg,
|
void getEdgCands(const POINT& s, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||||
double d) const;
|
double d) const;
|
||||||
|
|
||||||
std::set<Node*> getMatchingNds(const NodePL& s, NodeGrid* ng, double d) const;
|
std::set<Node*> getMatchingNds(const NodePL& s, NodeGrid* ng, double d) const;
|
||||||
|
@ -204,15 +203,15 @@ class OsmBuilder {
|
||||||
// Checks if from the edge e, a station similar to si can be reach with less
|
// Checks if from the edge e, a station similar to si can be reach with less
|
||||||
// than maxD distance and less or equal to "maxFullTurns" full turns. If
|
// than maxD distance and less or equal to "maxFullTurns" full turns. If
|
||||||
// such a station exists, it is returned. If not, 0 is returned.
|
// such a station exists, it is returned. If not, 0 is returned.
|
||||||
Node* eqStatReach(const Edge* e, const StatInfo* si, const DPoint& p,
|
Node* eqStatReach(const Edge* e, const StatInfo* si, const POINT& p,
|
||||||
double maxD, int maxFullTurns, double maxAng) const;
|
double maxD, int maxFullTurns, double maxAng) const;
|
||||||
|
|
||||||
Node* depthSearch(const Edge* e, const StatInfo* si,
|
Node* depthSearch(const Edge* e, const StatInfo* si, const POINT& p,
|
||||||
const DPoint& p, double maxD, int maxFullTurns,
|
double maxD, int maxFullTurns, double minAngle,
|
||||||
double minAngle, const SearchFunc& sfunc) const;
|
const SearchFunc& sfunc) const;
|
||||||
|
|
||||||
bool isBlocked(const Edge* e, const StatInfo* si, const DPoint& p,
|
bool isBlocked(const Edge* e, const StatInfo* si, const POINT& p, double maxD,
|
||||||
double maxD, int maxFullTurns, double minAngle) const;
|
int maxFullTurns, double minAngle) const;
|
||||||
|
|
||||||
StatGroup* groupStats(const NodeSet& s) const;
|
StatGroup* groupStats(const NodeSet& s) const;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Chair of Algorithms and Data Structures.
|
// Chair of Algorithms and Data Structures.
|
||||||
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
|
// 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/EdgePL.h"
|
||||||
#include "pfaedle/router/Router.h"
|
#include "pfaedle/router/Router.h"
|
||||||
#include "util/String.h"
|
#include "util/String.h"
|
||||||
|
@ -18,13 +20,13 @@ EdgeList* EdgePL::getEdges() { return &_edges; }
|
||||||
const EdgeList& EdgePL::getEdges() const { 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();
|
if (!_edges.size()) return *_end->pl().getGeom();
|
||||||
return _edges.back()->pl().frontHop();
|
return _edges.back()->pl().frontHop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const DPoint& EdgePL::backHop() const {
|
const POINT& EdgePL::backHop() const {
|
||||||
if (!_edges.size()) return *_start->pl().getGeom();
|
if (!_edges.size()) return *_start->pl().getGeom();
|
||||||
return _edges.front()->pl().backHop();
|
return _edges.front()->pl().backHop();
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,7 @@ const Node* EdgePL::backNode() const { return _end; }
|
||||||
const Node* EdgePL::frontNode() const { return _start; }
|
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 (!_edges.size()) return 0;
|
||||||
if (!_geom.size()) {
|
if (!_geom.size()) {
|
||||||
const trgraph::Node* l = _start;
|
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; }
|
void EdgePL::setCost(const router::EdgeCost& c) { _cost = c; }
|
||||||
|
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
util::json::Dict EdgePL::getAttrs() const {
|
util::json::Dict EdgePL::getAttrs() const {
|
||||||
util::json::Dict obj;
|
util::json::Dict obj;
|
||||||
|
|
|
@ -7,21 +7,20 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/router/Misc.h"
|
#include "pfaedle/router/Misc.h"
|
||||||
#include "util/geo/GeoGraph.h"
|
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
#include "util/geo/GeoGraph.h"
|
||||||
|
|
||||||
using util::geograph::GeoEdgePL;
|
using util::geograph::GeoEdgePL;
|
||||||
using util::geo::DPoint;
|
|
||||||
using util::geo::DLine;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace router {
|
namespace router {
|
||||||
|
|
||||||
class EdgePL : public GeoEdgePL<double> {
|
class EdgePL : public GeoEdgePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
EdgePL() : _cost(), _start(0), _end(0), _startE(0), _endE(0) {}
|
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;
|
util::json::Dict getAttrs() const;
|
||||||
router::EdgeList* getEdges();
|
router::EdgeList* getEdges();
|
||||||
const router::EdgeList& getEdges() const;
|
const router::EdgeList& getEdges() const;
|
||||||
|
@ -31,8 +30,8 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
void setEndEdge(const trgraph::Edge* s);
|
void setEndEdge(const trgraph::Edge* s);
|
||||||
const router::EdgeCost& getCost() const;
|
const router::EdgeCost& getCost() const;
|
||||||
void setCost(const router::EdgeCost& c);
|
void setCost(const router::EdgeCost& c);
|
||||||
const DPoint& frontHop() const;
|
const POINT& frontHop() const;
|
||||||
const DPoint& backHop() const;
|
const POINT& backHop() const;
|
||||||
const trgraph::Node* frontNode() const;
|
const trgraph::Node* frontNode() const;
|
||||||
const trgraph::Node* backNode() const;
|
const trgraph::Node* backNode() const;
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
const trgraph::Node* _end;
|
const trgraph::Node* _end;
|
||||||
const trgraph::Edge* _startE;
|
const trgraph::Edge* _startE;
|
||||||
const trgraph::Edge* _endE;
|
const trgraph::Edge* _endE;
|
||||||
mutable DLine _geom;
|
mutable LINE _geom;
|
||||||
};
|
};
|
||||||
} // namespace router
|
} // namespace router
|
||||||
} // namespace pfaedle
|
} // namespace pfaedle
|
||||||
|
|
|
@ -9,19 +9,21 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "pfaedle/trgraph/Graph.h"
|
#include "pfaedle/trgraph/Graph.h"
|
||||||
#include "util/geo/GeoGraph.h"
|
#include "util/geo/GeoGraph.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
|
|
||||||
using util::geograph::GeoNodePL;
|
using util::geograph::GeoNodePL;
|
||||||
using util::geo::DPoint;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace router {
|
namespace router {
|
||||||
|
|
||||||
class NodePL : public GeoNodePL<double> {
|
class NodePL : public GeoNodePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
NodePL() : _n(0) {}
|
NodePL() : _n(0) {}
|
||||||
NodePL(const pfaedle::trgraph::Node* n) : _n(n) {} // NOLINT
|
NodePL(const pfaedle::trgraph::Node* n) : _n(n) {} // NOLINT
|
||||||
|
|
||||||
const DPoint* getGeom() const {
|
const POINT* getGeom() const {
|
||||||
return !_n ? 0 : _n->pl().getGeom();
|
return !_n ? 0 : _n->pl().getGeom();
|
||||||
}
|
}
|
||||||
util::json::Dict getAttrs() const {
|
util::json::Dict getAttrs() const {
|
||||||
|
|
|
@ -132,7 +132,7 @@ NDistHeur::NDistHeur(const RoutingOpts& rOpts,
|
||||||
|
|
||||||
x /= c;
|
x /= c;
|
||||||
y /= c;
|
y /= c;
|
||||||
_center = DPoint(x, y);
|
_center = POINT(x, y);
|
||||||
|
|
||||||
for (auto to : tos) {
|
for (auto to : tos) {
|
||||||
double cur = webMercMeterDist(*to->pl().getGeom(), _center);
|
double cur = webMercMeterDist(*to->pl().getGeom(), _center);
|
||||||
|
@ -154,7 +154,7 @@ DistHeur::DistHeur(uint8_t minLvl, const RoutingOpts& rOpts,
|
||||||
|
|
||||||
x /= c;
|
x /= c;
|
||||||
y /= c;
|
y /= c;
|
||||||
_center = DPoint(x, y);
|
_center = POINT(x, y);
|
||||||
|
|
||||||
for (auto to : tos) {
|
for (auto to : tos) {
|
||||||
double cur = webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *
|
double cur = webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "pfaedle/trgraph/Graph.h"
|
#include "pfaedle/trgraph/Graph.h"
|
||||||
#include "util/graph/Dijkstra.h"
|
#include "util/graph/Dijkstra.h"
|
||||||
#include "util/graph/EDijkstra.h"
|
#include "util/graph/EDijkstra.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
|
|
||||||
using util::graph::EDijkstra;
|
using util::graph::EDijkstra;
|
||||||
using util::graph::Dijkstra;
|
using util::graph::Dijkstra;
|
||||||
|
@ -100,7 +102,7 @@ struct DistHeur
|
||||||
|
|
||||||
const RoutingOpts& _rOpts;
|
const RoutingOpts& _rOpts;
|
||||||
uint8_t _lvl;
|
uint8_t _lvl;
|
||||||
DPoint _center;
|
POINT _center;
|
||||||
double _maxCentD;
|
double _maxCentD;
|
||||||
EdgeCost operator()(const trgraph::Edge* a,
|
EdgeCost operator()(const trgraph::Edge* a,
|
||||||
const std::set<trgraph::Edge*>& b) const;
|
const std::set<trgraph::Edge*>& b) const;
|
||||||
|
@ -111,7 +113,7 @@ struct NDistHeur
|
||||||
NDistHeur(const RoutingOpts& rOpts, const std::set<trgraph::Node*>& tos);
|
NDistHeur(const RoutingOpts& rOpts, const std::set<trgraph::Node*>& tos);
|
||||||
|
|
||||||
const RoutingOpts& _rOpts;
|
const RoutingOpts& _rOpts;
|
||||||
DPoint _center;
|
POINT _center;
|
||||||
double _maxCentD;
|
double _maxCentD;
|
||||||
EdgeCost operator()(const trgraph::Node* a,
|
EdgeCost operator()(const trgraph::Node* a,
|
||||||
const std::set<trgraph::Node*>& b) const;
|
const std::set<trgraph::Node*>& b) const;
|
||||||
|
|
|
@ -14,20 +14,22 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/eval/Collector.h"
|
#include "pfaedle/eval/Collector.h"
|
||||||
#include "pfaedle/osm/OsmBuilder.h"
|
#include "pfaedle/osm/OsmBuilder.h"
|
||||||
#include "pfaedle/router/ShapeBuilder.h"
|
#include "pfaedle/router/ShapeBuilder.h"
|
||||||
#include "pfaedle/trgraph/StatGroup.h"
|
#include "pfaedle/trgraph/StatGroup.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
#include "util/geo/output/GeoGraphJsonOutput.h"
|
#include "util/geo/output/GeoGraphJsonOutput.h"
|
||||||
#include "util/geo/output/GeoJsonOutput.h"
|
#include "util/geo/output/GeoJsonOutput.h"
|
||||||
#include "util/graph/EDijkstra.h"
|
#include "util/graph/EDijkstra.h"
|
||||||
#include "util/log/Log.h"
|
#include "util/log/Log.h"
|
||||||
|
|
||||||
using util::geo::DPoint;
|
|
||||||
using util::geo::extendBox;
|
using util::geo::extendBox;
|
||||||
using util::geo::DBox;
|
using util::geo::DBox;
|
||||||
|
using util::geo::DPoint;
|
||||||
using util::geo::minbox;
|
using util::geo::minbox;
|
||||||
using util::geo::DLine;
|
|
||||||
using util::geo::webMercMeterDist;
|
using util::geo::webMercMeterDist;
|
||||||
using util::geo::webMercToLatLng;
|
using util::geo::webMercToLatLng;
|
||||||
using util::geo::latLngToWebMerc;
|
using util::geo::latLngToWebMerc;
|
||||||
|
@ -91,11 +93,11 @@ const NodeCandGroup& ShapeBuilder::getNodeCands(const Stop* s) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
DLine ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
|
LINE ShapeBuilder::shapeL(const router::NodeCandRoute& ncr,
|
||||||
const router::RoutingAttrs& rAttrs) {
|
const router::RoutingAttrs& rAttrs) {
|
||||||
const router::EdgeListHops& res = route(ncr, rAttrs);
|
const router::EdgeListHops& res = route(ncr, rAttrs);
|
||||||
|
|
||||||
DLine l;
|
LINE l;
|
||||||
for (const auto& hop : res) {
|
for (const auto& hop : res) {
|
||||||
const trgraph::Node* last = hop.start;
|
const trgraph::Node* last = hop.start;
|
||||||
if (hop.edges.size() == 0) {
|
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));
|
return shapeL(getNCR(trip), getRAttrs(trip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +220,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
||||||
{
|
{
|
||||||
LOG(INFO) << "@ " << j << " / " << clusters.size() << " ("
|
LOG(INFO) << "@ " << j << " / " << clusters.size() << " ("
|
||||||
<< (static_cast<int>((j * 1.0) / clusters.size() * 100))
|
<< (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
|
TODO: this is actually misleading. We are counting the
|
||||||
Dijkstra iterations, but the measuring them against
|
Dijkstra iterations, but the measuring them against
|
||||||
|
@ -284,7 +285,8 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
||||||
LOG(DEBUG) << "Total avg. trip tput "
|
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 "
|
LOG(DEBUG) << "Avg hop distance was "
|
||||||
<< (totAvgDist / static_cast<double>(clusters.size())) << " meters";
|
<< (totAvgDist / static_cast<double>(clusters.size()))
|
||||||
|
<< " meters";
|
||||||
|
|
||||||
if (_cfg.buildTransitGraph) {
|
if (_cfg.buildTransitGraph) {
|
||||||
LOG(INFO) << "Building transit network graph...";
|
LOG(INFO) << "Building transit network graph...";
|
||||||
|
@ -321,12 +323,12 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
||||||
double dist = -1;
|
double dist = -1;
|
||||||
double lastDist = -1;
|
double lastDist = -1;
|
||||||
hopDists->push_back(0);
|
hopDists->push_back(0);
|
||||||
DPoint last(0, 0);
|
POINT last(0, 0);
|
||||||
for (const auto& hop : shp.hops) {
|
for (const auto& hop : shp.hops) {
|
||||||
const trgraph::Node* l = hop.start;
|
const trgraph::Node* l = hop.start;
|
||||||
if (hop.edges.size() == 0) {
|
if (hop.edges.size() == 0) {
|
||||||
DPoint ll = webMercToLatLng<double>(hop.start->pl().getGeom()->getX(),
|
POINT ll = webMercToLatLng<PFAEDLE_PRECISION>(
|
||||||
hop.start->pl().getGeom()->getY());
|
hop.start->pl().getGeom()->getX(), hop.start->pl().getGeom()->getY());
|
||||||
|
|
||||||
if (dist > -0.5)
|
if (dist > -0.5)
|
||||||
dist += webMercMeterDist(last, *hop.start->pl().getGeom());
|
dist += webMercMeterDist(last, *hop.start->pl().getGeom());
|
||||||
|
@ -345,8 +347,8 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
||||||
last = *hop.end->pl().getGeom();
|
last = *hop.end->pl().getGeom();
|
||||||
|
|
||||||
if (dist - lastDist > 0.01) {
|
if (dist - lastDist > 0.01) {
|
||||||
ll = webMercToLatLng<double>(hop.end->pl().getGeom()->getX(),
|
ll = webMercToLatLng<PFAEDLE_PRECISION>(
|
||||||
hop.end->pl().getGeom()->getY());
|
hop.end->pl().getGeom()->getX(), hop.end->pl().getGeom()->getY());
|
||||||
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||||
seq++;
|
seq++;
|
||||||
lastDist = dist;
|
lastDist = dist;
|
||||||
|
@ -356,14 +358,15 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
||||||
const auto* e = *i;
|
const auto* e = *i;
|
||||||
if ((e->getFrom() == l) ^ e->pl().isRev()) {
|
if ((e->getFrom() == l) ^ e->pl().isRev()) {
|
||||||
for (size_t i = 0; i < e->pl().getGeom()->size(); i++) {
|
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)
|
if (dist > -0.5)
|
||||||
dist += webMercMeterDist(last, cur);
|
dist += webMercMeterDist(last, cur);
|
||||||
else
|
else
|
||||||
dist = 0;
|
dist = 0;
|
||||||
last = cur;
|
last = cur;
|
||||||
if (dist - lastDist > 0.01) {
|
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));
|
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||||
seq++;
|
seq++;
|
||||||
lastDist = dist;
|
lastDist = dist;
|
||||||
|
@ -371,14 +374,15 @@ ad::cppgtfs::gtfs::Shape* ShapeBuilder::getGtfsShape(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int64_t i = e->pl().getGeom()->size() - 1; i >= 0; i--) {
|
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)
|
if (dist > -0.5)
|
||||||
dist += webMercMeterDist(last, cur);
|
dist += webMercMeterDist(last, cur);
|
||||||
else
|
else
|
||||||
dist = 0;
|
dist = 0;
|
||||||
last = cur;
|
last = cur;
|
||||||
if (dist - lastDist > 0.01) {
|
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));
|
ret->addPoint(ShapePoint(ll.getY(), ll.getX(), dist, seq));
|
||||||
seq++;
|
seq++;
|
||||||
lastDist = dist;
|
lastDist = dist;
|
||||||
|
@ -452,10 +456,10 @@ BBoxIdx ShapeBuilder::getPaddedGtfsBox(const Feed* feed, double pad,
|
||||||
if (tid.empty() && t.second->getShape() && !dropShapes) continue;
|
if (tid.empty() && t.second->getShape() && !dropShapes) continue;
|
||||||
if (t.second->getStopTimes().size() < 2) continue;
|
if (t.second->getStopTimes().size() < 2) continue;
|
||||||
if (mots.count(t.second->getRoute()->getType())) {
|
if (mots.count(t.second->getRoute()->getType())) {
|
||||||
DBox cur = minbox<double>();
|
DBox cur;
|
||||||
for (const auto& st : t.second->getStopTimes()) {
|
for (const auto& st : t.second->getStopTimes()) {
|
||||||
cur = extendBox(
|
cur = extendBox(DPoint(st.getStop()->getLng(), st.getStop()->getLat()),
|
||||||
DPoint(st.getStop()->getLng(), st.getStop()->getLat()), cur);
|
cur);
|
||||||
}
|
}
|
||||||
box.add(cur);
|
box.add(cur);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +475,6 @@ void ShapeBuilder::buildGraph() {
|
||||||
osm::BBoxIdx box =
|
osm::BBoxIdx box =
|
||||||
getPaddedGtfsBox(_feed, 2500, _mots, _cfg.shapeTripId, _cfg.dropShapes);
|
getPaddedGtfsBox(_feed, 2500, _mots, _cfg.shapeTripId, _cfg.dropShapes);
|
||||||
|
|
||||||
|
|
||||||
osmBuilder.read(_cfg.osmPath, _motCfg.osmBuildOpts, &_g, box, _cfg.gridSize,
|
osmBuilder.read(_cfg.osmPath, _motCfg.osmBuildOpts, &_g, box, _cfg.gridSize,
|
||||||
getFeedStops(), &_restr);
|
getFeedStops(), &_restr);
|
||||||
|
|
||||||
|
@ -511,9 +514,10 @@ double ShapeBuilder::avgHopDist(Trip* trip) const {
|
||||||
prev = st.getStop();
|
prev = st.getStop();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto a = util::geo::latLngToWebMerc<double>(prev->getLat(), prev->getLng());
|
auto a = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(prev->getLat(),
|
||||||
auto b = util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
prev->getLng());
|
||||||
st.getStop()->getLng());
|
auto b = util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(
|
||||||
|
st.getStop()->getLat(), st.getStop()->getLng());
|
||||||
sum += util::geo::webMercMeterDist(a, b);
|
sum += util::geo::webMercMeterDist(a, b);
|
||||||
|
|
||||||
prev = st.getStop();
|
prev = st.getStop();
|
||||||
|
@ -573,8 +577,10 @@ bool ShapeBuilder::routingEqual(const Stop* a, const Stop* b) {
|
||||||
auto trackb = _motCfg.osmBuildOpts.trackNormzer(b->getPlatformCode());
|
auto trackb = _motCfg.osmBuildOpts.trackNormzer(b->getPlatformCode());
|
||||||
if (tracka != trackb) return false;
|
if (tracka != trackb) return false;
|
||||||
|
|
||||||
DPoint ap = util::geo::latLngToWebMerc<double>(a->getLat(), a->getLng());
|
POINT ap =
|
||||||
DPoint bp = util::geo::latLngToWebMerc<double>(b->getLat(), b->getLng());
|
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);
|
double d = util::geo::webMercMeterDist(ap, bp);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/config/MotConfig.h"
|
#include "pfaedle/config/MotConfig.h"
|
||||||
#include "pfaedle/config/PfaedleConfig.h"
|
#include "pfaedle/config/PfaedleConfig.h"
|
||||||
#include "pfaedle/eval/Collector.h"
|
#include "pfaedle/eval/Collector.h"
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
#include "pfaedle/router/Misc.h"
|
#include "pfaedle/router/Misc.h"
|
||||||
#include "pfaedle/router/Router.h"
|
#include "pfaedle/router/Router.h"
|
||||||
#include "pfaedle/trgraph/Graph.h"
|
#include "pfaedle/trgraph/Graph.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace router {
|
namespace router {
|
||||||
|
@ -28,8 +30,6 @@ using ad::cppgtfs::gtfs::Stop;
|
||||||
using ad::cppgtfs::gtfs::Trip;
|
using ad::cppgtfs::gtfs::Trip;
|
||||||
using ad::cppgtfs::gtfs::Feed;
|
using ad::cppgtfs::gtfs::Feed;
|
||||||
|
|
||||||
using util::geo::DLine;
|
|
||||||
|
|
||||||
struct Shape {
|
struct Shape {
|
||||||
router::EdgeListHops hops;
|
router::EdgeListHops hops;
|
||||||
double avgHopDist;
|
double avgHopDist;
|
||||||
|
@ -57,9 +57,9 @@ class ShapeBuilder {
|
||||||
|
|
||||||
const NodeCandGroup& getNodeCands(const Stop* s) const;
|
const NodeCandGroup& getNodeCands(const Stop* s) const;
|
||||||
|
|
||||||
DLine shapeL(const router::NodeCandRoute& ncr,
|
LINE shapeL(const router::NodeCandRoute& ncr,
|
||||||
const router::RoutingAttrs& rAttrs);
|
const router::RoutingAttrs& rAttrs);
|
||||||
DLine shapeL(Trip* trip);
|
LINE shapeL(Trip* trip);
|
||||||
|
|
||||||
pfaedle::router::Shape shape(Trip* trip) const;
|
pfaedle::router::Shape shape(Trip* trip) const;
|
||||||
pfaedle::router::Shape shape(Trip* trip);
|
pfaedle::router::Shape shape(Trip* trip);
|
||||||
|
@ -67,8 +67,7 @@ class ShapeBuilder {
|
||||||
const trgraph::Graph* getGraph() const;
|
const trgraph::Graph* getGraph() const;
|
||||||
|
|
||||||
static osm::BBoxIdx getPaddedGtfsBox(const Feed* feed, double pad,
|
static osm::BBoxIdx getPaddedGtfsBox(const Feed* feed, double pad,
|
||||||
const MOTs& mots,
|
const MOTs& mots, const std::string& tid,
|
||||||
const std::string& tid,
|
|
||||||
bool dropShapes);
|
bool dropShapes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
|
|
||||||
using pfaedle::trgraph::EdgePL;
|
using pfaedle::trgraph::EdgePL;
|
||||||
using pfaedle::trgraph::TransitEdgeLine;
|
using pfaedle::trgraph::TransitEdgeLine;
|
||||||
using util::geo::DLine;
|
|
||||||
|
|
||||||
std::map<DLine*, size_t> EdgePL::_flines;
|
|
||||||
|
std::map<LINE*, size_t> EdgePL::_flines;
|
||||||
std::map<const TransitEdgeLine*, size_t> EdgePL::_tlines;
|
std::map<const TransitEdgeLine*, size_t> EdgePL::_tlines;
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
EdgePL::EdgePL()
|
EdgePL::EdgePL()
|
||||||
: _length(0), _oneWay(0), _hasRestr(false), _rev(false), _lvl(0) {
|
: _length(0), _oneWay(0), _hasRestr(false), _rev(false), _lvl(0) {
|
||||||
_l = new DLine();
|
_l = new LINE();
|
||||||
_flines[_l] = 1;
|
_flines[_l] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ EdgePL::EdgePL(const EdgePL& pl, bool geoflat)
|
||||||
if (geoflat) {
|
if (geoflat) {
|
||||||
_l = pl._l;
|
_l = pl._l;
|
||||||
} else {
|
} else {
|
||||||
_l = new DLine(*pl._l);
|
_l = new LINE(*pl._l);
|
||||||
}
|
}
|
||||||
_flines[_l]++;
|
_flines[_l]++;
|
||||||
|
|
||||||
|
@ -101,13 +101,13 @@ const std::set<const TransitEdgeLine*>& EdgePL::getLines() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
void EdgePL::addPoint(const util::geo::DPoint& p) { _l->push_back(p); }
|
void EdgePL::addPoint(const POINT& p) { _l->push_back(p); }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const DLine* EdgePL::getGeom() const { return _l; }
|
const LINE* EdgePL::getGeom() const { return _l; }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
DLine* EdgePL::getGeom() { return _l; }
|
LINE* EdgePL::getGeom() { return _l; }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
util::json::Dict EdgePL::getAttrs() const {
|
util::json::Dict EdgePL::getAttrs() const {
|
||||||
|
@ -162,7 +162,7 @@ void EdgePL::setRev() { _rev = true; }
|
||||||
bool EdgePL::isRev() const { return _rev; }
|
bool EdgePL::isRev() const { return _rev; }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const util::geo::DPoint& EdgePL::backHop() const {
|
const POINT& EdgePL::backHop() const {
|
||||||
if (isRev()) {
|
if (isRev()) {
|
||||||
return *(++(getGeom()->cbegin()));
|
return *(++(getGeom()->cbegin()));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ const util::geo::DPoint& EdgePL::backHop() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const util::geo::DPoint& EdgePL::frontHop() const {
|
const POINT& EdgePL::frontHop() const {
|
||||||
if (isRev()) {
|
if (isRev()) {
|
||||||
return *(++(getGeom()->crbegin()));
|
return *(++(getGeom()->crbegin()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/router/Comp.h"
|
#include "pfaedle/router/Comp.h"
|
||||||
|
#include "util/geo/Geo.h"
|
||||||
#include "util/geo/GeoGraph.h"
|
#include "util/geo/GeoGraph.h"
|
||||||
|
|
||||||
using util::geograph::GeoEdgePL;
|
using util::geograph::GeoEdgePL;
|
||||||
using util::geo::DLine;
|
|
||||||
using util::geo::DPoint;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace trgraph {
|
namespace trgraph {
|
||||||
|
@ -43,7 +45,7 @@ inline bool operator<(const TransitEdgeLine& a, const TransitEdgeLine& b) {
|
||||||
/*
|
/*
|
||||||
* An edge payload class for the transit graph.
|
* An edge payload class for the transit graph.
|
||||||
*/
|
*/
|
||||||
class EdgePL : public GeoEdgePL<double> {
|
class EdgePL : public GeoEdgePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
EdgePL();
|
EdgePL();
|
||||||
~EdgePL();
|
~EdgePL();
|
||||||
|
@ -51,11 +53,11 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
EdgePL(const EdgePL& pl, bool geoFlat);
|
EdgePL(const EdgePL& pl, bool geoFlat);
|
||||||
|
|
||||||
// Return the geometry of this edge.
|
// Return the geometry of this edge.
|
||||||
const DLine* getGeom() const;
|
const LINE* getGeom() const;
|
||||||
DLine* getGeom();
|
LINE* getGeom();
|
||||||
|
|
||||||
// Extends this edge payload's geometry by Point p
|
// Extends this edge payload's geometry by Point p
|
||||||
void addPoint(const DPoint& p);
|
void addPoint(const POINT& p);
|
||||||
|
|
||||||
// Fill obj with k/v pairs describing the parameters of this payload.
|
// Fill obj with k/v pairs describing the parameters of this payload.
|
||||||
util::json::Dict getAttrs() const;
|
util::json::Dict getAttrs() const;
|
||||||
|
@ -103,11 +105,11 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
|
|
||||||
// Returns the last hop of the payload - this is the (n-2)th point in
|
// Returns the last hop of the payload - this is the (n-2)th point in
|
||||||
// the payload geometry of length n > 1
|
// the payload geometry of length n > 1
|
||||||
const DPoint& backHop() const;
|
const POINT& backHop() const;
|
||||||
|
|
||||||
// Returns the first hop of the payload - this is the 2nd point in
|
// Returns the first hop of the payload - this is the 2nd point in
|
||||||
// the payload geometry of length n > 1
|
// the payload geometry of length n > 1
|
||||||
const DPoint& frontHop() const;
|
const POINT& frontHop() const;
|
||||||
|
|
||||||
// Obtain an exact copy of this edge, but in reverse.
|
// Obtain an exact copy of this edge, but in reverse.
|
||||||
EdgePL revCopy() const;
|
EdgePL revCopy() const;
|
||||||
|
@ -119,13 +121,13 @@ class EdgePL : public GeoEdgePL<double> {
|
||||||
bool _rev : 1;
|
bool _rev : 1;
|
||||||
uint8_t _lvl : 3;
|
uint8_t _lvl : 3;
|
||||||
|
|
||||||
DLine* _l;
|
LINE* _l;
|
||||||
|
|
||||||
std::set<const TransitEdgeLine*> _lines;
|
std::set<const TransitEdgeLine*> _lines;
|
||||||
|
|
||||||
static void unRefTLine(const TransitEdgeLine* l);
|
static void unRefTLine(const TransitEdgeLine* l);
|
||||||
|
|
||||||
static std::map<DLine*, size_t> _flines;
|
static std::map<LINE*, size_t> _flines;
|
||||||
static std::map<const TransitEdgeLine*, size_t> _tlines;
|
static std::map<const TransitEdgeLine*, size_t> _tlines;
|
||||||
};
|
};
|
||||||
} // namespace trgraph
|
} // namespace trgraph
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace trgraph {
|
||||||
typedef util::graph::Edge<NodePL, EdgePL> Edge;
|
typedef util::graph::Edge<NodePL, EdgePL> Edge;
|
||||||
typedef util::graph::Node<NodePL, EdgePL> Node;
|
typedef util::graph::Node<NodePL, EdgePL> Node;
|
||||||
typedef util::graph::DirGraph<NodePL, EdgePL> Graph;
|
typedef util::graph::DirGraph<NodePL, EdgePL> Graph;
|
||||||
typedef Grid<Node*, Point, double> NodeGrid;
|
typedef Grid<Node*, Point, PFAEDLE_PRECISION> NodeGrid;
|
||||||
typedef Grid<Edge*, Line, double> EdgeGrid;
|
typedef Grid<Edge*, Line, PFAEDLE_PRECISION> EdgeGrid;
|
||||||
|
|
||||||
} // namespace trgraph
|
} // namespace trgraph
|
||||||
} // namespace pfaedle
|
} // namespace pfaedle
|
||||||
|
|
|
@ -46,7 +46,7 @@ NodePL::NodePL(const NodePL& pl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
NodePL::NodePL(const DPoint& geom)
|
NodePL::NodePL(const POINT& geom)
|
||||||
: _geom(geom),
|
: _geom(geom),
|
||||||
_si(0),
|
_si(0),
|
||||||
_component(0)
|
_component(0)
|
||||||
|
@ -58,7 +58,7 @@ NodePL::NodePL(const DPoint& geom)
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
NodePL::NodePL(const DPoint& geom, const StatInfo& si)
|
NodePL::NodePL(const POINT& geom, const StatInfo& si)
|
||||||
: _geom(geom),
|
: _geom(geom),
|
||||||
_si(0),
|
_si(0),
|
||||||
_component(0)
|
_component(0)
|
||||||
|
@ -108,10 +108,10 @@ void NodePL::setComp(const Component* c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const DPoint* NodePL::getGeom() const { return &_geom; }
|
const POINT* NodePL::getGeom() const { return &_geom; }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
void NodePL::setGeom(const DPoint& geom) { _geom = geom; }
|
void NodePL::setGeom(const POINT& geom) { _geom = geom; }
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
util::json::Dict NodePL::getAttrs() const {
|
util::json::Dict NodePL::getAttrs() const {
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||||
|
#include "pfaedle/Def.h"
|
||||||
#include "pfaedle/trgraph/StatInfo.h"
|
#include "pfaedle/trgraph/StatInfo.h"
|
||||||
#include "util/geo/GeoGraph.h"
|
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
#include "util/geo/GeoGraph.h"
|
||||||
|
|
||||||
using util::geograph::GeoNodePL;
|
using util::geograph::GeoNodePL;
|
||||||
using util::geo::DPoint;
|
|
||||||
|
|
||||||
namespace pfaedle {
|
namespace pfaedle {
|
||||||
namespace trgraph {
|
namespace trgraph {
|
||||||
|
@ -26,17 +26,17 @@ struct Component {
|
||||||
/*
|
/*
|
||||||
* A node payload class for the transit graph.
|
* A node payload class for the transit graph.
|
||||||
*/
|
*/
|
||||||
class NodePL : public GeoNodePL<double> {
|
class NodePL : public GeoNodePL<PFAEDLE_PRECISION> {
|
||||||
public:
|
public:
|
||||||
NodePL();
|
NodePL();
|
||||||
NodePL(const NodePL& pl); // NOLINT
|
NodePL(const NodePL& pl); // NOLINT
|
||||||
NodePL(const DPoint& geom); // NOLINT
|
NodePL(const POINT& geom); // NOLINT
|
||||||
NodePL(const DPoint& geom, const StatInfo& si);
|
NodePL(const POINT& geom, const StatInfo& si);
|
||||||
~NodePL();
|
~NodePL();
|
||||||
|
|
||||||
// Return the geometry of this node.
|
// Return the geometry of this node.
|
||||||
const DPoint* getGeom() const;
|
const POINT* getGeom() const;
|
||||||
void setGeom(const DPoint& geom);
|
void setGeom(const POINT& geom);
|
||||||
|
|
||||||
// Fill obj with k/v pairs describing the parameters of this payload.
|
// Fill obj with k/v pairs describing the parameters of this payload.
|
||||||
util::json::Dict getAttrs() const;
|
util::json::Dict getAttrs() const;
|
||||||
|
@ -68,7 +68,7 @@ class NodePL : public GeoNodePL<double> {
|
||||||
void setVisited() const;
|
void setVisited() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DPoint _geom;
|
POINT _geom;
|
||||||
StatInfo* _si;
|
StatInfo* _si;
|
||||||
const Component* _component;
|
const Component* _component;
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,7 @@ const NodeCandGroup& StatGroup::getNodeCands(const Stop* s) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
const std::set<Node*>& StatGroup::getNodes() const {
|
const std::set<Node*>& StatGroup::getNodes() const { return _nodes; }
|
||||||
return _nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
void StatGroup::remNode(trgraph::Node* n) {
|
void StatGroup::remNode(trgraph::Node* n) {
|
||||||
|
@ -64,7 +62,8 @@ double StatGroup::getPen(const Stop* s, trgraph::Node* n,
|
||||||
const trgraph::Normalizer& platformNorm,
|
const trgraph::Normalizer& platformNorm,
|
||||||
double trackPen, double distPenFac,
|
double trackPen, double distPenFac,
|
||||||
double nonOsmPen) const {
|
double nonOsmPen) const {
|
||||||
DPoint p = util::geo::latLngToWebMerc<double>(s->getLat(), s->getLng());
|
POINT p =
|
||||||
|
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(s->getLat(), s->getLng());
|
||||||
|
|
||||||
double distPen = util::geo::webMercMeterDist(p, *n->pl().getGeom());
|
double distPen = util::geo::webMercMeterDist(p, *n->pl().getGeom());
|
||||||
distPen *= distPenFac;
|
distPen *= distPenFac;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Geo.h"
|
#include "Geo.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue