B4J Question Math help B4J/JAVA

DonManfred

Expert
Licensed User
Longtime User
I did wrote a tileproviderfor b4a to use tiles generated by a Python Script.


IN: int x, int y, int Zoom
to match the tilenames with the y value, i needed to use this code to transform y

The Solution was to use this code (i found somewhere in the internet: don´t know what exactly it is doing but it was the solution. ;)
Java-Code
B4X:
          int reversedY = (1 << zoom) - y - 1;

For the tileprovider this was ok.

Now i´m in the need to do the Opposite. I have X, Zoom and the reversedY and i need Y.

Can anybody help me in this?

Ideally i would prefer to get a B4J Solution as i need to use it in B4J.
 

udg

Expert
Licensed User
Longtime User
Hi Don, have a look here.
So, "1 << zoom" should mean "shift left the representation of number 1 by zoom positions".
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
This is translate
B4X:
Dim ReservedY as int = (Bit.ShiftLeft(1,zoom) - y - 1
After i invert it
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Ok, so you now rewrote the java-part, right?
The javapart is already working in my b4a Lib and is OK.

BUT now i need the opposite. In B4J i need to evaluate Y from the given reversedY, Zoom and X Values.
Correct
B4X:
Y=Bit.ShiftLeft(1,zoom)-ReservedYReservedY-1
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Work it?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Looks good. GREAT. Thank you very much!

I need to check answer from my customer as he is using a Windowssoftware where the Tiles should be used. The Software is using a SQLite DB for the Tiles.
The Import to the SQLite is already done; must be tested now.

I´ll inform you about the results.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Looking at it better than code is actually a simple difference from a basic exponent 2

ReservedY = 2 ^ zoom-y-1

Probably in php it is easier to shift that the elevation to powern. In B4X. Would be:

B4X:
 ReservedY = Power (2, zoom) -y-1

It could also be understood as a 2-compliment
 
Last edited:
Upvote 0
Top