* speed up hop-to-hop calculations
* better and faster trip clustering: trip tries * add --write-colors to extract line colors from OSM data * refactor config parameter names, update default pfaedle.cfg * add --stats for writing a stats.json file * add --no-fast-hops, --no-a-star, --no-trie for debugging * general refactoring
This commit is contained in:
parent
f1822868c5
commit
4c29892658
126 changed files with 14576 additions and 12196 deletions
|
|
@ -11,7 +11,8 @@ Grid<V, G, T>::Grid(bool bldIdx)
|
|||
_cellHeight(0),
|
||||
_xWidth(0),
|
||||
_yHeight(0),
|
||||
_hasValIdx(bldIdx) {}
|
||||
_hasValIdx(bldIdx),
|
||||
_grid(0) {}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
template <typename V, template <typename> class G, typename T>
|
||||
|
|
@ -28,11 +29,10 @@ Grid<V, G, T>::Grid(double w, double h, const Box<T>& bbox, bool bValIdx)
|
|||
: _cellWidth(fabs(w)),
|
||||
_cellHeight(fabs(h)),
|
||||
_bb(bbox),
|
||||
_hasValIdx(bValIdx) {
|
||||
_width =
|
||||
bbox.getUpperRight().getX() - bbox.getLowerLeft().getX();
|
||||
_height =
|
||||
bbox.getUpperRight().getY() - bbox.getLowerLeft().getY();
|
||||
_hasValIdx(bValIdx),
|
||||
_grid(0) {
|
||||
_width = bbox.getUpperRight().getX() - bbox.getLowerLeft().getX();
|
||||
_height = bbox.getUpperRight().getY() - bbox.getLowerLeft().getY();
|
||||
|
||||
if (_width < 0 || _height < 0) {
|
||||
_width = 0;
|
||||
|
|
@ -46,11 +46,11 @@ Grid<V, G, T>::Grid(double w, double h, const Box<T>& bbox, bool bValIdx)
|
|||
_yHeight = ceil(_height / _cellHeight);
|
||||
|
||||
// resize rows
|
||||
_grid.resize(_xWidth);
|
||||
_grid = new std::set<V>*[_xWidth];
|
||||
|
||||
// resize columns
|
||||
for (size_t i = 0; i < _xWidth; i++) {
|
||||
_grid[i].resize(_yHeight);
|
||||
for (size_t x = 0; x < _xWidth; x++) {
|
||||
_grid[x] = new std::set<V>[_yHeight];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ void Grid<V, G, T>::add(G<T> geom, V val) {
|
|||
size_t neX = getCellXFromX(box.getUpperRight().getX());
|
||||
size_t neY = getCellYFromY(box.getUpperRight().getY());
|
||||
|
||||
for (size_t x = swX; x <= neX && x < _grid.size(); x++) {
|
||||
for (size_t y = swY; y <= neY && y < _grid[x].size(); y++) {
|
||||
for (size_t x = swX; x <= neX && x < _xWidth; x++) {
|
||||
for (size_t y = swY; y <= neY && y < _yHeight; y++) {
|
||||
if (intersects(geom, getBox(x, y))) {
|
||||
add(x, y, val);
|
||||
}
|
||||
|
|
@ -97,24 +97,23 @@ void Grid<V, G, T>::get(const Box<T>& box, std::set<V>* s) const {
|
|||
template <typename V, template <typename> class G, typename T>
|
||||
void Grid<V, G, T>::get(const G<T>& geom, double d, std::set<V>* s) const {
|
||||
Box<T> a = getBoundingBox(geom);
|
||||
Box<T> b(Point<T>(a.getLowerLeft().getX() - d,
|
||||
a.getLowerLeft().getY() - d),
|
||||
Point<T>(a.getUpperRight().getX() + d,
|
||||
a.getUpperRight().getY() + d));
|
||||
Box<T> b(
|
||||
Point<T>(a.getLowerLeft().getX() - d, a.getLowerLeft().getY() - d),
|
||||
Point<T>(a.getUpperRight().getX() + d, a.getUpperRight().getY() + d));
|
||||
return get(b, s);
|
||||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
template <typename V, template <typename> class G, typename T>
|
||||
void Grid<V, G, T>::get(size_t x, size_t y, std::set<V>* s) const {
|
||||
if (_hasValIdx) {
|
||||
if (_hasValIdx || _removed.size() == 0) {
|
||||
s->insert(_grid[x][y].begin(), _grid[x][y].end());
|
||||
} else {
|
||||
// if we dont have a value index, we have a set of deleted nodes.
|
||||
// in this case, only insert if not deleted
|
||||
std::copy_if(_grid[x][y].begin(), _grid[x][y].end(),
|
||||
std::inserter(*s, s->end()),
|
||||
[&](const V& v) { return Grid<V, G, T>::_removed.count(v) == 0; });
|
||||
std::copy_if(
|
||||
_grid[x][y].begin(), _grid[x][y].end(), std::inserter(*s, s->end()),
|
||||
[&](const V& v) { return Grid<V, G, T>::_removed.count(v) == 0; });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue