Skip to content

introduces under_score notation for all properties, fixes #682 - #719

Closed
karussell wants to merge 7 commits into
masterfrom
issue_682
Closed

karussell wants to merge 7 commits into
masterfrom
issue_682

Conversation

@karussell

@karussell karussell commented May 13, 2016 •

Copy link
Copy Markdown
Member

This change fixes #682 and requires a re-import as not only the storable properties are changed but also the EncodingManager properties like turnCosts -> turn_costs

Done:

  • under score parameters are now default for get and put in PMap
  • keep 'routing.' prefix for defaults specified in config.properties, on query the 'routing.' is not allowed (no fallback yet)

Some backward breaking changes (no fallback for now):

  • The biggest change is that we do no longer handle upper case as before e.g. stuff like this will fail now assertEquals("valueA", subject.get("FOO", ""));. The reason is that camelCase still works and is automatically converted to under_score
  • osmreader.preferred-language -> osmreader.preferred_language
  • prepare.contracted-nodes -> prepare.contracted_nodes
  • prepare.logmessages -> prepare.log_messages
  • osmreader.way_point_max_distance -> routing.way_point_max_distance

TODOs:

  • pass correct properties to measurement -> graphhopper.sh script (measurement.git_info, graph.import_time, graph.size_in_MB, location_index, etc) and config-example.properties
  • update measurement JS
  • update I18N keys and access to those key in the JS UI
  • change constants versions
  • routing.roundTrip.maxRetries
  • documentation e.g. about routing etc
  • add fallback for graph.elevation.*
    • graph.elevation.calcmean <- graph.elevation.calc_mean
    • graph.elevation.cachedir <- graph.elevation.cache_dir
    • graph.elevation.baseurl <- graph.elevation.base_url

@karussell karussell added this to the 0.7 milestone May 13, 2016
@devemux86

Copy link
Copy Markdown
Contributor

It appears we cannot avoid the backwards compatibility break (some will complain), but it's for better library organization.

@devemux86

devemux86 commented May 13, 2016 •

Copy link
Copy Markdown
Contributor

My suggestion is to group all these fixed strings into a central public class e.g. GHConstants, instead of being hard coded all over.

  • That way is less prone to errors, as they'll be maintained only in one place
  • And those using them from outside can access them safely, without worrying for typos or changes

@karussell

karussell commented May 13, 2016 •

Copy link
Copy Markdown
Member Author

Not sure about this constant class as this tightly coupling is only possible if used from a java client (also probably the name should be (GH)Parameters as we already have Constants).

Renaming of those keys should not happen often as this breaks usage from 'outside'. Or would a more context specific solution like currently done very seldom for e.g. CHAlgoFactoryDecorator.DISABLE or AlgorithmOptions.DIJKSTRA make more sense?

If not context sensitive the name would be ugly long like Parameters.ALGORITHM_DIJKSTRA etc

@devemux86

devemux86 commented May 13, 2016 •

Copy link
Copy Markdown
Contributor

Or would a more context specific solution like currently done very seldom for e.g. CHAlgoFactoryDecorator.DISABLE or AlgorithmOptions.DIJKSTRA make more sense?

Yes that could work too.
Still I'm talking about all fixed properties / parameters to be grouped in such a way. It'll be very helpful inside GH and from outside.

@karussell

karussell commented May 13, 2016 •

Copy link
Copy Markdown
Member Author

What came to my mind is to use embedded classes:

public class Parameters {
   public static class Algorithms {
       public static String DIJKSTRA="dijkstra";
   }
}

Then one could import e.g. Parameters.Algorithms and just use DIJKSTRA

@devemux86

Copy link
Copy Markdown
Contributor

I'd vote for that, good organization.

@karussell

Copy link
Copy Markdown
Member Author

The advantage of having all in one place is also a good overview / documentation of features.

@karussell

karussell commented May 14, 2016 •

Copy link
Copy Markdown
Member Author

Please see this new class 9fa4441#diff-c6031a04cf6bb054003314f01e9a4239R24

Maybe we should improve the handling for "on query parameters" vs. "init parameters". E.g. max_visited_nodes vs. init.max_visited_nodes or ch.disable vs. init.ch.disabling_allowed.

To help migration we could throw an exception (can be disabled) if parameters are passed to GH on init and are not listed in the Parameters class.

@devemux86

Copy link
Copy Markdown
Contributor

Nice, I like the constants synthesis in the class too.
There are still strings to be added right?

@karussell

karussell commented May 14, 2016 •

Copy link
Copy Markdown
Member Author

There are still strings to be added right?

Yes, although these should be only "init parameters" (should we move them there too?) or 'private' parameters (I would keep them private as there are e.g. implementation specific)

@devemux86

Copy link
Copy Markdown
Contributor

Inner classes can work, unless we have at the end a big amount of strings to handle.

'private' parameters (I would keep them private)

e.g. how you put the graph properties?

@karussell

karussell commented May 14, 2016 •

Copy link
Copy Markdown
Member Author

Inner classes can work, unless we have at the end a big amount of strings to handle.

Yeah, I'm not sure if some of the properties should be moved e.g. into the algorithms.

'private' parameters (I would keep them private)

I more meant params like alternative_route.min_plateau_factor which could be changed for other alternative route implementations. The graph.* and prepare.* params are what I mean with 'init parameters' and could be moved into the class as well - maybe not that important for now (?) and would let it for another issue (?)

@devemux86

devemux86 commented May 14, 2016 •

Copy link
Copy Markdown
Contributor

Probably a separate issue about hosting all fixed strings - regardless category - in such class(es) would be best and keep this for the notation?

@karussell

Copy link
Copy Markdown
Member Author

This is merged now.

@karussell karussell closed this May 15, 2016
@devemux86

Copy link
Copy Markdown
Contributor

Another thought, do you think the strings should be sorted in the class for better reviewing?

@karussell

Copy link
Copy Markdown
Member Author

Do you mean the Parameters class and what do you mean with better reviewing?

@devemux86

devemux86 commented May 15, 2016 •

Copy link
Copy Markdown
Contributor

Yes in that. Like you mentioned above it's a good overview / documentation of features. So I'm wondering if the various properties should be better sorted alphabetically in each sub-class, e.g. here.

@karussell

karussell commented May 15, 2016 •

Copy link
Copy Markdown
Member Author

Ah, yes. Makes sense for the future, also for the static classes. For now the setting number is small enough also hopefully we can create enough static classes to keep the number small.

karussell pushed a commit that referenced this pull request May 15, 2016
karussell pushed a commit to graphhopper/map-matching that referenced this pull request May 15, 2016
karussell added a commit that referenced this pull request May 15, 2016
karussell pushed a commit that referenced this pull request May 18, 2016
@karussell
karussell deleted the issue_682 branch October 6, 2016 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CamelCase vs. underscore notation

2 participants