-
Notifications
You must be signed in to change notification settings - Fork 215
[QUESTION] Octant Position Logic #4
Comments
Out of curiosity, how big were your .obj files? I just created my first one and it's 1gb. It's gonna take a long time to load - I can't imagine having to do this multiple times for the same site. Also, what model units were you using during import? |
Mine were 50-100mb, just imported them and they were there (not in the viewport though, see blender.md) |
edit: s2 geometry is a quadtree based. |
Unfortunately not. Also, no idea how to get correct sub-octants more efficiently (for OBJ export) or how to calculate visible octants from a camera via BulkMetadata, without loading all NodeData. There is BVH stuff in the NodeData and OBB stuff in BulkMetadata; not sure if that's only for collision or if it helps with this stuff. My guess would be that BVH is used for collision here because its packed alongside the meshes. I think OBB might be usable for octant calculations, because BulkMetadata is always traversed. But again, not sure at all. Hopefully someone here will figure it out. |
A workaround could be inputting gps coordinates, letting puppeteer open them in gmaps, and let all nodeInfo be parsed and downloaded for a given scene/position. Guess a webgl context is needed to make the calls to kh.gmaps |
I tried to make out some logic behind the octants, I'm not sure if this is know or not? The earth is made up of 8 octants: 02,03,12,13,20,21,30 and 31 which represents an octant of the earth each. The sub-octant is labeled according to the quadrant with respect to the parent: 0 (South West), 1 (South East), 2 (North West) or 3 (North West). Looking at the example in the readme: 20527061605273514 we see the following stating from the 205 octant:
Perhaps somebody can figure out how this logic relates to coordinates. |
A dirty script to convert octants to lat/long bounding box: |
@LexSong Is the reverse also possible this way? Tried brute-forcing it but got duplicate midpoints for octants: 0 and 4
1 and 5
2, 3, 6 and 7
Btw. figured out how BulkMetadata's oriented bounding box looks like: |
I have no idea how the z-axis separation works here. We can only assume that the block 210 and 214 both have the same latitude and longitude bounding box, but are in different height, and block 214 is higher than 210. |
edit: Wrote this script to convert lat long to octants: https://gist.github.com/retroplasma/a2511c08efb73d89699985fbdc0b5278. It uses your method and brute-forces through BulkMetadata. I committed this first but then noticed that it doesn't work for some coordinates. |
Method using OBB ray intersection, please test: https://github.com/retroplasma/earth-reverse-engineering/blob/443a3622ce9cb12cd4460cc6dc7999cc703ae67f/experimental_latlong_to_octant.js Usage:
|
I rewrote I'm not familiar with javascript, however I think it may be helpful. |
By the way, |
damn 😄 Yours is very elegant! What is the logic behind it btw? Guess there's some fixed order (like @erikmol said? I see a +4 in there). Feel free to open a PR btw if you want. |
Just traverse the octree as the original |
Ah thanks! Think I got it, it works because the octants split at the proper angles. That's nice. |
@LexSong please let me know if you want a PR or want me to directly implement it. planning to adapt it and add to README |
I will send the PR if you're OK with the current state. I think that there should be clearer way to determine child octants. However the script is already useful now. |
sure, send it. we can continue to improve it. it's very useful already |
@TysonGersh this is similar to this issue. Try going up the octant path a bit. 214263605143426 should work. You can drill down from there. It looks like this at max-level 18: |
I updated lat/long to octants script in my fork here: https://github.com/LexSong/earth-reverse-engineering Currently the output is like this:
You'll get multiple octants in the same level if the level is deep and there is large height difference. |
@TysonGersh Most of it is at 214263605143426 (#4 (comment)) The rest can be found using LexSong's script (https://github.com/LexSong/earth-reverse-engineering/tree/find_overlaps): From octant level 15: How to use find_overlaps.py: |
This is perhaps related to what's been discussed already but has anyone worked out to correctly assign a spatial reference to the output NodeData dump? I've gone through 4326, 3857, and even Google's weird Mercator_2SP but no joy, they're always deep within the Earth, somewhere in the mid Atlantic. I was thinking of forcing a false projection using the octant bounding boxes but haven't got anything to work yet. |
It looks like that the mesh is on an ECEF coordinate system, but on a pure sphere not an ellipsoid in usual GIS systems. |
I think you're right! Plugging some of the ECEF coordinates from the obj file into this https://www.oc.nps.edu/oc2902w/coord/llhxyz.htm Produces WGS84 coordinates that are where I'd hope to find them (just north of Melbourne).
Looks as though the common reference for this is ECEF to LLA (Lat, Long, Altitude): https://stackoverflow.com/questions/30307311/python-pyproj-convert-ecef-to-lla Further edit: This looks to be ideal, converting the entire obj file at once: https://github.com/TerriaJS/obj-transform although I have no idea how to use it, any ideas? |
So I just fiddled my way through getting a model of the entire area I wanted. My site was always in the corner of whatever model I was getting at octant 16. It's in the bottom right of 2053736372736176 20 The thing I need to figure out now is if the angle of the models is related to their position on the globe. So I'm off to get something from Australia to see if its upside down. |
I understand that two octants with value difference by 4 could be at different heights, but why is it that 2, 3, 6, 7 are all having the same geographical location? I see "if n == 90 or s == -90, then stop dividing the longitude by 2" in the octant_to_latlong.py script, can someone explain the theory behind? |
Did you find out a (logical) way on how to get the correct octants of a given coordinate? the positioning seems rather random and it's nearly impossible to get an obj from an POI without trial & error or loading all (>30) octants of any given viewport on google maps into the nodejs script.
The text was updated successfully, but these errors were encountered: