generate-shapes/src/pfaedle/gtfs/ShapeContainer.h
Patrick Brosi 63f0b61ea1 clean up and refactor half-baked development commits and squash them into a new version.
Changes:

* support for multiple GTFS feeds as input in filtering, read default global and local configuration files
* be a bit more memory conservative
* make caching optional
* dont delete orphan edge if it would transform a degree 3 node with a possible full turn into a degree 2 node eligible for contraction
* dedicated filters for funicular and gondola
* make max snap level option more intuitive
* allow filter rules for level 0
* additional fallback for station snapping
* dont try to route for MOT unequal to trip in -T mode, force-snap to orphaned OSM station if not snap was possible
* write bounds to filtered osm
* remove unused surrounding heuristic
* use bus lanes info
* be a bit more tolerant for bus oneway streets
* create missing directories
* error if no cfg is present, clean up evaluation Makefile
2019-01-12 01:08:13 +01:00

70 lines
1.5 KiB
C++

// Copyright 2018, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifndef PFAEDLE_GTFS_SHAPECONTAINER_H_
#define PFAEDLE_GTFS_SHAPECONTAINER_H_
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include "ad/cppgtfs/gtfs/Shape.h"
#include "ad/cppgtfs/gtfs/flat/Shape.h"
#include "util/Misc.h"
namespace pfaedle {
namespace gtfs {
struct Shape {
explicit Shape(const std::string& id) : id(id) {}
typedef std::string Ref;
static std::string getId(Ref r) { return r; }
template <typename T>
bool addPoint(T p) {
UNUSED(p);
return true;
}
const std::string& getId() const { return id; }
std::string id;
};
template <typename T>
class ShapeContainer {
public:
ShapeContainer();
~ShapeContainer();
T* add(const T& obj);
bool remove(const std::string& id);
const T* get(const std::string& id) const;
T* get(const std::string& id);
const std::string getRef(const std::string& id) const;
std::string getRef(const std::string& id);
size_t size() const;
void finalize() {}
bool has(const std::string& id) const;
std::string add(const ad::cppgtfs::gtfs::Shape& s);
void open();
bool nextStoragePt(ad::cppgtfs::gtfs::flat::ShapePoint* ret);
private:
std::set<std::string> _ids;
std::fstream _storage;
size_t _ptr;
size_t _max;
std::string _curId;
std::stringstream _writeBuffer;
};
#include "ShapeContainer.tpp"
} // namespace gtfs
} // namespace pfaedle
#endif // PFAEDLE_GTFS_SHAPECONTAINER_H_