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

Add support for OpenCage geocoder #7015

Merged
merged 5 commits into from
Sep 12, 2018
Merged

Conversation

marrouchi
Copy link
Contributor

OpenCage is an API for forward/reverse geocoding. This adds OpenCageGeocoderService for use with the Geocoder widget.

To test this, you'll need to open an account in order to get the API Key.

PS : I'll send the Signed CLA tomorow.

@cesium-concierge
Copy link

Thank you so much for the pull request @marrouchi! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@hpinkos
Copy link
Contributor

hpinkos commented Sep 6, 2018

Thanks for the pull request @marrouchi! At a glace, everything looks great. I'll do a more thorough review after we receive your CLA.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 8, 2018

@marrouchi we received your CLA, thanks again.

CHANGES.md Outdated
@@ -223,6 +223,7 @@ Change Log
* Added ability to invoke `sampleTerrain` from node.js to enable offline terrain sampling
* Added more ParticleSystem Sandcastle examples for rocket and comet tails and weather. [#6375](https://github.com/AnalyticalGraphicsInc/cesium/pull/6375)
* Added color and scale attributes to the `ParticleSystem` class constructor. When defined the variables override startColor and endColor and startScale and endScale. [#6429](https://github.com/AnalyticalGraphicsInc/cesium/pull/6429)
* Added `OpenCageGeocoderService`, which provides geocoding via [OpenCage](https://opencagedata.com/).
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be moved up to the 1.50 section

Check.defined('apiKey', apiKey);
//>>includeEnd('debug');

this._url = Resource.createIfNeeded(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using this._url three times, do

url = Resource.createIfNeeded(url);
...
this._url = url;

* @example
* // Configure a Viewer to use the OpenCage server hosted by https://geocode.earth/
* var viewer = new Cesium.Viewer('cesiumContainer', {
* geocoder: new Cesium.OpenCageGeocoderService(new Cesium.Resource({
Copy link
Contributor

Choose a reason for hiding this comment

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

This example code doesn't work. It doesn't pass in the API key param

* @param {String} [options.proximity] Provides the geocoder with a hint to bias results in favour of those closer to the specified location (For example: 41.40139,2.12870).
* @returns {Promise<GeocoderService~Result[]>}
*/
OpenCageGeocoderService.prototype.geocode = function(query, params) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't match the interface for GeocoderService.geocode https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/GeocoderService.js#L28-L32

The GeocoderViewModel for the geocoder widget will only pass in the search string and the second param is either GeocodeType.SEARCH or GeocodeType.AUTOCOMPLETE. Should all of these optional params be passed into the constructor instead?

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, i should probably pass these optional params into the constructor. OpenCage does not offer auto-complete geocoding so there is no need to use the second param.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that's no problem. Neither does the BingMapsGeocoderService: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/BingMapsGeocoderService.js#L75
That geocode function just accepts the first query param

@hpinkos
Copy link
Contributor

hpinkos commented Sep 10, 2018

Just those comments. Thanks @marrouchi!

@marrouchi
Copy link
Contributor Author

Thank you @hpinkos for the code review. Please let me know if there's others issues.

@hpinkos
Copy link
Contributor

hpinkos commented Sep 12, 2018

Works great! Thanks for the contribution @marrouchi!

@hpinkos hpinkos merged commit 6c0b112 into CesiumGS:master Sep 12, 2018
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