Sign in to follow this  
Guest artmartin

Getting geo position from photo texture filenames?

Recommended Posts

I know I once saw an article about this but can't find anything at this time. Scenery texture tiles have very long numerical names like 003020000102101su.bmp and I know those digits represent where in the world that tile exists. I need to know this because I'm adding a feature to my new program where a user can view the tiles on a mosaic and be able to see how they fit with one another. When one lays them out in alphabetical order, some fit together properly and others don't. Anyone have a key to the format? Art Martin

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi Art,Have a look at TCalc by Rhumbaflappy. If I remember correct he has also included the source code of his tool and you should be able to see how he calculated them there.

Share this post


Link to post
Share on other sites

Hi Art,If you want I email you (later today) my VB code to build the file name from the location.Regards, Luis

Share this post


Link to post
Share on other sites

I've been looking at these recently too. The files are build up in blocks - 1, 4, 16 then 64. The first block for the 1033 1033 000 sequence is:000 001002 003then it grows to:001 002 010 011003 004 012 013020 021 030 031022 023 032 033and then to:001 002 010 011 100 101 110 111003 004 012 013 102 103 112 113020 021 030 031 120 121 130 131022 023 032 033 122 123 132 133200 201 210 211 300 301 310 311202 203 212 213 302 303 312 313220 221 230 231 320 321 330 331222 223 232 233 322 323 332 333That's in my neck of the woods anyway - I don't know if this sequence changes with Latitude. You end up with 64 textures in an 8 x 8 square with the start bitmap being 10331033000000.bmp and the final one being 103301033000333.bmpIt's your program that got me started on this! :)boneshttp://fsaviation.nethttp://www.precisionmanuals.com/images/forum/ng_driver.jpg

Share this post


Link to post
Share on other sites

The names of CUSTOM textures is a quadtree.The number at the right is the LOD13 quad.The numbering is much like land parcel descriptions in the US:NE quarter of the NW quarter of the SE quarter....Dick

Share this post


Link to post
Share on other sites

Luis, would love to see it. My email is azstrummer(nospam)@aol.(nospam).com.Art

Share this post


Link to post
Share on other sites

Well, what I learned from looking at his source code is that it'll be almost impossible to go backwards from the filename to get the lat/long of the tile. The calculations are of the sort - take the latitude, perform a bunch of math on it and, if the result is odd, put in a 1 otherwise a 0. Same with the longitude, if it's result is odd put in a 0 otherwise a 2. Then add the two together and that ends up one of the digits of the 15 digit number. Each digit then can only be a 0, 1, 2, or 3. To get back to the lat/long from those options is mathematically impossible. Think the better task is to look for patterns as bones is doing below. Preliminary work there was making my eyes cross yesterday though. Tough looking at a string of 15 numbers and picking out characters from it without getting off in position. There has to be an easier way. Art

Share this post


Link to post
Share on other sites

Hi Art,Would it not be possible to see how the LOD squares are arranged from that source code? One you know which LOD square it is (for example cell numbers), it should not be too hard to find the lat/lon, as the size in degrees is fixed for these squares.

Share this post


Link to post
Share on other sites

I would suppose so but the code has absolutely no commenting and it's difficult to deduce just what equation goes with what screen output. The program is a wonderful addon but I have to admit that some of its output is a bit cryptic to me and my limited knowledge of lod design and placement. I've only begun to scratch the surface of scenery design and this is all a bit overwhelming at times. I know I saw something on one of the forums one day that laid out character by character just what the tile names stood for and I just can't find that reference again. I'll continue searching in my lack of spare time.Art

Share this post


Link to post
Share on other sites

>Well, what I learned from looking at his source code is that>it'll be almost impossible to go backwards from the filename>to get the lat/long of the tile. Hi Art,I do not know if you are referring to my source code as my first email (with a good destination address) was returned back to me. I tried a second time but I do not know if you got it.In any case it is very simple to go back from the file name to the location of the tile. I have just wrote a VB function to do that. I did not check it, but it would be very simple to correct it if you find any error when you run it. Regards, LuisPublic Function Custom2LL(ByRef Lat As Double, ByRef Lon As Double, ByVal FileName As String) As LongDim Char As String, N As LongDim DeltaLat As Double, DeltaLon As Double' Lat and Lon are passed by reference and, on exit, they' hold the latitude and longitude of the NW corner of tile' During the calculations:' Lat goes from 0 (north pole) to 180 (south pole)' Lon goes from 0 (W180) to 360 (E180)' If a wrong FileName is given, the function returns 0' otherwise returns 1Custom2LL = 0' the dimensions of a LOD0 quadDeltaLat = 90DeltaLon = 120' the NW corner of the flattened earthLat = 0Lon = 0' examine LOD0Char = Mid(FileName, 1, 2)If Char = "00" Then ' do nothingElseIf Char = "01" Then Lon = DeltaLonElseIf Char = "10" Then Lon = DeltaLon + DeltaLonElseIf Char = "02" Then Lat = DeltaLatElseIf Char = "03" Then Lat = DeltaLat Lon = DeltaLonElseIf Char = "12" Then Lat = DeltaLat Lon = DeltaLon + DeltaLonElse Exit FunctionEnd If' and then examine LOD1 up to LOD13For N = 1 To 13 DeltaLat = DeltaLat / 2 DeltaLon = DeltaLon / 2 Char = Mid(FileName, N + 1, 1) If Char = "0" Then ' do nothing ElseIf Char = "1" Then Lon = Lon + DeltaLon ElseIf Char = "2" Then Lat = Lat + DeltaLat ElseIf Char = "3" Then Lat = Lat + DeltaLat Lon = Lon + DeltaLon Else Exit Function End IfNext N' got here > no error' revert to normal latitude and longitudeCustom2LL = 1Lat = 90 - LatLon = Lon - 180End Function

Share this post


Link to post
Share on other sites

Thank you. Thank you from a very burned out programmer that was dreading figuring this out on my own. Art

Share this post


Link to post
Share on other sites

Luis, only found one error. Lats and longs were coming out quite a bit off and found that in this line: Char = Mid(FileName, N + 1, 1)it should read: Char = Mid(FileName, N + 2, 1) or N + 3 (can't remember which one worked. Don't have the code here at work)Once I changed that the coordinates came out perfect. Now for another question. I started creating my mosaic display by using the assumption that all tiles on the same row would have the same latitude value and all tiles in a column would have the same longitude values. It that a correct assumption with the world not being perfectly flat? It seemed to work for a directory that had few tiles but a larger one gave me weird results. Course I was doing all this way past bedtime last night so it may have just been my eyes and brain not focusing right. I'm thinking that it's possible all in a row or column will be almost exact over a large area so I may have to do some rounding for my comparisons.Art

Share this post


Link to post
Share on other sites

Hi,Yes, it should be N+2. The answer to your question is yes. FS uses a Geographic Projection of the Earth. That means that the whole Earth is represented by a rectangle of 360 degrees of longitude by 180 degrees of latitude. I have not tested your program (yet!) and I do not know if you are using (or not) constant width Areas (or LOD13 squares). I think you should take this into account. For example at a latitude of N40 the Areas are about 1.2km x 1.2 km. But in the equator they are larger (1.2km x 1.6km). And, near the poles, they are very thin. Here is a table:http://www.ptsim.com/downloads/sdk_lod.htmwhere you see that the dimension of the LOD13 quad is 1221 meters (height) by 1628 meters (width) at the Equator. The height is constant. The width decreases with latitude and a simple formula is:width = 1628 * cos( latitude)Hope this information is useful,Luis

Share this post


Link to post
Share on other sites

Well if the height of the Lod13 quad is constant then that should imply that for each row of tiles that the latitude values are exactly the same. That makes things easy for ordering the tiles then. Simply have to order the columns within each row by their longitudes and their position on the full mosaic is simple to compute. I'm really not dealing with the low level cartographic calculations at all in my program. The texture files are a fixed size in pixels (256 X 256) and that's the easiest way to deal with them in multiples of that size. Trying to skew them for the tiny differences over the small distances they represent would be an exercise in futility. All FS cares about in regards to entries in an .agn file is their relative location within a 1 X 1 grid (from -.5 to +.5). Nothing is coded to lat/lon. Only reason I'm even caring about texture tile physical locations on the world is to create a mosaic of those tiles to give the user an easier way of deciding which tile to edit in a huge scenery area. I can only show about 60 adjacent tiles on a screen at one time anyway so even if there's quite a skew across the entire scenery image, it'd be pretty unnoticeable over a 10 tile wide grid. Art

Share this post


Link to post
Share on other sites

>I started creating my mosaic display by>using the assumption that all tiles on the same row>would have the same latitude value and all tiles in>a column would have the same longitude values.>It that a correct assumption with the world not being>perfectly flat? It seemed to work for a directory >that had few tiles but a larger one gave me weird>.... so I may have to do some rounding for my>comparisons.Art,You are perfectly correct, the tiles should align on lat/long. You can use fairly crude rounding as the difference in latitudes for each row is 0.010986328125 deg and longitude (column) is 0.0146484375 deg.George

Share this post


Link to post
Share on other sites

>Only reason I'm even caring about texture tile physical>locations on the world is to create a mosaic of those tiles to>give the user an easier way of deciding which tile to edit in>a huge scenery area. I can only show about 60 adjacent tiles>on a screen at one time anyway so even if there's quite a skew>across the entire scenery image, it'd be pretty unnoticeable>over a 10 tile wide grid. Hi Art,I agree this is not very important for the anotation part of scenery design. Since I introduced this discussion here allow me to develop a litle further (I could start a new thread, but I think it is best to keep things together). In making photo scenery we must georefernce our phototiles. In extreme north (and south) regions that means a lot of predistortion. Land class scenery, for example, uses the same undistorted phototiles from the Equator up to (I think) 80 degrees of latitude (N or S). Here are illustrations of this:http://www.ptsim.com/downloads/sbuilder/land70.jpg that shows 4x3=12 land class tiles placed around N70 W10. I also placed the 12 tiles at N0 W10 but unfortunately I did not keep the same zoom:http://www.ptsim.com/downloads/sbuilder/land00.jpgStill, we clearly see the difference on the real size of the LOD13 rectangles. In Flight Simulator these 2 sceneries look like this:http://www.ptsim.com/downloads/sbuilder/fsland70.jpghttp://www.ptsim.com/downloads/sbuilder/fsland00.jpgKind Regards, Luis

Share this post


Link to post
Share on other sites

Thought you'd get a kick out of the outcome of all this. Here's a screenshot from the mosaic file browsing page I've created. Works wonderfully. The red boxes are around tiles that already have autogen created, the green for the ones that don't.Arthttp://forums.avsim.net/user_files/112138.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this