use double precision
This commit is contained in:
parent
967963e180
commit
486a8136fd
24 changed files with 186 additions and 177 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue