-
Notifications
You must be signed in to change notification settings - Fork 232
Use correct altitude for given GPS coordinates #1155
Conversation
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. |
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 |
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).
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. |
* 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
@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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Kotlin, you can concat it like this:
"https://elevation.mapzen.com/height?json={\"shape\":[{\"lat\":$latitude,\"lon\":$longitude}]}"
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this the try
Fixes: #1122
Changes made: