Skip to content

Commit

Permalink
write attributions.txt crediting OSM contributors, mention OSM copyri…
Browse files Browse the repository at this point in the history
…ght in README, closes #53
  • Loading branch information
patrickbr committed Mar 4, 2024
1 parent 0037a83 commit 7ccc303
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ The following flags may be useful for debugging:
# Configuration

A default configuration file `pfaedle.cfg` can be found in this repo and will be installed with `make install`. Custom configuration files can be specified with the `-c` flag. If no `-c` flag is set, `pfaedle` will parse and merge the following cfg files in the given order (if present): `<install prefix>/etc/pfaedle/pfaedle.cfg`, `$HOME/.config/pfaedle/pfaedle.cfg`, `<CWD>/pfaedle.cfg`. Values given in later files will overwrite earlier defined values.

# Attribution

Note that the `shapes.txt` produced by `pfaedle` is based on OpenStreetMap data, which is licensed under OdBL 1.0 (see [here](https://osm.org/copyright)). If you copy, distribute, transmit and adapt the shapefied GTFS feed, please credit the contributors of OpenStreetMap.
2 changes: 1 addition & 1 deletion src/cppgtfs
28 changes: 28 additions & 0 deletions src/pfaedle/gtfs/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ void Writer::write(gtfs::Feed* sourceFeed, const std::string& path) const {
cannotWrite(curFileTg);
}
}

curFile = getTmpFName(gtfsPath, ".pfaedle-tmp", "attributions.txt");
curFileTg = gtfsPath + "/attributions.txt";
fs.open(curFile.c_str());
if (!fs.good()) cannotWrite(curFile, curFileTg);
writeAttribution(sourceFeed, &fs);
fs.close();

if (toZip) {
#ifdef LIBZIP_FOUND
moveIntoZip(za, curFile, "attributions.txt");
#endif
} else {
if (std::rename(curFile.c_str(), curFileTg.c_str()))
cannotWrite(curFileTg);
}
} catch (...) {
#ifdef LIBZIP_FOUND
zip_discard(za);
Expand All @@ -363,6 +379,18 @@ void Writer::write(gtfs::Feed* sourceFeed, const std::string& path) const {
}
}

// ____________________________________________________________________________
void Writer::writeAttribution(gtfs::Feed*, std::ostream* os) const {
auto csvw = ad::cppgtfs::Writer::getAttributionCsvw(os);

csvw->flushLine();
csvw->writeString("OpenStreetMap contributors");
csvw->writeString("https://www.openstreetmap.org/copyright");
csvw->writeInt(1);

csvw->flushLine();
}

// ____________________________________________________________________________
void Writer::writeFeedInfo(gtfs::Feed* f, std::ostream* os) const {
auto csvw = ad::cppgtfs::Writer::getFeedInfoCsvw(os);
Expand Down
1 change: 1 addition & 0 deletions src/pfaedle/gtfs/Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Writer {
void writeStopTimes(Feed* f, std::ostream* os) const;
void writeLevels(Feed* f, std::ostream* os) const;
void writePathways(Feed* f, std::ostream* os) const;
void writeAttribution(Feed* f, std::ostream* os) const;

static void cannotWrite(const std::string& file, const std::string& file2);
static void cannotWrite(const std::string& file);
Expand Down

0 comments on commit 7ccc303

Please sign in to comment.