Skip to content

Commit

Permalink
MissingCoordinates: 0 is valid for latitude or longitude (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Sep 4, 2024
1 parent 0ad94ba commit e3cd571
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/metadatas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ mod tests {
assert_eq!(
serde_json::to_string_pretty(&metadatas.stats).unwrap(),
r#"{
"stops_count": 17,
"stops_count": 19,
"stop_areas_count": 2,
"stop_points_count": 9,
"stop_points_count": 11,
"stops_with_wheelchair_info_count": null,
"routes_count": 5,
"routes_with_custom_color_count": 0,
Expand All @@ -466,9 +466,9 @@ mod tests {
assert_eq!(
serde_json::to_string_pretty(&metadatas.stats).unwrap(),
r#"{
"stops_count": 17,
"stops_count": 19,
"stop_areas_count": 2,
"stop_points_count": 9,
"stop_points_count": 11,
"stops_with_wheelchair_info_count": 0,
"routes_count": 5,
"routes_with_custom_color_count": 0,
Expand Down
6 changes: 2 additions & 4 deletions src/validators/stops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ fn check_coord(stop: &gtfs_structures::Stop) -> Option<Issue> {
(Some(lon), Some(lat)) if lon == 0.0 && lat == 0.0 => {
"Latitude and longitude are missing"
}
(Some(lon), _) if lon == 0.0 => "Longitude is missing",
(_, Some(lat)) if lat == 0.0 => "Latitude is missing",
_ => "Coordinates are ok",
}),
)
Expand All @@ -99,7 +97,7 @@ fn check_coord(stop: &gtfs_structures::Stop) -> Option<Issue> {

fn has_coord(stop: &gtfs_structures::Stop) -> bool {
match (stop.latitude, stop.longitude) {
(Some(lon), Some(lat)) => lon != 0.0 && lat != 0.0,
(Some(lon), Some(lat)) => lon != 0.0 || lat != 0.0,
_ => false,
}
}
Expand Down Expand Up @@ -133,7 +131,7 @@ fn test_missing() {
.collect();

assert_eq!(1, missing_coord_issue.len());
assert_eq!("AMV", missing_coord_issue[0].object_id);
assert_eq!("null_island", missing_coord_issue[0].object_id);
assert_eq!(
IssueType::MissingCoordinates,
missing_coord_issue[0].issue_type
Expand Down
2 changes: 2 additions & 0 deletions test_data/stops/stops.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ entrance_bad_parent,bad entrance,,36.909489,-116.768242,,,2,BULLFROG
good_entrance,good entrance,,36.909489,-116.768242,,,2,PARENT
EMSI,E Main St / S Irving St (Demo),,36.905697,-116.76218,,,,
AMV,Amargosa Valley (Demo),,0.0,-116.40094,,,,
DIJON,Dijon Valley (Demo),,-42.1337,0.0,,,,
null_island,Null Island,,0.0,0.0,,,,
PARENT,Moo,,92.462154,-116.40094,,,1,

0 comments on commit e3cd571

Please sign in to comment.