L3DT users' community
Large 3D terrain generator

Google Maps plugin

Correspondence concerning plugins and scripts; development, use, bugs and ideas.

Google Maps plugin

Postby SeerBlue » Wed Nov 15, 2006 3:50 pm

Actually the gmap plugin would not be that difficult, if one inverts the x,y of the tiles on export they are in the proper sequence for google maps, and L3DT will already export 256x256 tiles.
The hard part would be the naming, a google tile is named 300_256_8, as in the x and y and the zoom factor (8), for example.
So the plugin would just have to remove the x and y and insert _ (underscore) as a seperator, and add an underscore and the zoom factor.
A interface could be designed to allow the input of the zoom factor manually.
This would be the easy way, as all the tiles would start at 0,0, or in gmaps -180 (west) and 85 (north) degrees (approx. gmaps do not map to the north/south poles). So you could do multiple layers simply by starting at the largest you wanted, generate your 256x256 tiles,and then halve the image size and repeat

zoom level from furthest out to most detailed

zoom level x y total number tiles
0 1 1 1

1 2 2 4

2 4 4 16

3 8 8 64

4 16 16 256

5 32 32 1024

6 64 64 4096

7 128 128 16384

8 256 256 65536

9 512 512 262144

10 1024 1024 1048576

11 2048 2048 4194304


12 4096 4096 16777216

13 8192 8192 67108864

14 16384 16384 268435456

15 32768 32768 1073741824

16 65536 65536 4294967296

17 131072 131072 17179869184

18 262144 262144 68719476736

19 524288 524288 274877906944

20 1048576 1048576 1099511627776


For example a 32kx32k L3DT Texture map would be 125 tiles wide by 125 tiles high for 15625 total tiles, which would fall between Googles zoom 6 and 7. Zoom 6 requires 4096 tiles to cover the globe and zoom 7 needs 16384. But you could, if you wanted, put your tiles in any zoom range, as long as geo-referencing was not a consideration, and restrict your custom map extents and zoom slider range via javascript so only your map was displayed, and no one would know.
Placing L3DT tiles in specific coordinate space would be more difficult. Say you had a map from a game you developed, and you wanted a gmap that displayed that map in relation to real world co-ordinates so players could have a spatial reference, or place markers on locations they have been to or fought battles at (whatever)...
Google Maps sets the tile by its tile name , and the upper left corner of that tile has specific coordinates at each zoom range, so unless you had a real big image that covered the globe at all the zoom ranges you wanted from zero to, say 8, (so you could just tile from 0,0 to whatever your lower right tile would be, following the table above), you would need some way of inputting the start tile's x and y, or upper left corner, (say 24_34_5) for your best zoom, and have L3DT name them all from there upon tiling ( easy enough, input box for tile x,y, and zoom)...but then, when you zoom out a step (ie scale the image down in L3DT by half before exporting tiles) now you need to know what the start tile would be in zoom 4 (one zoom out).
If you look above you see that each zoom range uses images measuring 256x256pixels for tiles. So in zoom 0 there is one tile(1x1 is 1), in zoom 1 there are 4 tiles (2x2 is 4) and so on...so if zoom 5's fictional upper left tile was 24_34, (if my math is right) the corresponding zoom 4 tile should be 12_17_4..BECAUSE 24 divided by 2 = 12, AND 34 divided by 2=17.
Zoom 3 should be (and this is where it gets hard) 6_8.5_3...can't get it to be exactly on the tile border at this point, we need 6_8_3, so L3DT, or the plugin, would have to pad the image out on the top with128 pixels so that both the left side and the TOP side aligned with the latitude and longitude of Google Maps tiling scheme. Otherwise when the map was zoomed the maps/images would not be aligned. The same applies if you end up with a fraction for the X, as in 16.5_8_3, except in this case it would be the left hand side that needs padding to get 16_8_3.
I think, but I may be wrong, that l3dt already pads images on export, ie export a 1024 image in tiles of 300x 300 pixels, you end up with a black border filling in the excess space to make a 4x 4 grid of tiles, as 1024 divided by 300=3.413333, but it pads the top (good) and the right hand side (not good, Google maps are set by the top and left, so that would need to be where the padding was done)


So, if geo referencing is wanted, even just approximate referencing to have the artic areas fall in the right real world zones, or referencing so Google's scale bars are accurate (if you use Googles maps you will see that the scale bar changes as you travel north or south from the equator when zoomed way out) we would need some way of inputting the starting tiles name in x,y, and zoom and the number of zoom ranges we wanted to tile from the original "best zoom, closest zoom" out:
As in our map would start out at it's largest size, it would be tiled, halved, tiled, halved, tiled and so on. The plugin would have to know how to find the correct tile start name for each succesive zoom(x and y taken from the original input and divded by 2, zoom range taken from original input minus 1, for each step) and how to pad the image at either the top or left hand side (or both) if the computed tile name was a fraction, pad it correctly(I think, but have not really done the math, the padding should always be 128 pixels, or half of the tiles size) and tile that image...but then it would have to return to the original image to correctly size the image for the next zoom level, as the padded image from the previous image would not be suitable for use as the new zoom range may not require padding, or may require different padding (perhaps left side needs 128 pixels instead of the top).
And this would not be real geo-referencing, as Google uses the Mercator projection to stretch the image. But in most cases it would probably not be a problem as the L3DT created maps/textures would not have a "real world" association.
This is just some of the things I have run into manually tiling maps for google, so there may be some more bugaboos in there, the more spatially accurate you try to get, ie maps that are in mercator projection to align with Googles ability to report latitude and longitude, the more work would be neede to make a plugin. But if you just want to display your map on GMaps, this should do it, I would suggest multiple zooms, takes up alot of server space, but one of the benefits og Gmaps is the ability to zoom out, get a broad overview of the map, and zoom in for detail. Having just one layer, even a highly detailed one, does not give the same sense of scale or relationship.
Anywho, a caffiene and Marlboro fueled idea, but writing the plugin is beyond me. SeerBlue
Check Out Me-DEM
SeerBlue
Luminary
 
Posts: 68
Joined: Thu Dec 01, 2005 12:42 am

Postby DeathTwister » Wed Nov 15, 2006 9:10 pm

yes I would like to bring google maps into L3DT, what a great idea. I have google earth, and not much I can really do with it, until maybe now if I could google in Terrains, that would be awesome to be able to grab that data and make it easy for dumb artists /smiles......to bring into L3DT.

DT
User avatar
DeathTwister
Dearly missed
 
Posts: 562
Joined: Thu Dec 15, 2005 12:30 pm
Location: Klamath, CA.

Postby SeerBlue » Wed Nov 15, 2006 11:05 pm

hey DT, google maps and google earth are different creatures. Google maps only display 2d images, like satellite imagery and such. Google earth displays the imagery draped over a heightfield, but, at my last look into it a while a go, all the heightfield info is streamed, so there is no real cache...unlike World Wind which does use a cache so it is feasible to create your own cache pack in .bil format once the naming scheme for the tiles is sussed, and modify the xml to pull the heightfield from there.
Since Google Earth streams the heightfield (kml/kmz)there was no way to get your own heightfield data into it from your own computer , unless you pony up for the full package, then you can stream whatever you want from a server. Ohh to be rich. SeerBlue
Check Out Me-DEM
SeerBlue
Luminary
 
Posts: 68
Joined: Thu Dec 01, 2005 12:42 am

Postby DeathTwister » Thu Nov 16, 2006 3:09 pm

Ya I know what youir talking about and the full google package is what 3-400 bucks? not worth it your right.
I have the 20.oo buck version, gues not good enough ROTFL hahahahahahaha, thanks for the info on how that works bro. Didn't know, but I figured if it was cheep so was the code hahahahaha, DER.

What is a good program to get info that don't cost an arm and a leg? Sure would like to have good software to get good quality dems/HHT fields in L3DT though. I have had some trouble with that of late when I get the change to mess with that.

Whats World Wind? have a link?

DT
User avatar
DeathTwister
Dearly missed
 
Posts: 562
Joined: Thu Dec 15, 2005 12:30 pm
Location: Klamath, CA.

Postby SeerBlue » Thu Nov 16, 2006 4:12 pm

DT for info on dems and such I put a reply in the resources,,to keep this one on topic SeerBlue
Check Out Me-DEM
SeerBlue
Luminary
 
Posts: 68
Joined: Thu Dec 01, 2005 12:42 am

Postby DeathTwister » Fri Nov 17, 2006 1:15 pm

KK /smiles
DT
User avatar
DeathTwister
Dearly missed
 
Posts: 562
Joined: Thu Dec 15, 2005 12:30 pm
Location: Klamath, CA.


Return to Plugins and scripts

Who is online

Users browsing this forum: No registered users and 5 guests