Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public static boolean isPositionValid(GtfsRealtime.Position position) {
if (position.getLongitude() < -180f || position.getLongitude() > 180f) {
return false;
}
if (position.getLongitude() == 0f && position.getLongitude() == 0f) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,6 @@ public void testValidPosition() {
/**
* Valid lat/longs
*/
positionBuilder.setLatitude(0);
positionBuilder.setLongitude(0);

assertEquals(true, GtfsUtils.isPositionValid(positionBuilder.build()));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this test in the invalid test cases because it seems like 0,0 should be invalid according to #77 and this test broke when I changed the validator.


positionBuilder.setLatitude(-90);
positionBuilder.setLongitude(-180);
Expand All @@ -469,6 +465,11 @@ public void testValidPosition() {
/**
* Bad lat or long
*/
positionBuilder.setLatitude(0);
positionBuilder.setLongitude(0);

assertEquals(false, GtfsUtils.isPositionValid(positionBuilder.build()));

positionBuilder.setLatitude(-91);
positionBuilder.setLongitude(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ public void testE026() {
expected.put(E026, 1);
TestUtils.assertResults(expected, results);

// Invalid lat & long - 1 error
positionBuilder.setLatitude(0f);
positionBuilder.setLongitude(0f);

vehiclePositionBuilder.setPosition(positionBuilder.build());

vehiclePositionBuilder.setVehicle(vehicleDescriptorBuilder.build());
feedEntityBuilder.setVehicle(vehiclePositionBuilder.build());
feedMessageBuilder.setEntity(0, feedEntityBuilder.build());

results = vehicleValidator.validate(MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
expected.put(E026, 1);
TestUtils.assertResults(expected, results);


clearAndInitRequiredFeedFields();
}

Expand Down