Jump to content
Sign in to follow this  
rhumbaflappy

Hows is the VTP2Point calculated?

Recommended Posts

Guest

Hi,In my little Island project I need to add the coastline to the LWMpolygon. I need a formula for how to calculate the VTP2Points from a given coordinate in latitude and longitude.Any help is appreciated//Anders

Share this post


Link to post
Share on other sites
Guest

Hi Anders!Using Rhumba's TDFCalc3 will give you the VTP2 point you are seeking. Install and also install FSUIPC.dll and you can open FS, get a top down view, slew to you coastline... open TDFCalc3 and it will give you the coordinates of the point you are seeking. Repeat as necessary to get the other points in the shoreline.You might also see this thread:http://ftp.avsim.com/cgi-bin/dcforum/dcboa...10&viewmode=allSeems they are using SCM2VTP to make the shorelines as well as roads.

Share this post


Link to post
Share on other sites

Hi Anders.In addition to the info in the FS2002 terrain SDK, here's some math routines I use... they're in Delphi, but a translation should be easy.// ===================================================== LOD5x := Floor( ( Longitude ) / 3.75 ) ; LOD5y := Floor( ( Latitude ) / 2.8125 ) + 1 ; LOD5xLon := LOD5x * 3.75 ; LOD5yLat := LOD5y * 2.8125 ; LOD5xPoint := Ceil( ( Frac( ( Longitude + 180 ) / 3.75 ) * 3.75 ) / 0.0146484375 ) - 1 ; LOD5yPoint := 256 - Ceil( ( Frac( ( Latitude + 90 ) / 2.8125 ) * 2.8125 ) / 0.010986328125 ); LOD8x := Ceil( ( Longitude + 180 ) / 0.46875 ) - 1 ; LOD8y := Ceil( ( 180 - ( Latitude + 90 ) ) / 0.3515625 ) - 1 ; LOD13xSub:= Ceil( ( Longitude + 180 ) / 0.0146484375 ) - 1; LOD13ySub:= Ceil( ( 180 - ( Latitude + 90 ) ) / 0.010986328125 ) - 1; LOD13x := Ceil( ( Longitude + 180 ) / 0.0146484375 ) - 1 - ( LOD8x * 32 ); LOD13y := Ceil( ( 180 - ( Latitude + 90 ) ) / 0.010986328125 ) - 1 - ( LOD8y * 32 ); LOD13xPoint := Ceil( ( Longitude + 180 ) / 0.000057220458984375 ) - 1 - ( LOD13xSub * 256 ); LOD13yPoint := Ceil( ( 180 - ( Latitude + 90 ) ) / 0.00004291534423828125 ) - 1 - ( LOD13ySub * 256 ); LOD8xPoint := LOD13xPoint + ( LOD13x * 255 ) + 4080; LOD8yPoint := LOD13yPoint + ( LOD13y * 255 ) + 4080; If LOD5x < 0 then LOD5x := 0; If LOD5x > 97 then LOD5x := 97; If LOD5y < 0 then LOD5y := 0; If LOD5y > 64 then LOD5y := 64; If LOD5xPoint < 0 then LOD5xPoint := 0; If LOD5xPoint > 255 then LOD5xPoint := 255; If LOD5yPoint < 0 then LOD5yPoint := 0; If LOD5yPoint > 255 then LOD5yPoint := 255; If LOD8x < 0 then LOD8x := 0; If LOD8x > 767 then LOD8x := 767; If LOD8y < 0 then LOD8y := 0; If LOD8y > 511 then LOD8y := 511; If LOD13x < 0 then LOD13x := 0; If LOD13x > 31 then LOD13x := 31; If LOD13y < 0 then LOD13y := 0; If LOD13y > 31 then LOD13y := 31; If LOD13xPoint < 0 then LOD13xPoint := 0; If LOD13xPoint > 255 then LOD13xPoint := 255; If LOD13yPoint < 0 then LOD13yPoint := 0; If LOD13yPoint > 255 then LOD13yPoint := 255; If LOD8xPoint < 4080 then LOD8xPoint := 4080; If LOD8xPoint > 12239 then LOD8xPoint := 12239; If LOD8yPoint < 4080 then LOD8yPoint := 4080; If LOD8yPoint > 12239 then LOD8yPoint := 12239; AreaFill1x := LOD13x; AreaFill1y := LOD13y; AreaFill2x := LOD13x DIV 2; AreaFill2y := LOD13y DIV 2; AreaFill4x := LOD13x DIV 4; AreaFill4y := LOD13y DIV 4; AreaFill8x := LOD13x DIV 8; AreaFill8y := LOD13y DIV 8; AreaFill16x := LOD13x DIV 16; AreaFill16y := LOD13y DIV 16; LWMHeight := Floor( Elevation ); LWMFraction := Ceil( Frac( Elevation ) * 256 );Dick

Share this post


Link to post
Share on other sites

Hi James.That's part of the Delphi code for TDFCalc3.p.s.I'll email you some info on VTP Method1's later today ( I hope ).Dick

Share this post


Link to post
Share on other sites
Guest

Hi Dick,That was exactly what I was looking for! THANK YOU!I'm in the lucky situation that I have a lot of map data that I "only" have to convert to BGLs. So I have made a little software that will do that for me. I have managed to calculate all the other values (cells, areas ,areapoints) but I'm having problems with the vtp2points. However by looking at your code I can see that I was on the right track but I made some misstakes which gave me incorrect values.So thanks again for the perfect answer. I have no problem in reading the code and translate it to Visual Basic ( I used to write a lot of Pascal code, however years ago).I'm willing to share my code as well if anyone cares to see it.Anders

Share this post


Link to post
Share on other sites

Hi Anders.I'm sure lots of people would like to see the code, and a lot more would like the program. :)I'm glad I could help.Dick

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...