make geometry precision configurable for build
This commit is contained in:
parent
486a8136fd
commit
8446db5c4b
25 changed files with 222 additions and 208 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||
#include "pfaedle/Def.h"
|
||||
#include "pfaedle/eval/Collector.h"
|
||||
#include "pfaedle/eval/Result.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
|
@ -15,9 +16,8 @@
|
|||
#include "util/geo/output/GeoJsonOutput.h"
|
||||
#include "util/log/Log.h"
|
||||
|
||||
using util::geo::DLine;
|
||||
using util::geo::PolyLine;
|
||||
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;
|
||||
DLine oldL = getWebMercLine(
|
||||
LINE oldL = getWebMercLine(
|
||||
oldS, t->getStopTimes().begin()->getShapeDistanceTravelled(),
|
||||
(--t->getStopTimes().end())->getShapeDistanceTravelled(), &oldDists);
|
||||
|
||||
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");
|
||||
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<double> oldStart = oldSegs[0];
|
||||
PolyLine<double> newStart = newSegs[0];
|
||||
POLYLINE oldStart = oldSegs[0];
|
||||
POLYLINE 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<double> oldEnd = oldSegs[oldSegs.size() - 1];
|
||||
PolyLine<double> newEnd = newSegs[oldSegs.size() - 1];
|
||||
POLYLINE oldEnd = oldSegs[oldSegs.size() - 1];
|
||||
POLYLINE 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
|
||||
DLine oldLCut;
|
||||
DLine newLCut;
|
||||
LINE oldLCut;
|
||||
LINE newLCut;
|
||||
|
||||
for (auto oldL : oldSegs) {
|
||||
gjout.print(oldL, util::json::Dict{{"ver", "old"}});
|
||||
|
|
@ -166,32 +166,31 @@ double Collector::add(const Trip* t, const Shape* oldS, const Shape* newS,
|
|||
<< " A_L/L = " << unmatchedSegmentsLength << "/" << totL << " = "
|
||||
<< unmatchedSegmentsLength / totL << " d_f = " << fd;
|
||||
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
std::vector<DLine> Collector::segmentize(
|
||||
const Trip* t, const DLine& shape, const std::vector<double>& dists,
|
||||
std::vector<LINE> Collector::segmentize(
|
||||
const Trip* t, const LINE& shape, const std::vector<double>& dists,
|
||||
const std::vector<double>* newTripDists) {
|
||||
std::vector<DLine> ret;
|
||||
std::vector<LINE> ret;
|
||||
|
||||
if (t->getStopTimes().size() < 2) return ret;
|
||||
|
||||
util::geo::PolyLine<double> pl(shape);
|
||||
std::vector<std::pair<DPoint, double> > cuts;
|
||||
POLYLINE pl(shape);
|
||||
std::vector<std::pair<POINT, double> > cuts;
|
||||
|
||||
size_t i = 0;
|
||||
for (auto st : t->getStopTimes()) {
|
||||
if (newTripDists) {
|
||||
cuts.push_back(std::pair<DPoint, double>(
|
||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
cuts.push_back(std::pair<POINT, double>(
|
||||
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
(*newTripDists)[i]));
|
||||
} else {
|
||||
cuts.push_back(std::pair<DPoint, double>(
|
||||
util::geo::latLngToWebMerc<double>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
cuts.push_back(std::pair<POINT, double>(
|
||||
util::geo::latLngToWebMerc<PFAEDLE_PRECISION>(st.getStop()->getLat(),
|
||||
st.getStop()->getLng()),
|
||||
st.getShapeDistanceTravelled()));
|
||||
}
|
||||
i++;
|
||||
|
|
@ -200,8 +199,7 @@ std::vector<DLine> 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<double> l(
|
||||
DLine(shape.begin(), shape.begin() + before + 1));
|
||||
POLYLINE l(LINE(shape.begin(), shape.begin() + before + 1));
|
||||
auto lastLp = l.projectOn(cuts.front().first);
|
||||
|
||||
for (size_t i = 1; i < cuts.size(); i++) {
|
||||
|
|
@ -212,8 +210,7 @@ std::vector<DLine> Collector::segmentize(
|
|||
dists.begin();
|
||||
}
|
||||
|
||||
util::geo::PolyLine<double> beforePl(
|
||||
DLine(shape.begin(), shape.begin() + before));
|
||||
POLYLINE beforePl(LINE(shape.begin(), shape.begin() + before));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
DLine Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists) {
|
||||
DLine ret;
|
||||
LINE Collector::getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists) {
|
||||
LINE ret;
|
||||
|
||||
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 (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);
|
||||
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,
|
||||
const std::vector<DLine>& b) {
|
||||
std::pair<size_t, double> Collector::getDa(const std::vector<LINE>& a,
|
||||
const std::vector<LINE>& b) {
|
||||
assert(a.size() == b.size());
|
||||
std::pair<size_t, double> ret{0, 0};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
#include "ad/cppgtfs/gtfs/Feed.h"
|
||||
#include "pfaedle/Def.h"
|
||||
#include "pfaedle/eval/Result.h"
|
||||
#include "util/geo/Geo.h"
|
||||
|
||||
using ad::cppgtfs::gtfs::Trip;
|
||||
using ad::cppgtfs::gtfs::Shape;
|
||||
using util::geo::DLine;
|
||||
|
||||
namespace pfaedle {
|
||||
namespace eval {
|
||||
|
|
@ -57,9 +57,9 @@ class Collector {
|
|||
// Return the averaged average frechet distance
|
||||
double getAvgDist() const;
|
||||
|
||||
static DLine getWebMercLine(const Shape* s, double from, double to);
|
||||
static DLine getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists);
|
||||
static LINE getWebMercLine(const Shape* s, double from, double to);
|
||||
static LINE getWebMercLine(const Shape* s, double from, double to,
|
||||
std::vector<double>* dists);
|
||||
|
||||
private:
|
||||
std::set<Result> _results;
|
||||
|
|
@ -78,12 +78,12 @@ class Collector {
|
|||
|
||||
std::vector<double> _dfBins;
|
||||
|
||||
static std::pair<size_t, double> getDa(const std::vector<DLine>& a,
|
||||
const std::vector<DLine>& b);
|
||||
static std::pair<size_t, double> getDa(const std::vector<LINE>& a,
|
||||
const std::vector<LINE>& b);
|
||||
|
||||
static std::vector<DLine> segmentize(const Trip* t, const DLine& shape,
|
||||
const std::vector<double>& dists,
|
||||
const std::vector<double>* newTripDists);
|
||||
static std::vector<LINE> segmentize(const Trip* t, const LINE& shape,
|
||||
const std::vector<double>& dists,
|
||||
const std::vector<double>* newTripDists);
|
||||
|
||||
static std::vector<double> getBins(double mind, double maxd, size_t steps);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue