Repository navigation
Conversation
|
Thanks! This is indeed a very minor change - nice :) ! We could even avoid breaking the Java API when offering the old method setCHWeighting(String). |
There was a problem hiding this comment.
we should throw an exception here saying at least one weighting is required.
There was a problem hiding this comment.
You are right. I will update the PR
|
Ah, okay the method |
There was a problem hiding this comment.
Probably comma separated without spaces ?
There was a problem hiding this comment.
for the encoders we accept also spaces I think, trimming is easy and should be done before calling setCHWeighting. But for now I would be even okay with trimming inside the setter, not sure.
There was a problem hiding this comment.
I thought about that as well. What is the downside of trimming? We do not allow weighting names like " name" or "name ". The benefit is that our config files are not sensible to whitespace.
I would not expect a config file to be sensible to whitespaces.
trimming inside the setter
Do you think adding logic to a setter is bad?
There was a problem hiding this comment.
Do you think adding logic to a setter is bad?
Yeah. That is the only thing I don't like about it. But when reading the config file we should trim and then set with the array which is then used 'as it'. Maybe even do not do toLowerCase but throw exception if upper case?
There was a problem hiding this comment.
I actually don't think that adding logic to getters/setter is a bad practice. As long as we are trying to improve the quality of the "seted" value. And not doing anything unrelated to setting the value.
The pro of doing it in the setter is that we have a central/unique place to execute the correction of weighting values.
How about creating a setCHWeighting method that uses varargs. This would not break the setter.
How about providing a Therefore, this would be a pure feature that does not break the api and could be merged soon (since I'd like to see that feature in the master branch ;)). |
There was a problem hiding this comment.
here I vote for just 'getCHWeightings'
There was a problem hiding this comment.
Me too, but overloading of methods is only valid if you use different parameters. Same method name with different return type is not valid.
There was a problem hiding this comment.
Ah, ups, you're right. You wanted to keep the old method, hmmh. I think we should break the API here as the new method should also have a nice name and the old method is probably not that often used.
There was a problem hiding this comment.
Ok, so I will change the name from getAllCHWeightings to getCHWeightings and change the name of getCHWeighting to getFallbackCHWeighting to be used in the getWeightingForCH method.
After writing the above I just realized, that getWeightingForCH and getCHWeighting is probably irritating.
Maybe we refactor the getAllCHWeightings to getCHWeightingNames?
There was a problem hiding this comment.
After writing the above I just realized, that getWeightingForCH and getCHWeighting is probably irritating.
Hmmh, that is right. I would get rid of it and just keep getCHWeightings and getWeightingForCH. Currently new GH versions broke the Java API and if it is properly documented in the changelog.txt there was no problem or even questions in the forum.
BTW: Maybe we should rename getWeightingForCH to findCHWeighting to indicate the small overhead? But would be a different issue
|
Perfect ideas! Just for the toLowerCase and trimming I would like to know your oppinion e.g. if just doing it or throwing exceptions etc |
|
Ok everything should be fixed now. I added the renaming to the changelog.txt. What do you think, can we merge this branch? |
|
Thanks! One minor thing now is that the setter and getter of the |
|
Ok sure, I can do that. But I would leave the fallback method using varargs without the s? To not break the API at this point. |
Hmmh, good question. Or keep setCHWeighting with one string and do setCHWeightings with the varargs? As I would mark the old setCHWeighting method as deprecated and remove it at some point (?) |
Ok this sounds reasonable. Change both List+Varargs to setCHWeightings and add a setCHWeighting method that is set deprecated? |
|
Ok! |
Added Comments in properties file Created Wrapper Methods to not break the API Removed getCHWeighting and added Information to changelog Updated setCHWeighting
599ba57 to
d7f7702
Compare
|
PR is squashed. Thanks. |
Oh, I have to thank: thanks :) ! One thing which I will do in another change: This should be renamed to |
|
Merged with a few changes in the GraphHopper class. 641d222 |
|
Thanks! |
This PR allows users to setup multiple weightings using CH. You have to define the weightings in the properties file like:
prepare.chWeighting=fastest, shortest