Skip to content

Commit

Permalink
make box padding configurable via -b [ --box-padding ], also change d…
Browse files Browse the repository at this point in the history
…efault box padding from 2500 meters to 20000 meters, this should fix #58
  • Loading branch information
patrickbr committed Oct 31, 2024
1 parent 0871301 commit 3ad6215
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/pfaedle/Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
#define BOX util::geo::Box<PFDL_PREC>
#define POLYLINE util::geo::PolyLine<PFDL_PREC>

#define BOX_PADDING 2500

#endif // PFAEDLE_DEF_H_
8 changes: 4 additions & 4 deletions src/pfaedle/PfaedleMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int main(int argc, char** argv) {

if (cfg.writeOsm.size()) {
LOG(INFO) << "Writing filtered XML to " << cfg.writeOsm << " ...";
BBoxIdx box(BOX_PADDING);
BBoxIdx box(cfg.boxPadding);

for (size_t i = 0; i < cfg.feedPaths.size(); i++) {
ShapeBuilder::getGtfsBox(&gtfs[i], cmdCfgMots, cfg.shapeTripId, true,
Expand All @@ -216,7 +216,7 @@ int main(int argc, char** argv) {
}
exit(static_cast<int>(RetCode::SUCCESS));
} else if (cfg.writeOverpass) {
BBoxIdx box(BOX_PADDING);
BBoxIdx box(cfg.boxPadding);
for (size_t i = 0; i < cfg.feedPaths.size(); i++) {
ShapeBuilder::getGtfsBox(&gtfs[i], cmdCfgMots, cfg.shapeTripId, true,
&box, maxSpeed, 0, cfg.verbosity);
Expand All @@ -232,7 +232,7 @@ int main(int argc, char** argv) {
osmBuilder.overpassQryWrite(&std::cout, opts, box);
exit(static_cast<int>(RetCode::SUCCESS));
} else if (cfg.writeOsmfilter) {
BBoxIdx box(BOX_PADDING);
BBoxIdx box(cfg.boxPadding);
OsmBuilder osmBuilder;
std::vector<pfaedle::osm::OsmReadOpts> opts;
for (const auto& o : motCfgReader.getConfigs()) {
Expand Down Expand Up @@ -273,7 +273,7 @@ int main(int argc, char** argv) {
pfaedle::trgraph::Graph graph;
pfaedle::osm::OsmBuilder osmBuilder;

pfaedle::osm::BBoxIdx box(BOX_PADDING);
pfaedle::osm::BBoxIdx box(cfg.boxPadding);
ShapeBuilder::getGtfsBox(
&gtfs[0], usedMots, cfg.shapeTripId, cfg.dropShapes, &box,
motCfg.osmBuildOpts.maxSpeed, &hopDists, cfg.verbosity);
Expand Down
12 changes: 10 additions & 2 deletions src/pfaedle/config/ConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void ConfigReader::help(const char* bin) {
<< "pfaedle config file\n"
<< std::setw(35) << " -i [ --input ] arg"
<< "gtfs feed(s), may also be given as positional\n"
<< std::setw(35) << " -F [ --keep-additional-gtfs-fields ] arg"
<< "keep additional non-standard feeds in GTFS input\n"
<< std::setw(35) << " "
<< " parameter (see usage)\n"
<< std::setw(35) << " -x [ --osm-file ] arg"
Expand Down Expand Up @@ -99,8 +101,10 @@ void ConfigReader::help(const char* bin) {
<< "Output overpass query for matching OSM data\n"
<< std::setw(35) << " --osmfilter"
<< "Output osmfilter filter rules for matching OSM data\n"
<< std::setw(35) << " --grid-size arg (=2000)"
<< std::setw(35) << " -g [ --grid-size ] arg (=2000)"
<< "Approx. grid cell size in meters\n"
<< std::setw(35) << " -b [ --box-padding ] arg (=20000)"
<< "Padding of bounding box used to crop input OSM data in meters\n"
<< std::setw(35) << " --no-fast-hops"
<< "Disable fast hops technique\n"
<< std::setw(35) << " --no-a-star"
Expand Down Expand Up @@ -129,6 +133,7 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
{"drop-shapes", required_argument, 0, 'D'},
{"mots", required_argument, NULL, 'm'},
{"grid-size", required_argument, 0, 'g'},
{"box-padding", required_argument, 0, 'b'},
{"overpass", no_argument, 0, 'a'},
{"osmfilter", no_argument, 0, 'f'},
{"osm-out", required_argument, 0, 'X'},
Expand All @@ -151,7 +156,7 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
{0, 0, 0, 0}};

int c;
while ((c = getopt_long(argc, argv, ":o:hvi:c:x:Dm:g:X:T:d:pP:FW", ops, 0)) !=
while ((c = getopt_long(argc, argv, ":o:hvi:c:x:Dm:g:X:T:d:pP:FWb:", ops, 0)) !=
-1) {
switch (c) {
case 1:
Expand Down Expand Up @@ -190,6 +195,9 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
case 'g':
cfg->gridSize = atof(optarg) / util::geo::M_PER_DEG;
break;
case 'b':
cfg->boxPadding = atof(optarg);
break;
case 'X':
cfg->writeOsm = optarg;
break;
Expand Down
3 changes: 3 additions & 0 deletions src/pfaedle/config/PfaedleConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct Config {
writeStats(false),
parseAdditionalGTFSFields(false),
gridSize(2000 / util::geo::M_PER_DEG),
boxPadding(20000),
gaussianNoise(0),
verbosity(0) {}
std::string dbgOutputPath;
Expand Down Expand Up @@ -67,6 +68,7 @@ struct Config {
bool writeStats;
bool parseAdditionalGTFSFields;
double gridSize;
double boxPadding;
double gaussianNoise;
uint8_t verbosity;

Expand All @@ -81,6 +83,7 @@ struct Config {
<< "use-hmm: " << useHMM << "\n"
<< "write-graph: " << writeGraph << "\n"
<< "grid-size: " << gridSize << "\n"
<< "box-padding: " << boxPadding << "\n"
<< "use-cache: " << useCaching << "\n"
<< "write-overpass: " << writeOverpass << "\n"
<< "write-osmfilter: " << writeOsmfilter << "\n"
Expand Down
2 changes: 1 addition & 1 deletion src/pfaedle/router/ShapeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ShapeBuilder::ShapeBuilder(
_restr(restr),
_classifier(classifier),
_router(router) {
pfaedle::osm::BBoxIdx box(BOX_PADDING);
pfaedle::osm::BBoxIdx box(cfg.boxPadding);
ShapeBuilder::getGtfsBox(feed, mots, cfg.shapeTripId, cfg.dropShapes, &box,
_motCfg.osmBuildOpts.maxSpeed, 0, cfg.verbosity);

Expand Down

0 comments on commit 3ad6215

Please sign in to comment.