use double precision
This commit is contained in:
parent
967963e180
commit
486a8136fd
24 changed files with 186 additions and 177 deletions
|
@ -15,9 +15,9 @@
|
|||
#include "util/geo/output/GeoJsonOutput.h"
|
||||
#include "util/log/Log.h"
|
||||
|
||||
using util::geo::FLine;
|
||||
using util::geo::DLine;
|
||||
using util::geo::PolyLine;
|
||||
using util::geo::FPoint;
|
||||
using util::geo::DPoint;
|
||||
using ad::cppgtfs::gtfs::Trip;
|
||||
using ad::cppgtfs::gtfs::Shape;
|
||||
using pfaedle::eval::Collector;
|
||||
|
@ -46,12 +46,12 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
|||
double unmatchedSegmentsLength;
|
||||
|
||||
std::vector<double> oldDists;
|
||||
FLine oldL = getWebMercLine(
|
||||
DLine oldL = getWebMercLine(
|
||||
oldS, t->getStopTimes().begin()->getShapeDistanceTravelled(),
|
||||
(--t->getStopTimes().end())->getShapeDistanceTravelled(), &oldDists);
|
||||
|
||||
std::vector<double> newDists;
|
||||
FLine newL = getWebMercLine(newS, -1, -1, &newDists);
|
||||
DLine newL = getWebMercLine(newS, -1, -1, &newDists);
|
||||
|
||||
std::ofstream fstr(_evalOutPath + "/trip-" + t->getId() + ".json");
|
||||
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
|
||||
// loops at the end
|
||||
PolyLine<float> oldStart = oldSegs[0];
|
||||
PolyLine<float> newStart = newSegs[0];
|
||||
PolyLine<double> oldStart = oldSegs[0];
|
||||
PolyLine<double> newStart = newSegs[0];
|
||||
auto oldStartNew =
|
||||
oldStart.getSegment(oldStart.projectOn(newSegs[0][0]).totalPos, 1);
|
||||
auto newStartNew =
|
||||
|
@ -77,8 +77,8 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
|||
newSegs[0] = newStartNew.getLine();
|
||||
}
|
||||
|
||||
PolyLine<float> oldEnd = oldSegs[oldSegs.size() - 1];
|
||||
PolyLine<float> newEnd = newSegs[oldSegs.size() - 1];
|
||||
PolyLine<double> oldEnd = oldSegs[oldSegs.size() - 1];
|
||||
PolyLine<double> newEnd = newSegs[oldSegs.size() - 1];
|
||||
auto oldEndNew =
|
||||
oldEnd.getSegment(0, oldEnd.projectOn(newSegs.back().back()).totalPos);
|
||||
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
|
||||
FLine oldLCut;
|
||||
FLine newLCut;
|
||||
DLine oldLCut;
|
||||
DLine newLCut;
|
||||
|
||||
for (auto oldL : oldSegs) {
|
||||
gjout.print(oldL, util::json::Dict{{"ver", "old"}});
|
||||
|
@ -171,26 +171,26 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
std::vector<FLine> Collector::segmentize(
|
||||
const Trip* t, const FLine& shape, const std::vector<double>& dists,
|
||||
std::vector<DLine> Collector::segmentize(
|
||||
const Trip* t, const DLine& shape, const std::vector<double>& dists,
|
||||
const std::vector<double>* newTripDists) {
|
||||
std::vector<FLine> ret;
|
||||
std::vector<DLine> ret;
|
||||
|
||||
if (t->getStopTimes().size() < 2) return ret;
|
||||
|
||||
util::geo::PolyLine<float> pl(shape);
|
||||
std::vector<std::pair<FPoint, double> > cuts;
|
||||
util::geo::PolyLine<double> pl(shape);
|
||||
std::vector<std::pair<DPoint, double> > cuts;
|
||||
|
||||
size_t i = 0;
|
||||
for (auto st : t->getStopTimes()) {
|
||||
if (newTripDists) {
|
||||
cuts.push_back(std::pair<FPoint, double>(
|
||||
util::geo::latLngToWebMerc<float>(st.getStop()->getLat(),
|
||||
cuts.push_back(std::pair<DPoint, double>(
|
||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
(*newTripDists)[i]));
|
||||
} else {
|
||||
cuts.push_back(std::pair<FPoint, double>(
|
||||
util::geo::latLngToWebMerc<float>(st.getStop()->getLat(),
|
||||
cuts.push_back(std::pair<DPoint, double>(
|
||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
st.getShapeDistanceTravelled()));
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ std::vector<FLine> Collector::segmentize(
|
|||
// get first half of geometry, and search for start point there!
|
||||
size_t before = std::upper_bound(dists.begin(), dists.end(), cuts[1].second) -
|
||||
dists.begin();
|
||||
util::geo::PolyLine<float> l(
|
||||
FLine(shape.begin(), shape.begin() + before + 1));
|
||||
util::geo::PolyLine<double> l(
|
||||
DLine(shape.begin(), shape.begin() + before + 1));
|
||||
auto lastLp = l.projectOn(cuts.front().first);
|
||||
|
||||
for (size_t i = 1; i < cuts.size(); i++) {
|
||||
|
@ -212,8 +212,8 @@ std::vector<FLine> Collector::segmentize(
|
|||
dists.begin();
|
||||
}
|
||||
|
||||
util::geo::PolyLine<float> beforePl(
|
||||
FLine(shape.begin(), shape.begin() + before));
|
||||
util::geo::PolyLine<double> beforePl(
|
||||
DLine(shape.begin(), shape.begin() + before));
|
||||
|
||||
auto curLp = beforePl.projectOnAfter(cuts[i].first, lastLp.lastIndex);
|
||||
|
||||
|
@ -226,14 +226,14 @@ std::vector<FLine> Collector::segmentize(
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
FLine Collector::getWebMercLine(const Shape* s, double from, double t) {
|
||||
DLine Collector::getWebMercLine(const Shape* s, double from, double t) {
|
||||
return getWebMercLine(s, from, t, 0);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
FLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||
DLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists) {
|
||||
FLine ret;
|
||||
DLine ret;
|
||||
|
||||
auto i = s->getPoints().begin();
|
||||
|
||||
|
@ -243,7 +243,7 @@ FLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
|||
if ((from < 0 || (p.travelDist - from) > -0.01)) {
|
||||
if (to >= 0 && (p.travelDist - to) > 0.01) break;
|
||||
|
||||
FPoint mercP = util::geo::latLngToWebMerc<float>(p.lat, p.lng);
|
||||
DPoint mercP = util::geo::latLngToWebMerc<double>(p.lat, p.lng);
|
||||
|
||||
ret.push_back(mercP);
|
||||
if (dists) dists->push_back(p.travelDist);
|
||||
|
@ -393,8 +393,8 @@ void Collector::printStats(std::ostream* os) const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
std::pair<size_t, double> Collector::getDa(const std::vector<FLine>& a,
|
||||
const std::vector<FLine>& b) {
|
||||
std::pair<size_t, double> Collector::getDa(const std::vector<DLine>& a,
|
||||
const std::vector<DLine>& b) {
|
||||
assert(a.size() == b.size());
|
||||
std::pair<size_t, double> ret{0, 0};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
using ad::cppgtfs::gtfs::Trip;
|
||||
using ad::cppgtfs::gtfs::Shape;
|
||||
using util::geo::FLine;
|
||||
using util::geo::DLine;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace eval {
|
||||
|
@ -57,8 +57,8 @@ class Collector {
|
|||
// Return the averaged average frechet distance
|
||||
double getAvgDist() const;
|
||||
|
||||
static FLine getWebMercLine(const Shape* s, double from, double to);
|
||||
static FLine getWebMercLine(const Shape* s, double from, double to,
|
||||
static DLine getWebMercLine(const Shape* s, double from, double to);
|
||||
static DLine getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists);
|
||||
|
||||
private:
|
||||
|
@ -78,10 +78,10 @@ class Collector {
|
|||
|
||||
std::vector<double> _dfBins;
|
||||
|
||||
static std::pair<size_t, double> getDa(const std::vector<FLine>& a,
|
||||
const std::vector<FLine>& b);
|
||||
static std::pair<size_t, double> getDa(const std::vector<DLine>& a,
|
||||
const std::vector<DLine>& b);
|
||||
|
||||
static std::vector<FLine> segmentize(const Trip* t, const FLine& shape,
|
||||
static std::vector<DLine> segmentize(const Trip* t, const DLine& shape,
|
||||
const std::vector<double>& dists,
|
||||
const std::vector<double>* newTripDists);
|
||||
|
||||
|
|
|
@ -22,17 +22,17 @@ namespace netgraph {
|
|||
* A payload class for edges on a network graph - that is a graph
|
||||
* that exactly represents a physical public transit network
|
||||
*/
|
||||
class EdgePL : public GeoEdgePL<float> {
|
||||
class EdgePL : public GeoEdgePL<double> {
|
||||
public:
|
||||
EdgePL() {}
|
||||
EdgePL(const util::geo::FLine& l, const std::set<const Trip*>& trips)
|
||||
EdgePL(const util::geo::DLine& l, const std::set<const Trip*>& trips)
|
||||
: _l(l), _trips(trips) {
|
||||
for (const auto t : _trips) {
|
||||
_routeShortNames.insert(t->getRoute()->getShortName());
|
||||
_tripShortNames.insert(t->getShortname());
|
||||
}
|
||||
}
|
||||
const util::geo::FLine* getGeom() const { return &_l; }
|
||||
const util::geo::DLine* getGeom() const { return &_l; }
|
||||
util::json::Dict getAttrs() const {
|
||||
util::json::Dict obj;
|
||||
obj["num_trips"] = static_cast<int>(_trips.size());
|
||||
|
@ -44,7 +44,7 @@ class EdgePL : public GeoEdgePL<float> {
|
|||
}
|
||||
|
||||
private:
|
||||
util::geo::FLine _l;
|
||||
util::geo::DLine _l;
|
||||
std::set<const Trip*> _trips;
|
||||
std::set<std::string> _routeShortNames;
|
||||
std::set<std::string> _tripShortNames;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
using util::geo::Point;
|
||||
using util::geo::Line;
|
||||
using util::geo::FPoint;
|
||||
using util::geo::FLine;
|
||||
using util::geo::DPoint;
|
||||
using util::geo::DLine;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace netgraph {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "util/geo/GeoGraph.h"
|
||||
|
||||
using util::geograph::GeoNodePL;
|
||||
using util::geo::DPoint;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace netgraph {
|
||||
|
@ -19,18 +20,18 @@ namespace netgraph {
|
|||
* A payload class for edges on a network graph - that is a graph
|
||||
* that exactly represents a physical public transit network
|
||||
*/
|
||||
class NodePL : public GeoNodePL<float> {
|
||||
class NodePL : public GeoNodePL<double> {
|
||||
public:
|
||||
NodePL() {}
|
||||
NodePL(const util::geo::FPoint& geom) { _geom = geom; } // NOLINT
|
||||
NodePL(const util::geo::DPoint& geom) { _geom = geom; } // NOLINT
|
||||
|
||||
const util::geo::FPoint* getGeom() const { return &_geom; }
|
||||
const DPoint* getGeom() const { return &_geom; }
|
||||
util::json::Dict getAttrs() const {
|
||||
return util::json::Dict();
|
||||
}
|
||||
|
||||
private:
|
||||
util::geo::FPoint _geom;
|
||||
DPoint _geom;
|
||||
};
|
||||
} // namespace netgraph
|
||||
} // namespace pfaedle
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
using pfaedle::osm::BBoxIdx;
|
||||
|
||||
// _____________________________________________________________________________
|
||||
BBoxIdx::BBoxIdx(float padding) : _padding(padding), _size(0) {}
|
||||
BBoxIdx::BBoxIdx(double padding) : _padding(padding), _size(0) {}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
void BBoxIdx::add(Box<float> box) {
|
||||
void BBoxIdx::add(Box<double> box) {
|
||||
// division by 83.000m is only correct here around a latitude deg of 25,
|
||||
// but should be a good heuristic. 1 deg is around 63km at latitude deg of 44,
|
||||
// and 110 at deg=0, since we usually dont do map matching in the arctic,
|
||||
|
@ -24,21 +24,21 @@ void BBoxIdx::add(Box<float> box) {
|
|||
size_t BBoxIdx::size() const { return _size; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool BBoxIdx::contains(const Point<float>& p) const {
|
||||
bool BBoxIdx::contains(const Point<double>& p) const {
|
||||
return treeHas(p, _root);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
util::geo::Box<float> BBoxIdx::getFullWebMercBox() const {
|
||||
return util::geo::FBox(
|
||||
util::geo::latLngToWebMerc<float>(_root.box.getLowerLeft().getY(),
|
||||
util::geo::Box<double> BBoxIdx::getFullWebMercBox() const {
|
||||
return util::geo::DBox(
|
||||
util::geo::latLngToWebMerc<double>(_root.box.getLowerLeft().getY(),
|
||||
_root.box.getLowerLeft().getX()),
|
||||
util::geo::latLngToWebMerc<float>(_root.box.getUpperRight().getY(),
|
||||
util::geo::latLngToWebMerc<double>(_root.box.getUpperRight().getY(),
|
||||
_root.box.getUpperRight().getX()));
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
bool BBoxIdx::treeHas(const Point<float>& p, const BBoxIdxNd& nd) const {
|
||||
bool BBoxIdx::treeHas(const Point<double>& p, const BBoxIdxNd& nd) const {
|
||||
if (!nd.childs.size()) return util::geo::contains(p, nd.box);
|
||||
for (const auto& child : nd.childs) {
|
||||
if (util::geo::contains(p, child.box)) return treeHas(p, child);
|
||||
|
@ -48,7 +48,7 @@ bool BBoxIdx::treeHas(const Point<float>& p, const BBoxIdxNd& nd) const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
void BBoxIdx::addToTree(const Box<float>& box, BBoxIdxNd* nd, size_t lvl) {
|
||||
void BBoxIdx::addToTree(const Box<double>& box, BBoxIdxNd* nd, size_t lvl) {
|
||||
double bestCommonArea = 0;
|
||||
ssize_t bestChild = -1;
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ using util::geo::Box;
|
|||
using util::geo::Point;
|
||||
|
||||
struct BBoxIdxNd {
|
||||
BBoxIdxNd() : box(util::geo::minbox<float>()) {}
|
||||
explicit BBoxIdxNd(const Box<float>& box) : box(box) {}
|
||||
Box<float> box;
|
||||
BBoxIdxNd() : box(util::geo::minbox<double>()) {}
|
||||
explicit BBoxIdxNd(const Box<double>& box) : box(box) {}
|
||||
Box<double> box;
|
||||
std::vector<BBoxIdxNd> childs;
|
||||
};
|
||||
|
||||
|
@ -26,16 +26,16 @@ struct BBoxIdxNd {
|
|||
*/
|
||||
class BBoxIdx {
|
||||
public:
|
||||
explicit BBoxIdx(float padding);
|
||||
explicit BBoxIdx(double padding);
|
||||
|
||||
// Add a bounding box to this index
|
||||
void add(Box<float> box);
|
||||
void add(Box<double> box);
|
||||
|
||||
// Check if a point is contained in this index
|
||||
bool contains(const Point<float>& box) const;
|
||||
bool contains(const Point<double>& box) const;
|
||||
|
||||
// Return the full total bounding box of this index
|
||||
util::geo::Box<float> getFullWebMercBox() const;
|
||||
util::geo::Box<double> getFullWebMercBox() const;
|
||||
|
||||
// Return the size of this index
|
||||
size_t size() const;
|
||||
|
@ -46,8 +46,8 @@ class BBoxIdx {
|
|||
|
||||
BBoxIdxNd _root;
|
||||
|
||||
void addToTree(const Box<float>& box, BBoxIdxNd* nd, size_t lvl);
|
||||
bool treeHas(const Point<float>& p, const BBoxIdxNd& nd) const;
|
||||
void addToTree(const Box<double>& box, BBoxIdxNd* nd, size_t lvl);
|
||||
bool treeHas(const Point<double>& p, const BBoxIdxNd& nd) const;
|
||||
|
||||
static const size_t MAX_LVL = 5;
|
||||
static constexpr double MIN_COM_AREA = 0.0;
|
||||
|
|
|
@ -136,7 +136,7 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
|||
|
||||
for (double d : opts.maxSnapDistances) {
|
||||
for (auto s : orphanStations) {
|
||||
FPoint geom = *s->pl().getGeom();
|
||||
DPoint geom = *s->pl().getGeom();
|
||||
NodePL pl = s->pl();
|
||||
pl.getSI()->setIsFromOsm(false);
|
||||
const auto& r = snapStation(g, &pl, &eg, &sng, opts, res, false, d);
|
||||
|
@ -374,7 +374,7 @@ void OsmBuilder::readWriteWays(xml::File* i, util::xml::XmlWriter* o,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
NodePL OsmBuilder::plFromGtfs(const Stop* s, const OsmReadOpts& ops) const {
|
||||
NodePL ret(util::geo::latLngToWebMerc<float>(s->getLat(), s->getLng()),
|
||||
NodePL ret(util::geo::latLngToWebMerc<double>(s->getLat(), s->getLng()),
|
||||
StatInfo(ops.statNormzer(s->getName()),
|
||||
ops.trackNormzer(s->getPlatformCode()), false));
|
||||
|
||||
|
@ -413,7 +413,7 @@ xml::ParserState OsmBuilder::readBBoxNds(xml::File* xml, OsmIdSet* nodes,
|
|||
double y = util::atof(cur.attrs.find("lat")->second, 7);
|
||||
double x = util::atof(cur.attrs.find("lon")->second, 7);
|
||||
|
||||
if (bbox.contains(Point<float>(x, y))) {
|
||||
if (bbox.contains(Point<double>(x, y))) {
|
||||
curId = util::atoul(cur.attrs.find("id")->second);
|
||||
nodes->add(curId);
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ void OsmBuilder::readNodes(xml::File* xml, Graph* g, const RelLst& rels,
|
|||
keepAttrs, fl))
|
||||
.id) {
|
||||
Node* n = 0;
|
||||
auto pos = util::geo::latLngToWebMerc<float>(nd.lat, nd.lng);
|
||||
auto pos = util::geo::latLngToWebMerc<double>(nd.lat, nd.lng);
|
||||
if (nodes->count(nd.id)) {
|
||||
n = (*nodes)[nd.id];
|
||||
n->pl().setGeom(pos);
|
||||
|
@ -930,7 +930,7 @@ std::string OsmBuilder::getAttr(const DeepAttrRule& s, osmid id,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
Nullable<StatInfo> OsmBuilder::getStatInfo(Node* node, osmid nid,
|
||||
const FPoint& pos, const AttrMap& m,
|
||||
const DPoint& pos, const AttrMap& m,
|
||||
StAttrGroups* groups,
|
||||
const RelMap& nodeRels,
|
||||
const RelLst& rels,
|
||||
|
@ -994,7 +994,7 @@ double OsmBuilder::dist(const Node* a, const Node* b) const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
double OsmBuilder::webMercDistFactor(const util::geo::FPoint& a) const {
|
||||
double OsmBuilder::webMercDistFactor(const util::geo::DPoint& a) const {
|
||||
// euclidean distance on web mercator is in meters on equator,
|
||||
// and proportional to cos(lat) in both y directions
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ void OsmBuilder::fixGaps(Graph* g, NodeGrid* ng) const {
|
|||
otherN = (*nb->getAdjListOut().begin())->getOtherNd(nb);
|
||||
else
|
||||
otherN = (*nb->getAdjListIn().begin())->getOtherNd(nb);
|
||||
FLine l;
|
||||
DLine l;
|
||||
l.push_back(*otherN->pl().getGeom());
|
||||
l.push_back(*n->pl().getGeom());
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ void OsmBuilder::fixGaps(Graph* g, NodeGrid* ng) const {
|
|||
|
||||
// _____________________________________________________________________________
|
||||
EdgeGrid OsmBuilder::buildEdgeIdx(Graph* g, size_t size,
|
||||
const Box<float>& webMercBox) const {
|
||||
const Box<double>& webMercBox) const {
|
||||
EdgeGrid ret(size, size, webMercBox, false);
|
||||
for (auto* n : *g->getNds()) {
|
||||
for (auto* e : n->getAdjListOut()) {
|
||||
|
@ -1070,7 +1070,7 @@ EdgeGrid OsmBuilder::buildEdgeIdx(Graph* g, size_t size,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
NodeGrid OsmBuilder::buildNodeIdx(Graph* g, size_t size,
|
||||
const Box<float>& webMercBox,
|
||||
const Box<double>& webMercBox,
|
||||
bool which) const {
|
||||
NodeGrid ret(size, size, webMercBox, false);
|
||||
for (auto* n : *g->getNds()) {
|
||||
|
@ -1084,7 +1084,7 @@ NodeGrid OsmBuilder::buildNodeIdx(Graph* g, size_t size,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
||||
const util::geo::FPoint& p, double maxD,
|
||||
const util::geo::DPoint& p, double maxD,
|
||||
int maxFullTurns, double minAngle,
|
||||
const SearchFunc& sfunc) const {
|
||||
// shortcuts
|
||||
|
@ -1125,10 +1125,10 @@ Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
|||
if (cur.fromEdge &&
|
||||
cur.node->getInDeg() + cur.node->getOutDeg() >
|
||||
2) { // only intersection angles
|
||||
const FPoint& toP = *cand->pl().getGeom();
|
||||
const FPoint& fromP =
|
||||
const DPoint& toP = *cand->pl().getGeom();
|
||||
const DPoint& fromP =
|
||||
*cur.fromEdge->getOtherNd(cur.node)->pl().getGeom();
|
||||
const FPoint& nodeP = *cur.node->pl().getGeom();
|
||||
const DPoint& nodeP = *cur.node->pl().getGeom();
|
||||
|
||||
if (util::geo::innerProd(nodeP, fromP, toP) < minAngle) fullTurn = 1;
|
||||
}
|
||||
|
@ -1150,24 +1150,24 @@ Node* OsmBuilder::depthSearch(const Edge* e, const StatInfo* si,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
bool OsmBuilder::isBlocked(const Edge* e, const StatInfo* si,
|
||||
const util::geo::FPoint& p, double maxD,
|
||||
const util::geo::DPoint& p, double maxD,
|
||||
int maxFullTurns, double minAngle) const {
|
||||
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, BlockSearch());
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
Node* OsmBuilder::eqStatReach(const Edge* e, const StatInfo* si,
|
||||
const util::geo::FPoint& p, double maxD,
|
||||
const util::geo::DPoint& p, double maxD,
|
||||
int maxFullTurns, double minAngle) const {
|
||||
return depthSearch(e, si, p, maxD, maxFullTurns, minAngle, EqSearch());
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
void OsmBuilder::getEdgCands(const FPoint& geom, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||
void OsmBuilder::getEdgCands(const DPoint& geom, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||
double d) const {
|
||||
double distor = webMercDistFactor(geom);
|
||||
std::set<Edge*> neighs;
|
||||
Box<float> box = util::geo::pad(util::geo::getBoundingBox(geom), d / distor);
|
||||
Box<double> box = util::geo::pad(util::geo::getBoundingBox(geom), d / distor);
|
||||
eg->get(box, &neighs);
|
||||
|
||||
for (auto* e : neighs) {
|
||||
|
@ -1186,7 +1186,7 @@ std::set<Node*> OsmBuilder::getMatchingNds(const NodePL& s, NodeGrid* ng,
|
|||
std::set<Node*> ret;
|
||||
double distor = webMercDistFactor(*s.getGeom());
|
||||
std::set<Node*> neighs;
|
||||
Box<float> box =
|
||||
Box<double> box =
|
||||
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
||||
ng->get(box, &neighs);
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ std::set<Node*> OsmBuilder::getMatchingNds(const NodePL& s, NodeGrid* ng,
|
|||
Node* OsmBuilder::getMatchingNd(const NodePL& s, NodeGrid* ng, double d) const {
|
||||
double distor = webMercDistFactor(*s.getGeom());
|
||||
std::set<Node*> neighs;
|
||||
Box<float> box =
|
||||
Box<double> box =
|
||||
util::geo::pad(util::geo::getBoundingBox(*s.getGeom()), d / distor);
|
||||
ng->get(box, &neighs);
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
|||
|
||||
auto ne = g->addEdg(e->getFrom(), n, e->pl());
|
||||
ne->pl().setLength(webMercDist(n, e->getFrom()));
|
||||
FLine l;
|
||||
DLine l;
|
||||
l.push_back(*e->getFrom()->pl().getGeom());
|
||||
l.push_back(*n->pl().getGeom());
|
||||
*ne->pl().getGeom() = l;
|
||||
|
@ -1290,7 +1290,7 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
|||
|
||||
auto nf = g->addEdg(n, e->getTo(), e->pl());
|
||||
nf->pl().setLength(webMercDist(n, e->getTo()));
|
||||
FLine ll;
|
||||
DLine ll;
|
||||
ll.push_back(*n->pl().getGeom());
|
||||
ll.push_back(*e->getTo()->pl().getGeom());
|
||||
*nf->pl().getGeom() = ll;
|
||||
|
|
|
@ -162,7 +162,7 @@ class OsmBuilder {
|
|||
OsmRel nextRel(xml::File* xml, const OsmFilter& filter,
|
||||
const AttrKeySet& keepAttrs) const;
|
||||
|
||||
Nullable<StatInfo> getStatInfo(Node* node, osmid nid, const FPoint& pos,
|
||||
Nullable<StatInfo> getStatInfo(Node* node, osmid nid, const DPoint& pos,
|
||||
const AttrMap& m, StAttrGroups* groups,
|
||||
const RelMap& nodeRels, const RelLst& rels,
|
||||
const OsmReadOpts& ops) const;
|
||||
|
@ -172,14 +172,14 @@ class OsmBuilder {
|
|||
void deleteOrphEdgs(Graph* g) const;
|
||||
double dist(const Node* a, const Node* b) const;
|
||||
double webMercDist(const Node* a, const Node* b) const;
|
||||
double webMercDistFactor(const FPoint& a) const;
|
||||
double webMercDistFactor(const DPoint& a) const;
|
||||
|
||||
NodeGrid buildNodeIdx(Graph* g, size_t size,
|
||||
const util::geo::Box<float>& webMercBox,
|
||||
const util::geo::Box<double>& webMercBox,
|
||||
bool which) const;
|
||||
|
||||
EdgeGrid buildEdgeIdx(Graph* g, size_t size,
|
||||
const util::geo::Box<float>& webMercBox) const;
|
||||
const util::geo::Box<double>& webMercBox) const;
|
||||
|
||||
void fixGaps(Graph* g, NodeGrid* ng) const;
|
||||
void collapseEdges(Graph* g) const;
|
||||
|
@ -190,7 +190,7 @@ class OsmBuilder {
|
|||
uint32_t writeComps(Graph* g) const;
|
||||
bool edgesSim(const Edge* a, const Edge* b) const;
|
||||
const EdgePL& mergeEdgePL(Edge* a, Edge* b) const;
|
||||
void getEdgCands(const FPoint& s, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||
void getEdgCands(const DPoint& s, EdgeCandPQ* ret, EdgeGrid* eg,
|
||||
double d) const;
|
||||
|
||||
std::set<Node*> getMatchingNds(const NodePL& s, NodeGrid* ng, double d) const;
|
||||
|
@ -204,14 +204,14 @@ class OsmBuilder {
|
|||
// 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
|
||||
// such a station exists, it is returned. If not, 0 is returned.
|
||||
Node* eqStatReach(const Edge* e, const StatInfo* si, const FPoint& p,
|
||||
Node* eqStatReach(const Edge* e, const StatInfo* si, const DPoint& p,
|
||||
double maxD, int maxFullTurns, double maxAng) const;
|
||||
|
||||
Node* depthSearch(const Edge* e, const StatInfo* si,
|
||||
const util::geo::FPoint& p, double maxD, int maxFullTurns,
|
||||
const DPoint& p, double maxD, int maxFullTurns,
|
||||
double minAngle, const SearchFunc& sfunc) const;
|
||||
|
||||
bool isBlocked(const Edge* e, const StatInfo* si, const FPoint& p,
|
||||
bool isBlocked(const Edge* e, const StatInfo* si, const DPoint& p,
|
||||
double maxD, int maxFullTurns, double minAngle) const;
|
||||
|
||||
StatGroup* groupStats(const NodeSet& s) const;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) *
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include "pfaedle/trgraph/EdgePL.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
||||
using pfaedle::trgraph::EdgePL;
|
||||
using pfaedle::trgraph::TransitEdgeLine;
|
||||
using util::geo::DLine;
|
||||
|
||||
std::map<util::geo::FLine*, size_t> EdgePL::_flines;
|
||||
std::map<DLine*, size_t> EdgePL::_flines;
|
||||
std::map<const TransitEdgeLine*, size_t> EdgePL::_tlines;
|
||||
|
||||
// _____________________________________________________________________________
|
||||
EdgePL::EdgePL()
|
||||
: _length(0), _oneWay(0), _hasRestr(false), _rev(false), _lvl(0) {
|
||||
_l = new util::geo::FLine();
|
||||
_l = new DLine();
|
||||
_flines[_l] = 1;
|
||||
}
|
||||
|
||||
|
@ -33,7 +35,7 @@ EdgePL::EdgePL(const EdgePL& pl, bool geoflat)
|
|||
if (geoflat) {
|
||||
_l = pl._l;
|
||||
} else {
|
||||
_l = new util::geo::FLine(*pl._l);
|
||||
_l = new DLine(*pl._l);
|
||||
}
|
||||
_flines[_l]++;
|
||||
|
||||
|
@ -99,13 +101,13 @@ const std::set<const TransitEdgeLine*>& EdgePL::getLines() const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
void EdgePL::addPoint(const util::geo::FPoint& p) { _l->push_back(p); }
|
||||
void EdgePL::addPoint(const util::geo::DPoint& p) { _l->push_back(p); }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const util::geo::FLine* EdgePL::getGeom() const { return _l; }
|
||||
const DLine* EdgePL::getGeom() const { return _l; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
util::geo::FLine* EdgePL::getGeom() { return _l; }
|
||||
DLine* EdgePL::getGeom() { return _l; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
util::json::Dict EdgePL::getAttrs() const {
|
||||
|
@ -160,7 +162,7 @@ void EdgePL::setRev() { _rev = true; }
|
|||
bool EdgePL::isRev() const { return _rev; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const util::geo::FPoint& EdgePL::backHop() const {
|
||||
const util::geo::DPoint& EdgePL::backHop() const {
|
||||
if (isRev()) {
|
||||
return *(++(getGeom()->cbegin()));
|
||||
}
|
||||
|
@ -168,7 +170,7 @@ const util::geo::FPoint& EdgePL::backHop() const {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const util::geo::FPoint& EdgePL::frontHop() const {
|
||||
const util::geo::DPoint& EdgePL::frontHop() const {
|
||||
if (isRev()) {
|
||||
return *(++(getGeom()->crbegin()));
|
||||
}
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
#include "util/geo/GeoGraph.h"
|
||||
|
||||
using util::geograph::GeoEdgePL;
|
||||
using util::geo::DLine;
|
||||
using util::geo::DPoint;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace trgraph {
|
||||
|
||||
|
||||
/*
|
||||
* A line occuring on an edge
|
||||
*/
|
||||
|
@ -42,7 +43,7 @@ inline bool operator<(const TransitEdgeLine& a, const TransitEdgeLine& b) {
|
|||
/*
|
||||
* An edge payload class for the transit graph.
|
||||
*/
|
||||
class EdgePL : public GeoEdgePL<float> {
|
||||
class EdgePL : public GeoEdgePL<double> {
|
||||
public:
|
||||
EdgePL();
|
||||
~EdgePL();
|
||||
|
@ -50,11 +51,11 @@ class EdgePL : public GeoEdgePL<float> {
|
|||
EdgePL(const EdgePL& pl, bool geoFlat);
|
||||
|
||||
// Return the geometry of this edge.
|
||||
const util::geo::FLine* getGeom() const;
|
||||
util::geo::FLine* getGeom();
|
||||
const DLine* getGeom() const;
|
||||
DLine* getGeom();
|
||||
|
||||
// Extends this edge payload's geometry by Point p
|
||||
void addPoint(const util::geo::FPoint& p);
|
||||
void addPoint(const DPoint& p);
|
||||
|
||||
// Fill obj with k/v pairs describing the parameters of this payload.
|
||||
util::json::Dict getAttrs() const;
|
||||
|
@ -102,11 +103,11 @@ class EdgePL : public GeoEdgePL<float> {
|
|||
|
||||
// Returns the last hop of the payload - this is the (n-2)th point in
|
||||
// the payload geometry of length n > 1
|
||||
const util::geo::FPoint& backHop() const;
|
||||
const DPoint& backHop() const;
|
||||
|
||||
// Returns the first hop of the payload - this is the 2nd point in
|
||||
// the payload geometry of length n > 1
|
||||
const util::geo::FPoint& frontHop() const;
|
||||
const DPoint& frontHop() const;
|
||||
|
||||
// Obtain an exact copy of this edge, but in reverse.
|
||||
EdgePL revCopy() const;
|
||||
|
@ -118,13 +119,13 @@ class EdgePL : public GeoEdgePL<float> {
|
|||
bool _rev : 1;
|
||||
uint8_t _lvl : 3;
|
||||
|
||||
util::geo::FLine* _l;
|
||||
DLine* _l;
|
||||
|
||||
std::set<const TransitEdgeLine*> _lines;
|
||||
|
||||
static void unRefTLine(const TransitEdgeLine* l);
|
||||
|
||||
static std::map<util::geo::FLine*, size_t> _flines;
|
||||
static std::map<DLine*, size_t> _flines;
|
||||
static std::map<const TransitEdgeLine*, size_t> _tlines;
|
||||
};
|
||||
} // namespace trgraph
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
using util::geo::Grid;
|
||||
using util::geo::Point;
|
||||
using util::geo::Line;
|
||||
using util::geo::FPoint;
|
||||
using util::geo::FLine;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace trgraph {
|
||||
|
@ -26,8 +24,8 @@ namespace trgraph {
|
|||
typedef util::graph::Edge<NodePL, EdgePL> Edge;
|
||||
typedef util::graph::Node<NodePL, EdgePL> Node;
|
||||
typedef util::graph::DirGraph<NodePL, EdgePL> Graph;
|
||||
typedef Grid<Node*, Point, float> NodeGrid;
|
||||
typedef Grid<Edge*, Line, float> EdgeGrid;
|
||||
typedef Grid<Node*, Point, double> NodeGrid;
|
||||
typedef Grid<Edge*, Line, double> EdgeGrid;
|
||||
|
||||
} // namespace trgraph
|
||||
} // namespace pfaedle
|
||||
|
|
|
@ -46,7 +46,7 @@ NodePL::NodePL(const NodePL& pl)
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
NodePL::NodePL(const util::geo::FPoint& geom)
|
||||
NodePL::NodePL(const DPoint& geom)
|
||||
: _geom(geom),
|
||||
_si(0),
|
||||
_component(0)
|
||||
|
@ -58,7 +58,7 @@ NodePL::NodePL(const util::geo::FPoint& geom)
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
NodePL::NodePL(const util::geo::FPoint& geom, const StatInfo& si)
|
||||
NodePL::NodePL(const DPoint& geom, const StatInfo& si)
|
||||
: _geom(geom),
|
||||
_si(0),
|
||||
_component(0)
|
||||
|
@ -108,10 +108,10 @@ void NodePL::setComp(const Component* c) {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
const util::geo::FPoint* NodePL::getGeom() const { return &_geom; }
|
||||
const DPoint* NodePL::getGeom() const { return &_geom; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
void NodePL::setGeom(const util::geo::FPoint& geom) { _geom = geom; }
|
||||
void NodePL::setGeom(const DPoint& geom) { _geom = geom; }
|
||||
|
||||
// _____________________________________________________________________________
|
||||
util::json::Dict NodePL::getAttrs() const {
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||
#include "pfaedle/trgraph/StatInfo.h"
|
||||
#include "util/geo/GeoGraph.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
||||
using util::geograph::GeoNodePL;
|
||||
using util::geo::DPoint;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace trgraph {
|
||||
|
@ -24,17 +26,17 @@ struct Component {
|
|||
/*
|
||||
* A node payload class for the transit graph.
|
||||
*/
|
||||
class NodePL : public GeoNodePL<float> {
|
||||
class NodePL : public GeoNodePL<double> {
|
||||
public:
|
||||
NodePL();
|
||||
NodePL(const NodePL& pl); // NOLINT
|
||||
NodePL(const util::geo::FPoint& geom); // NOLINT
|
||||
NodePL(const util::geo::FPoint& geom, const StatInfo& si);
|
||||
NodePL(const DPoint& geom); // NOLINT
|
||||
NodePL(const DPoint& geom, const StatInfo& si);
|
||||
~NodePL();
|
||||
|
||||
// Return the geometry of this node.
|
||||
const util::geo::FPoint* getGeom() const;
|
||||
void setGeom(const util::geo::FPoint& geom);
|
||||
const DPoint* getGeom() const;
|
||||
void setGeom(const DPoint& geom);
|
||||
|
||||
// Fill obj with k/v pairs describing the parameters of this payload.
|
||||
util::json::Dict getAttrs() const;
|
||||
|
@ -66,8 +68,7 @@ class NodePL : public GeoNodePL<float> {
|
|||
void setVisited() const;
|
||||
|
||||
private:
|
||||
// 32bit floats are enough here
|
||||
util::geo::FPoint _geom;
|
||||
DPoint _geom;
|
||||
StatInfo* _si;
|
||||
const Component* _component;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ double StatGroup::getPen(const Stop* s, trgraph::Node* n,
|
|||
const trgraph::Normalizer& platformNorm,
|
||||
double trackPen, double distPenFac,
|
||||
double nonOsmPen) const {
|
||||
FPoint p = util::geo::latLngToWebMerc<float>(s->getLat(), s->getLng());
|
||||
DPoint p = util::geo::latLngToWebMerc<double>(s->getLat(), s->getLng());
|
||||
|
||||
double distPen = util::geo::webMercMeterDist(p, *n->pl().getGeom());
|
||||
distPen *= distPenFac;
|
||||
|
|
|
@ -174,20 +174,20 @@ inline std::vector<Geometry<T>> rotate(std::vector<Geometry<T>> multigeo,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline Point<T> move(const Point<T>& geo, T x, T y) {
|
||||
inline Point<T> move(const Point<T>& geo, double x, double y) {
|
||||
return Point<T>(geo.getX() + x, geo.getY() + y);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline Line<T> move(Line<T> geo, T x, T y) {
|
||||
inline Line<T> move(Line<T> geo, double x, double y) {
|
||||
for (size_t i = 0; i < geo.size(); i++) geo[i] = move(geo[i], x, y);
|
||||
return geo;
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline LineSegment<T> move(LineSegment<T> geo, T x, T y) {
|
||||
inline LineSegment<T> move(LineSegment<T> geo, double x, double y) {
|
||||
geo.first = move(geo.first, x, y);
|
||||
geo.second = move(geo.second, x, y);
|
||||
return geo;
|
||||
|
@ -195,7 +195,7 @@ inline LineSegment<T> move(LineSegment<T> geo, T x, T y) {
|
|||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline Polygon<T> move(Polygon<T> geo, T x, T y) {
|
||||
inline Polygon<T> move(Polygon<T> geo, double x, double y) {
|
||||
for (size_t i = 0; i < geo.getOuter().size(); i++)
|
||||
geo.getOuter()[i] = move(geo.getOuter()[i], x, y);
|
||||
return geo;
|
||||
|
@ -203,8 +203,8 @@ inline Polygon<T> move(Polygon<T> geo, T x, T y) {
|
|||
|
||||
// _____________________________________________________________________________
|
||||
template <template <typename> class Geometry, typename T>
|
||||
inline std::vector<Geometry<T>> move(std::vector<Geometry<T>> multigeo, T x,
|
||||
T y) {
|
||||
inline std::vector<Geometry<T>> move(std::vector<Geometry<T>> multigeo, double x,
|
||||
double y) {
|
||||
for (size_t i = 0; i < multigeo.size(); i++)
|
||||
multigeo[i] = move(multigeo[i], x, y);
|
||||
return multigeo;
|
||||
|
@ -536,8 +536,8 @@ inline bool intersects(const Box<T>& b, const Point<T>& p) {
|
|||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline Point<T> intersection(T p1x, T p1y, T q1x, T q1y, T p2x, T p2y, T q2x,
|
||||
T q2y) {
|
||||
inline Point<T> intersection(double p1x, double p1y, double q1x, double q1y, double p2x, double p2y, double q2x,
|
||||
double q2y) {
|
||||
/*
|
||||
* calculates the intersection between two line segments
|
||||
*/
|
||||
|
@ -574,8 +574,8 @@ inline Point<T> intersection(const LineSegment<T>& s1,
|
|||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline bool lineIntersects(T p1x, T p1y, T q1x, T q1y, T p2x, T p2y, T q2x,
|
||||
T q2y) {
|
||||
inline bool lineIntersects(double p1x, double p1y, double q1x, double q1y, double p2x, double p2y, double q2x,
|
||||
double q2y) {
|
||||
/*
|
||||
* checks whether two lines intersect
|
||||
*/
|
||||
|
@ -953,7 +953,7 @@ inline Point<T> projectOn(const Point<T>& a, const Point<T>& b,
|
|||
if (doubleEq(a.getX(), c.getX()) && doubleEq(a.getY(), c.getY())) return a;
|
||||
if (doubleEq(b.getX(), c.getX()) && doubleEq(b.getY(), c.getY())) return b;
|
||||
|
||||
T x, y;
|
||||
double x, y;
|
||||
|
||||
if (c.getX() == a.getX()) {
|
||||
// infinite slope
|
||||
|
@ -1266,10 +1266,10 @@ inline double area(const Polygon<T>& b) {
|
|||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline double commonArea(const Box<T>& ba, const Box<T>& bb) {
|
||||
T l = std::max(ba.getLowerLeft().getX(), bb.getLowerLeft().getX());
|
||||
T r = std::min(ba.getUpperRight().getX(), bb.getUpperRight().getX());
|
||||
T b = std::max(ba.getLowerLeft().getY(), bb.getLowerLeft().getY());
|
||||
T t = std::min(ba.getUpperRight().getY(), bb.getUpperRight().getY());
|
||||
double l = std::max(ba.getLowerLeft().getX(), bb.getLowerLeft().getX());
|
||||
double r = std::min(ba.getUpperRight().getX(), bb.getUpperRight().getX());
|
||||
double b = std::max(ba.getLowerLeft().getY(), bb.getLowerLeft().getY());
|
||||
double t = std::min(ba.getUpperRight().getY(), bb.getUpperRight().getY());
|
||||
|
||||
if (l > r || b > t) return 0;
|
||||
return (r - l) * (t - b);
|
||||
|
|
Loading…
Reference in a new issue