Skip to content

Adding mechanism for overriding OSM WayPropertySetSource in build-config.json - #2389

Merged
abyrd merged 14 commits into
opentripplanner:masterfrom
entur:rutebanken_norway_osm_properties
Aug 17, 2017
Merged

Adding mechanism for overriding OSM WayPropertySetSource in build-config.json#2389
abyrd merged 14 commits into
opentripplanner:masterfrom
entur:rutebanken_norway_osm_properties

Conversation

@seime

@seime seime commented Jan 4, 2017

Copy link
Copy Markdown
Contributor

See #1996

Configurable via build parameter "osmWayPropertySet"

Also added a custom property set for Norway where other access rules applies

@mg-code

mg-code commented Jan 10, 2017

Copy link
Copy Markdown

This is very useful feature.
I made merge in my forked repo and already using it for Latvia.

Thanks!

seime referenced this pull request in HSLdevcom/OpenTripPlanner Feb 6, 2017
DT-1759 Add penalty for walking on roads
// Support "default" as well
case "default":
retval = new DefaultWayPropertySetSource();
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I find switch statements kind of fragile with their default fall-through behavior and lack of braces around their clauses. Could we replace this with:

if ("default".equals(type)) {return new DefaultWayPropertySetSource();}
else if...


public WayPropertySet getWayPropertySet();

public class WayPropertySetSourceFactory {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just eliminate this inner class and put the static method on the containing class?

* @see WayPropertySetSource
* @see DefaultWayPropertySetSource
*/
public class NorwayWayPropertySetSource extends DefaultWayPropertySetSource {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd like to avoid inheritance where possible. Could we instead define a WayPropertySetSource that does not extend the default one, and just composes with it? I would think we can construct a default one, get its WayPropertySet, and then add some additional properties. But then I see you want to get your properties in before the default ones.

}

/* Populate properties on existing WayPropertySet. Makes it easer to override any properties by sub classes. */
protected void populateProperties(WayPropertySet props) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see that you're making these protected so they are accessible from a subclass, but I'm now realizing maybe they should be public static utility functions on the superclass. They don't seem to need any state fields from the class instance itself.

@seime
seime force-pushed the rutebanken_norway_osm_properties branch from 0e110e1 to 4b41554 Compare March 14, 2017 14:20
@seime

seime commented Mar 14, 2017

Copy link
Copy Markdown
Contributor Author

Updated code according to comments @abyrd

@abyrd

abyrd commented Mar 21, 2017

Copy link
Copy Markdown
Member

Thanks @seime, looks good. About WayPropertySetSourceFactory though, I don't think we need a separate class at all to contain a single function. It would be preferable to put the static factory method on the WayPropertySetSource class, so it would be invoked as WayPropertySetSource.fromConfig(). I think the documentation needs more detail as well, explaining the context: we must interpret OSM tags when building the OTP graph, and different OSM way types and tags have different meanings in different countries, and different OTP users may want those tags to be applied differently.

@seime

seime commented Jun 16, 2017

Copy link
Copy Markdown
Contributor Author

@abyrd will look at this again next week

@seime

seime commented Jun 27, 2017

Copy link
Copy Markdown
Contributor Author

@abyrd looking ok now?

@seime

seime commented Aug 16, 2017

Copy link
Copy Markdown
Contributor Author

Can this be merged and closed?

@seime seime mentioned this pull request Aug 17, 2017
@abyrd
abyrd merged commit bb29688 into opentripplanner:master Aug 17, 2017
@t2gran
t2gran deleted the rutebanken_norway_osm_properties branch March 27, 2019 11:45
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.

3 participants