SDK - Scenery development question - Web-Mercator

  • @IPACS,
    Thanks much for the SDK release. I've tried everything and thanks for the new airport, new aircraft with great visibility, and the sample data read/write application which compiles and executes with VisStudio2015 just fine.
    I wanted to add a very simple airport near my home in San Diego (Oceanside Municipal) but I really don't get the web-mercator coordinates. I have used websites and actual C++ code to be able to go from Lat,Lon to web-mercator (and back again) but I can't match the numbers that you used for Kingman objects - Example:

    <[vector3_float64][position][24043.51308231 51802.69537268 0]> <<<<=======

    From editing those web-mercator numbers (by 0.1), and then seeing the scenery shift, I see that the units are 100 meters (I think), but when I enter those coords ( 24043.51308231 51802.69537268) * 100.0 into my converters, I get lat,lons which don't make sense to me (shouldn't they be like the lat,lon for Kingman airport (-113, 35)? Also, what is your longitudinal reference point ? Could you please explain these? There must be some scale factors I don't know about.
    I am using simple equations like the following that I found - they agree with some online converters:
    East = (180.0 + lon) * 20037508.34 / 180.;
    North = log(tan((90.0 + lat) * PI / 360.)) / (PI / 180.);
    North = North * 20037508.34 / 180.;

  • Here are the formulas we use to get from web mercator to lon lat and vice versa. We simple
    did a copy/paste from our source code. tmvector2d is just a simple structure containing
    two values:

    struct vector2d
      double x;
      double y;

    So here are the two function. Note lon lat are always in radians.

    We strongly recommend to use web mercator for now as lon lat adds some additional complexity. We do support lon lat as well, but we have to create a sample first.

  • @IPACS,
    Thanks very much for the web-mercator equations! That will really help. Could you please say what TM_PI is. EDIT (I guess it is also PI)

    Now, a few questions about scenery development and comparing it to FSX. In FSX/ESP/P3D there are libraries of objects that we can use for a given airport or scenery area in general - all we have to know is a GUID - a unique identifier - and then we can place that object with a given Lat-Lon, angular orientation- primarily a yaw setting, and scale factor. Is there any chance FS2 will sometime support that idea. Then I don't have to have the source for the object - in this case,the max file.
    In FSX, we can generate a simple runway system without having to actually model the runway - just supply the location, orientation, and lighting parameters.For simple runways, that would be a nice feature. There is a freeware tool - ADE( - that many of us use to make a fairly accurate runway model using an underlay of the aerial image. Also, freeware FsEarthTiles allows us to get an aerial image BMP file with accurate geo corners.
    The above two features would allow users or potentially third party addons like Instant Scenery 3 to be able to help us fill up the world where we really care.

    Thanks for a super product


  • Hello Dave,

    I've also worked with ADE in the past and it has its pros and cons. Its quite easy to create a custom airport but I found it rather difficult to place scenery objects like buildings, cars, trees accurately and I never got any AI traffic to land on them. Maybe once I have the editor for Aerofly FS 2 aircraft somewhat finished I could start my next project, an airport generator/editor like ADE.

    The IPACS scenery development team works with professional modelling tools like 3Ds Max, Cinema 4D, Coral and Photoshop allowing them to customize every line and texture. While airports can be modelled in 2D just like every airport in FSX is, they can also be modelled in 3D when you have an accurate ground mesh for example (Zurich is one of them as far as I know). "Flat" airports will then be bent by the Aerofly FS 2 engine to fit the local curvature of the terrain (unlike FSX).

    And yes, there is something called "xref" in the Aerofly FS 2, a library or aircraft models, building and runway textures. I don't know how they are placed at the airport, could be added to the SDK if there is a way to do it without publishing the original models...


  • Jan,
    Thanks for your thoughts. As far as ADE, I just use it with an ortho-rectified aerial image from FsEarthTiles so I know the lat/lon corners, and then lay out the runways and taxiways over the real image - and save that - no hangars, no aircraft,etc. Then I use Flight1 Instant Scenery 3 to select library objects (including ones that I have added - aircraft, buildings, trees, cars, towers, ILS shacks,etc...) and move them carefully into place using the realtime FSX/P3D screen to see that they are going to the exact spot and orientation I want - which then updates the placement BGL file. I can fly right then without having to restart and test, restart and test! One to two hours later, I have a pretty good airport - assuming that a flat rectangular area is OK. If I need some different elevations, then SbuilderX is utilized to fiddle with terrain height. Instant Scenery 3 is $30 - wonderful - the other tools are freeware - BTW, add ModelConverterX from into the mix in order to view and fixup the actual objects.

    @IPACS - I now get the correct answers for lonlat to web-mercator conversion at Kingman - BUT not exactly, either my trig functions are different (I'm using Visual Studio 2015 with everything being "double" ) or my values for PI and TM_PI and Rad_to_Degree are slightly different - if you could provide those, it would be helpful. Again, thanks for the code - pretty much what I had but different scale factors. I now can place some objects at KOKB - my home airport in Oceanside, CA. Thanks again!

  • Jet-Pack (IPACS),
    You say you haven't seen the variable "PI" in the Aerofly code:
    But, from above in this thread:

    tmvector2d LonLatFromWebMercator( const vector2d webmercator )
    vector2d lonlat;
    lonlat.x = ( webmercator.x * 2.0 * PI / 131072.0 ) - PI; <<=============
    lonlat.y = webmercator.y - 65536.0;
    lonlat.y *= -2.0 * TM_PI / 131072.0;
    lonlat.y = exp( lonlat.y );
    lonlat.y = atan( lonlat.y );
    lonlat.y = 2.0 * ( lonlat.y - PI / 4.0 ); <<====================
    return lonlat;

    I would imagine that it has the same value as "TM_PI" but since I am not exactly getting the correct web-mercator values, maybe there is some difference.