Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/just_gtfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhlopkova Olga <o.khlopkova@corp.mail.ru>2021-02-05 17:59:44 +0300
committerKhlopkova Olga <o.khlopkova@corp.mail.ru>2021-02-05 17:59:44 +0300
commit7516753825500f90ac2de6f18c256d5abec1ff33 (patch)
tree389985bef30985b9a6518581c51046fbd1f6696e
parent0b3559b70b183ddbf6fd7355bbfc62a383d431e4 (diff)
Fixes for StopLocationType & FareTransfers::Unlimitedfor-usage-as-submodule
-rw-r--r--just_gtfs.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/just_gtfs.h b/just_gtfs.h
index 4077c02..9fc160c 100644
--- a/just_gtfs.h
+++ b/just_gtfs.h
@@ -888,7 +888,7 @@ struct Stop
Text stop_code;
Text stop_desc;
Text stop_url;
- StopLocationType location_type = StopLocationType::GenericNode;
+ StopLocationType location_type = StopLocationType::StopOrPlatform;
Text stop_timezone;
Text wheelchair_boarding;
Id level_id;
@@ -999,6 +999,14 @@ struct FareAttributesItem
size_t transfer_duration = 0; // Length of time in seconds before a transfer expires
};
+inline bool operator==(const FareAttributesItem & lhs, const FareAttributesItem & rhs)
+{
+ return std::tie(lhs.fare_id, lhs.price, lhs.currency_type, lhs.payment_method, lhs.transfers,
+ lhs.agency_id, lhs.transfer_duration) ==
+ std::tie(rhs.fare_id, rhs.price, rhs.currency_type, rhs.payment_method, rhs.transfers,
+ rhs.agency_id, rhs.transfer_duration);
+}
+
// Optional dataset file
struct FareRule
{
@@ -1840,7 +1848,7 @@ inline Result Feed::add_fare_attributes(const ParsedCsvRow & row)
item.currency_type = row.at("currency_type");
set_field(item.payment_method, row, "payment_method", false);
- set_field(item.transfers, row, "transfers", false);
+ set_field(item.transfers, row, "transfers");
// Conditionally optional:
item.agency_id = get_value_or_default(row, "agency_id");
@@ -2778,9 +2786,12 @@ inline void Feed::write_fare_attributes(std::ofstream & out) const
for (const auto & attribute : fare_attributes)
{
std::vector<std::string> fields{
- wrap(attribute.fare_id), wrap(attribute.price), attribute.currency_type,
- wrap(attribute.payment_method), wrap(attribute.transfers), wrap(attribute.agency_id),
- wrap(attribute.transfer_duration)};
+ wrap(attribute.fare_id), wrap(attribute.price), attribute.currency_type,
+ wrap(attribute.payment_method),
+ // Here we handle GTFS specification corner case: "The fact that this field can be left
+ // empty is an exception to the requirement that a Required field must not be empty.":
+ attribute.transfers == FareTransfers::Unlimited ? "" : wrap(attribute.transfers),
+ wrap(attribute.agency_id), wrap(attribute.transfer_duration)};
write_joined(out, std::move(fields));
}
}