Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Use correct altitude for given GPS coordinates #1155

Merged
merged 13 commits into from
Aug 19, 2016
Merged

Use correct altitude for given GPS coordinates #1155

merged 13 commits into from
Aug 19, 2016

Conversation

KyleBoyer
Copy link
Contributor

Fixes: #1122

Changes made:

  • Looks up correct elevation/altitude in meters for given GPS coordinates
  • Fixed 2 warnings(by changing var to val)

@Sieberkev
Copy link
Collaborator

Sieberkev commented Aug 18, 2016

Nice work with the fetching, but won't this nuke their server like hell? That's probably why @jabbink asked for caching on S2 level. May I propose a slight modification?

Check in which S2 cell the requested lat/long is (the library to do so is already in the bot), fetch the altitude only once and cache/use the cell size (= level) + altitude (with some small randomisation per lat/long when they are in large cells).

Save/load the cached altitudes/sizes in a local cache file (on start/stop) so on a bot restart (or if you use multiple bots in the same area) you use the cached values (it's not that the earth changes altitude so much) ;)

This would be way more friendly to the external API.

@alexbulyha
Copy link
Contributor

Great idea , however i believe getting the altitude on each Start wont overload their servers and will be more precise. F.e. If I change the location my bot is farming, the altitude should change too. I believe the besteht way would be getting it once on start and thats was it

@Sieberkev
Copy link
Collaborator

Sieberkev commented Aug 18, 2016

however i believe getting the altitude on each Start wont overload their servers and will be more precise

If you start every time on the exact same location, that altitude will never change (maybe when a volcano erupts, but what are the chances of that).
If you are caching anyway (because nuking other APIs/servers for information that does not change is not very polite), you better use that value too on start since you have it anyway.

If I change the location my bot is farming, the altitude should change too.

Each time you move, it checks in which S2 cell you are. If that value is cached, use that value (+/- a small randomisation on large cells), if you don't have it in cache, fetch it from the external server.

KyleBoyer and others added 4 commits August 18, 2016 08:51
* Updated explanation in several files (#1152)

* Updated some of the readme files (API/FAQ/USAGE and ISSUE TEMPLATE)

* Additional information

* Fixed some words with feedback from jabbink

* Lowercase "ptc", to be sure ^-^

* Some more clarification

* Fix #1147 (#1157)

* Ensure template correctness (#1154)

* fixed typo in template file

* wrote tests for json-template

* fixed json-template with help from the new TestSettings

* Separated json credential testing from properties testing
* Updated explanation in several files (#1152)

* Updated some of the readme files (API/FAQ/USAGE and ISSUE TEMPLATE)

* Additional information

* Fixed some words with feedback from jabbink

* Lowercase "ptc", to be sure ^-^

* Some more clarification

* Fix #1147 (#1157)

* Ensure template correctness (#1154)

* fixed typo in template file

* wrote tests for json-template

* fixed json-template with help from the new TestSettings

* Separated json credential testing from properties testing
@KyleBoyer
Copy link
Contributor Author

@Sieberkev I have made those according changes

return this.s2Cache[cellId]!! + rand
}
var elevation = 10.0
val url = HttpUrl.parse("https://elevation.mapzen.com/height?json={\"shape\":[{\"lat\":" + latitude.toString() + ",\"lon\":" + longitude.toString() + "}]}").newBuilder().build()
Copy link
Contributor

Choose a reason for hiding this comment

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

return this.s2Cache[cellId]!! + rand
}
var elevation = 10.0
var url = HttpUrl.parse("https://maps.googleapis.com/maps/api/elevation/json?locations=$latitude,$longitude&sensor=true").newBuilder().build()
Copy link
Contributor

Choose a reason for hiding this comment

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

put this the try

@Sieberkev Sieberkev merged commit a4acaf8 into jabbink:develop Aug 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants