Skip to content

Refactor elevation provider - #2381

Merged
easbar merged 3 commits into
graphhopper:masterfrom
camptocamp:refactor_elevation_provider
Sep 4, 2021
Merged

easbar merged 3 commits into
graphhopper:masterfrom
camptocamp:refactor_elevation_provider

Conversation

@gberaudo

Copy link
Copy Markdown
Contributor

Refactor elevation provider:

  • clean up interface;
  • add a getEle(node) variant with a default implementation.

Fixes: #2374.
Ping @otbutz, @easbar.

I did not introduce constructor parameters as it was a bit tricky with multiple constructors like in MultiplSourceElevationProvider.
The AbstractElevationProvider was alreading containing filesystem related code so I moved the methods there.
I have not renamed getInterpolate to canInterpolate yet. I will work on it later.

Please let me know your feedback of this PR.

@easbar easbar left a comment

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.

Thanks for this PR. See my comments inline.

The AbstractElevationProvider was alreading containing filesystem related code so I moved the methods there.

Can we rename it to F(T?)ileBasedElevationProvider then?

Please also add a line to CHANGELOG.md and add yourself to CONTRIBUTORS.md.

@otbutz

otbutz commented Aug 25, 2021

Copy link
Copy Markdown
Contributor

I'd vote for TileBasedElevationProvider

@gberaudo
gberaudo force-pushed the refactor_elevation_provider branch 3 times, most recently from a874627 to f6c44b4 Compare August 26, 2021 11:56
@otbutz

otbutz commented Aug 26, 2021

Copy link
Copy Markdown
Contributor

IMHO it's either a MultiSourceTileBasedProvider and therefore extends the TileBasedProvider interface or it's generic and we need to loop over it's providers and check+configure them.

@otbutz

otbutz commented Aug 26, 2021

Copy link
Copy Markdown
Contributor

I'd prefer a generic MultiSourceElevationProvider and configure each of its wrapped providers.

@gberaudo

gberaudo commented Aug 26, 2021 •

Copy link
Copy Markdown
Contributor Author

I'd prefer a generic MultiSourceElevationProvider and configure each of its wrapped providers.

@otbutz, do you mean I should:

  • remove the TileBasedElevationProviderInterface;
  • remove the related setters from MultiSourceElevationProvider;
  • add a getProviders method to MultiSourceElevationProvider which returns [this.srtmProvider, this.globalProvider];
  • in Graphhopper.java, iterate on these providers and run call the setters.

If yes, how do I handle the setBaseUrl?

  public MultiSourceElevationProvider setBaseURL(String baseURL) {
        String[] urls = baseURL.split(";");
        if (urls.length != 2) {
            throw new IllegalArgumentException("The base url must consist of two urls separated by a ';'. The first for cgiar, the second for gmted");
        }
        srtmProvider.setBaseURL(urls[0]);
        globalProvider.setBaseURL(urls[1]);
        return this;
    }

@gberaudo

Copy link
Copy Markdown
Contributor Author

@otbutz, I am willing to address the concern you expressed. Could you please give me some inputs so that I can move forward?

@otbutz

otbutz commented Aug 30, 2021

Copy link
Copy Markdown
Contributor

Scratch that. Had a look at the current implementation and the MultiSourceElevationProvider only ties together a CIGAR and a GMTED provider. So this is far from a generic solution.

I'd go with MultiSourceTileBasedElevationProvider extends TileBasedElevationProvider and butcher the TileBasedElevationProviderInterface

So we'd end up with the following interfaces/classes:

  • ElevationProvider (interface)
  • TileBasedElevationProvider (abstract class)

@gberaudo
gberaudo force-pushed the refactor_elevation_provider branch from f6c44b4 to 15c6c87 Compare August 31, 2021 11:58
@gberaudo

Copy link
Copy Markdown
Contributor Author

OK @otbutz, I reworked the PR with your idea.
@easbar, does it also look good for you?

@gberaudo
gberaudo force-pushed the refactor_elevation_provider branch from 15c6c87 to 98c5cb0 Compare August 31, 2021 13:20

@otbutz otbutz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart from the config.yml_old the PR is looking fine :)

Comment thread config.yml_old Resolved
- move them to the TileBasedElevationProvider;
- expose builder methods consistently and specialize the returned type;
- assume MultiSourceElevationProvider works with file/tile providers.
@gberaudo
gberaudo force-pushed the refactor_elevation_provider branch from 98c5cb0 to 93c9ebb Compare August 31, 2021 13:28
@gberaudo
gberaudo force-pushed the refactor_elevation_provider branch from 93c9ebb to ef28716 Compare August 31, 2021 14:51
@gberaudo

gberaudo commented Sep 3, 2021

Copy link
Copy Markdown
Contributor Author

Hi @easbar, you requested changes to the PR. I think I addressed all your demands. If the code looks good to you now would you be willing to merge the PR?

@easbar

easbar commented Sep 4, 2021

Copy link
Copy Markdown
Member

Hi @easbar, you requested changes to the PR. I think I addressed all your demands. If the code looks good to you now would you be willing to merge the PR?

Thanks for your changes. Yes, this PR looks good to me. There are a few minor things that we should fix (like missing overrides, duplicate javadocs in multi source provider and some whitespace/formatting), but I'll do this in a follow-up commit.

Had a look at the current implementation and the MultiSourceElevationProvider only ties together a CIGAR and a GMTED provider. So this is far from a generic solution.

Yes, the name is a bit misleading indeed, I'll check if this can be improved, but this is unrelated to this PR.

@easbar
easbar merged commit 1d6b2e1 into graphhopper:master Sep 4, 2021
@gberaudo

gberaudo commented Sep 7, 2021

Copy link
Copy Markdown
Contributor Author

Thanks @easbar. I saw your follow up PR. Will also manage this part next time.

@gberaudo
gberaudo deleted the refactor_elevation_provider branch September 7, 2021 07:11
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.

Cleanup ElevationProvider interface

3 participants