To decode coordinates it's not enough to have only two values (x, y).
As I understand they pass MBR in response, not direct coordinates.
It really depends on tile's boundary coordinates.
I'll give an example of decoding.
First, you should have tile's boundary.
If we have tile for all world they have them as:
-1800000000|1800000000|-850511288|850511288
That will be converted to:
let left = -1800000000 / 1e7
let right = 1800000000 / 1e7
let bottom = -850511288 / 1e7
let top = 850511288 / 1e7
And then if you have line of information like this:
30870710|2492727202|1200141117|20170|8177|18| Bagram
It contains MBR of an object and additional information. You can decode it using such code:
let str = '30870710|2492727202|1200141117|20170|8177|18| Bagram'
let temp = str.split('|')
let mbr = {
left: left + parseInt(temp[1], 10) / 1e7,
top: bottom + parseInt(temp[2], 10) / 1e7,
bottom: parseInt(temp[4], 10) / 1e7,
right: parseInt(temp[3], 10) / 1e7
}
// mbr correction
mbr.bottom = mbr.top - mbr.bottom
mbr.right = mbr.left + mbr.right
let obj = {
type: "Feature",
properties: {
"id": temp[0],
"name": temp[6],
"zoom": parseInt(temp[5], 10),
"mbr": mbr,
},
geometry: {
type: "Point",
coordinates: [(mbr.left + mbr.right) / 2, (mbr.bottom + mbr.top) / 2]
}
}