Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data structure #89

Closed
wants to merge 4 commits into from
Closed

Data structure #89

wants to merge 4 commits into from

Conversation

pantierra
Copy link
Contributor

This is a new pull request for the revised data structure #30 with a lot of wonderful work by @AltNico.
Please help with your review. Thanks! 😄

@grote
Copy link
Owner

grote commented Nov 29, 2017

@xamanu thanks for this! Do you know why the CI didn't run for this MR? Do you mind rebasing this on master, so we can get the benefit of the Accra integration test to see if it still passes with these changes?

@pantierra
Copy link
Contributor Author

Will rebase and check.

Copy link
Owner

@grote grote left a comment

Choose a reason for hiding this comment

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

I gave this a first quick read and it already looks quite good. Thanks for the good work!

line.add_itinerary(itinerary)
except ValueError:
print('Itinerary ID does not match line ID. Please fix in OSM.')
print(line.osm_url)
Copy link
Owner

Choose a reason for hiding this comment

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

These kind of errors should be printed to stderr like elsewhere.


Returns a initiated RouteVariant object from raw data

colour = "FFFFFF"
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should be in line with transitfeed's way of writing color here (and below).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

British... American... now it's time to chose 😄 I also tend to use the American over the British as in most technical environments it is the quasi standard. I would go for color, what do you think, @AltNico?


colour = "FFFFFF"
if "colour" in route_master.tags:
colour = OsmConnector.get_hex_code_for_color(route_master.tags['colour'])
Copy link
Owner

Choose a reason for hiding this comment

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

Do the tags really use colour instead of color? Is this defined somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in OpenStreetMap usually British English is used: https://wiki.openstreetmap.org/wiki/Key:colour

Copy link
Contributor

Choose a reason for hiding this comment

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

What about supporting both? 😄

self.stops["relation/" + str(relation.id)
] = self._build_stop_area(relation)
except RuntimeError:
print('Cannot add stop area', relation.id)
Copy link
Owner

Choose a reason for hiding this comment

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

We should not catch RuntimeErrors. Please use a different exception for this. You can even make your own.

@@ -598,7 +646,7 @@ def _find_best_name_for_unnamed_stop(self, stop):
winner_distance = sys.maxint
for candidate in candidates:
if isinstance(candidate, overpy.Way):
lat, lon = Stop.get_center_of_nodes(
lat, lon = OsmConnector.get_center_of_nodes(
Copy link
Owner

Choose a reason for hiding this comment

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

We do you need to prepend method calls with OsmConnector when you are in OsmConnector?

str(osm_type) + "/" + str(osm_id))


class StopArea(object):
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't need to be annotated with @attr.s?

class Stop(object):

osm_id = attr.ib()
osm_type = attr.ib()
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need an osm_type? What values can this have?

Copy link
Contributor Author

@pantierra pantierra Nov 29, 2017

Choose a reason for hiding this comment

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

It can be either node or way. Depending on the type different behaviours might be necessary. E.g for a way you may want to find the center. And we concretely need it for constructing the url to the object here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another reason is also related to #94: osm_id is used for different id spaces, depending on osm_type. Both together can identify an object in OSM, not only osm_id. For the id of the GTFS it is recommended to combine those two in any way.

@@ -78,6 +79,7 @@ def _get_itinerary_operation(self, itinerary,
operations.append("sunday")
return operations

# pylint: disable=arguments-differ
def _create_service_period(self, schedule, operation):
Copy link
Owner

Choose a reason for hiding this comment

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

Why do the arguments differ here?

route_url # From Line
route_color # From Line
route_text_color # From Line
"""
Copy link
Owner

Choose a reason for hiding this comment

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

What do these comments mean? What do they relate to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were just to not forget important values 😄 Can be taken out.

@pantierra
Copy link
Contributor Author

Thanks a lot for the review, @grote! I just fixed the noted issues.
But I have no idea why CI is not running here.

Please note: When testing, make sure you clean all your cached data.

@grote
Copy link
Owner

grote commented Nov 29, 2017

Please check your project settings for Integration & Services and make sure Travis CI is listed there and enabled.


# Cache data
Cache.write_data('stops-' + self.selector, self.stops)
Cache.write_data('stops-' + self.selector, self.routes)
Copy link
Owner

Choose a reason for hiding this comment

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

routes are written to stops?

sys.stderr.write("http://osm.org/node/" +
str(member.ref) + "\n")
if len(stop_members) < 1:
raise RuntimeError('Cannot build stop area with no members')
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like you are still raising a RuntimeError here.

@pantierra
Copy link
Contributor Author

pantierra commented Nov 29, 2017

Thanks, now CI pipeline works. Still a bit to fix, but we are close to green 😄 Will comment then.

@pantierra
Copy link
Contributor Author

It seems like the last error raised here by pylint through the Travis CI are part of attr.s and can not be fixed: python-attrs/attrs#215

@pantierra
Copy link
Contributor Author

Closed in favour of this rebased version: #96

@pantierra pantierra closed this Dec 7, 2017
@pantierra pantierra deleted the data-structure branch December 16, 2017 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants