DGL
https://delphigl.com/forum/

google earth kml file format
https://delphigl.com/forum/viewtopic.php?f=19&t=5489
Seite 1 von 1

Autor:  noeska [ Mo Mai 01, 2006 21:27 ]
Betreff des Beitrags:  google earth kml file format

on taking a look at the google earth kml file format, things are not as easy as they looked first.

a kml is basicly a xml document. (also there are .kmz files which are just kml files inside a .zip file)

a tutorial on the file format can be found here: http://www.keyhole.com/kml/kml_tut.html#polygons

as there are things called polygons i expted to be able to use

Code:
  1. glBegin(GL_POLYGON);
  2.  
  3. glVertex3f(x,y,z);
  4. .....
  5.  
  6. glEnd;


but that did not give the correct result. (bug i could just have misplaced the camera)

but looking at the coords i cannot detect a pentagon like shape inside it, unles is deeply hidden in the numbers behind the .

any ideas are welkom. it sure would be nice to be able to use google sketchup http://sketchup.google.com to design 3d models for use in your delphi opengl applications.

Autor:  La Boda [ Di Mai 02, 2006 12:08 ]
Betreff des Beitrags: 

Hmm it seems that the coordinates in the keyhole-tutorial differ from the second position after the dot. The values given in the tutorial seem like they are "earth coordinates". Have you already tried to delete the numbers before and scaled it to "bigger" ones? For example:
Code:
  1. -77.05788457660967 -> -7.88457660967

Autor:  Tokter [ Di Mai 02, 2006 15:32 ]
Betreff des Beitrags: 

Seems to work for me:
Code:
  1.     public partial class Form1 : Form
  2.     {
  3.         private Context m_Context;
  4.  
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.             SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  9.             SetStyle(ControlStyles.UserPaint, true);
  10.             SetStyle(ControlStyles.ResizeRedraw, true);
  11.  
  12.             m_Context = new Context(this, 32, 16, 0);
  13.         }
  14.  
  15.         protected override void OnPaintBackground(PaintEventArgs e)
  16.         {            
  17.         }
  18.  
  19.         protected override void OnPaint(PaintEventArgs e)
  20.         {
  21.             gl.Clear(gl.COLOR_BUFFER_BIT);
  22.             gl.Viewport(0, 0, ClientSize.Width, ClientSize.Height);
  23.             gl.MatrixMode(gl.PROJECTION);
  24.             gl.LoadIdentity();
  25.             glu.Ortho2D(-77.050, -77.06, 38.875, 38.865);
  26.             gl.MatrixMode(gl.MODELVIEW);
  27.             gl.LoadIdentity();
  28.  
  29.             gl.Color3f(1.0f, 1.0f, 1.0f);
  30.             gl.Begin(gl.POLYGON);
  31.             gl.Vertex2d(-77.05788457660967d, 38.87253259892824d);
  32.             gl.Vertex2d(-77.05465973756702d, 38.87291016281703d);
  33.             gl.Vertex2d(-77.05315536854791d, 38.87053267794386d);
  34.             gl.Vertex2d(-77.05552622493516d, 38.868757801256d);
  35.             gl.Vertex2d(-77.05844056290393d, 38.86996206506943d);
  36.             gl.Vertex2d(-77.05788457660967d, 38.87253259892824d);
  37.             gl.End();
  38.  
  39.             m_Context.SwapBuffers();
  40.         }
  41.     }

Autor:  BenBE [ Di Mai 02, 2006 20:50 ]
Betreff des Beitrags: 

Die angegebenen Koordinaten sind IMHO Kugel-Koordinaten auf der Oberfläche ... (bzw. in der angegebenen Höhe)

Autor:  noeska [ So Mai 14, 2006 13:36 ]
Betreff des Beitrags: 

i am not going for the glu.orhto2d solution.

Some further research on kugel-koordinaten got me this:

Zitat:
Q17. How do I convert Euclidean to Polar coordinates?
-----------------------------------------------------

With a Euclidean coordinate (x y z), the goal is to convert it into a
Polar coordinate (latitude, longitude, distance).

The conversion is as follows:

-----------------------------------------
distance = sqrt( x*x + y*y + z*z )

x /= distance;
y /= distance;
z /= distance;

xz_dist = sqrt( x*x + z*z )
latitude = atan2( xz_dist, y ) * RADIANS
longitude = atan2( x, z ) * RADIANS
-----------------------------------------


Q18. How do I convert Polar to Euclidean coordinates?
-----------------------------------------------------

With a Polar coordinate (latitude, longitude, distance), the goal is to
convert it into a Euclidean coordinate (x y z).

The conversion is as follows:

-----------------------------------------
x = cos( latitude ) . sin( longitude )
y = sin( latitude )
z = cos( latitude ) . cos( longitude )
-----------------------------------------


From: http://web.archive.org/web/200410111938 ... atest.html

Q18 should be the way to go, but this puzles me a bit as where te leave the third number from the kml file. Or should that be left as is?

As i already guesed the 3rd number is latitude. So i gues i can leave it unchanged (not sure though).

Autor:  Tokter [ Mo Mai 15, 2006 15:08 ]
Betreff des Beitrags: 

Sorry to dissapoint you but the earth is no Sphere :-). It's an ellipsoid and I think google earth uses WGS84 for it's coordinate projections. Which use an ellipsoid as it's base and not a sphere. A poolar to euclidean conversion may still be good enough but as bigger the models as less aquarate it will become.

Zitat:
Q18 should be the way to go, but this puzles me a bit as where te leave the third number from the kml file. Or should that be left as is?
As i already guesed the 3rd number is latitude. So i gues i can leave it unchanged (not sure though).


The third component is the altitude, you just build an altitude vector and add it to the x,y,z you get from the comversion.

Autor:  noeska [ So Nov 25, 2007 11:58 ]
Betreff des Beitrags: 

Sorry to kick this topic, but i found this nice obj export script for Google Sketchup:

http://sketchuptips.blogspot.com/2007/0 ... orter.html

It needs some tweeking and improvement. But it does its job nice for single non materialized meshes.

Autor:  Flash [ Mo Nov 26, 2007 19:03 ]
Betreff des Beitrags: 

kml ist ein ziemlich cooles, weil einfach zu verstehendes Format.

Genial ist, dass man in Google-Maps eine URL zu einem KML File angeben kann, und dies dann in Google-Maps angezeigt wird. So kann man ziemlich nett Infos visualisieren.

Autor:  noeska [ Mo Nov 26, 2007 20:14 ]
Betreff des Beitrags: 

The problem with kml is not the format but how coords are represented. Sure they are great for Google Earth. But they are not for when you want to use it with opengl in your own application.

Autor:  noeska [ Di Jan 29, 2008 20:16 ]
Betreff des Beitrags: 

Google now also released an sdk for the sketchup fileformat: http://code.google.com/apis/sketchup/do ... ubmit.html

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/