Re: [osg-users] convert GPS coordinates to local terrain coordinates

2007-12-04 Thread Glenn Waldron
Stephane,

When we deploy txp databases, we always create an archive.prj file to
accompany the archive.txp file. The prj file contains a WKT-format
description of the projection. (WKT is a standard format that OGR can read
directly.) This, along with the offsets in projInfo.txt, gives you
everything you need for spatial referencing.

As for the LA database, best guess would be either UTM 11N or California
State Plane Zone V. But that is just a guess. The real answer is to check
the source TerraVista project if you can. -gw

-- 
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791


On Dec 4, 2007 3:10 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

  Thanks Glenn,



 My txp file is « Los Angeles ».

 I'll have a look to OGR/GDAL and come back to you is any issue.



 By the way, the most important for my project is to know the projection
 type associated with the terrain is mandatory. So If I want to be compatible
 with any terrain, I need to introduce a kind of terrain's user description
 at selection time.



 BR,



 Stephane


  --

 *De :* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *De la part de* Glenn Waldron
 *Envoyé :* lundi 3 décembre 2007 19:10

 *À :* OpenSceneGraph Users
 *Objet :* Re: [osg-users] convert GPS coordinates to local terrain
 coordinates



 Stephane,

 The TXP doesn't explicitly contain its projection. You need to go back to
 the TerraVista project. We can make an educated guess though; Where is your
 database? City, country?

 As for converting the lat/lon, OSG does not do this natively. You can use
 OGR ( http://gdal.org/ogr/) which is part of GDAL. Or (shameless plug) use
 the osgGIS library (http://osggis.org) which has a SpatialReference class
 that encapsulates OGR/PROJ4 coordinate conversion.

 -gw

  On Dec 3, 2007 11:08 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

 Thanks Glenn,



 It helped a lot as I was completely wrong.



 My projInfo.txt file is as following, meaning my offsets are set to 0?



 My csm=Projected

 originlat=33.094356133212699

 originlon=-117.642398847633000

 zunits=1.000

 selectorId=6

 dcType=NONE

 dcSelectorId=0

 txpOffsetX=0.00

 txpOffsetY=0.00

 txpOffsetZ=0.00



 By the way how can I retrieve the terrain projection type?

 And then, how can I convert lat/lon to the terrain's projection?



 BR,


 Stephane


  --

 *De :* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *De la part de* Glenn Waldron
 *Envoyé :* lundi 3 décembre 2007 16:47
 *À :* OpenSceneGraph Users
 *Objet :* Re: [osg-users] convert GPS coordinates to local terrain
 coordinates



 Stephane,

 If you TXP database is in a flat-earth projection, like UTM or state
 plane, the osg::Ellipsoid functions will not help. They convert to and from
 geocentric (earth-centered) coordinates.

 TerraVista generates a  projInfo.txt file along with the TXP database.
 This contains the txpOffsetX and txpOffsetY properties that tell the
 local offset of the lower-left corner of your TXP terrain, relative to the
 geographic projection in which you generated the terrain.

 So to go from lat/lon to scene coordinates, you need to:

 1. convert lat/lon to the terrain's projection (e.g., UTM)
 2. translate the resulting coordinates by the offset in the projInfo.txtfile

 hth -gw

 On Dec 3, 2007 9:59 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

 Hello,



 I'm new on OSG scene.

 Here is my issue:

 I have a TXP terrain on which I know the local origin coordinates. This
 coordinates are:

 Longitude : -117.64

 Latitude : 33.09



 I now whant to know the local coordinates (within my TXP terrain) of a
 know location (GPS cocordinate):

 Longitude: -117.3636264412

 Latitude: 33.2940335740



 I use ElModel-convertLatLongHeightToXYZ to transform the goedesic
 coordinates in caretsian ones. What I need now if to transform the resulting
 coordinates according to the origin's location in order to take care of my
 offset.



 Any idea of how to perform this?



 I tried the following:



  OriLongitude=-117.64 /*origin*/;

  OriLatitude=33.09/*origin*/;

  OriAltitude=0;

  ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(OriLatitude),

  osg::DegreesToRadians(OriLongitude),

 OriAltitude,

 oriX,

 oriY,

 oriZ );





 ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(33.2940335740),

 osg::DegreesToRadians(-117.3636264412),


 0,

 x,

 y,

 z );





 xl=-sin(OriLongitude)*(x-oriX)+ cos(OriLongitude)*(y-oriY);

 yl=-sin(OriLatitude)*cos(OriLongitude)*(x-oriX)

   -sin(OriLatitude)*sin(OriLongitude)*(y-oriY)

   +cos(OriLatitude)*(z-oriZ

Re: [osg-users] convert GPS coordinates to local terrain coordinates

2007-12-03 Thread Stephane DUGUET
Thanks Glenn,

 

It helped a lot as I was completely wrong.

 

My projInfo.txt file is as following, meaning my offsets are set to 0?

 

My csm=Projected

originlat=33.094356133212699

originlon=-117.642398847633000

zunits=1.000

selectorId=6

dcType=NONE

dcSelectorId=0

txpOffsetX=0.00

txpOffsetY=0.00

txpOffsetZ=0.00

 

By the way how can I retrieve the terrain projection type? 

And then, how can I convert lat/lon to the terrain's projection?

 

BR,


Stephane

 



De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Glenn Waldron
Envoyé : lundi 3 décembre 2007 16:47
À : OpenSceneGraph Users
Objet : Re: [osg-users] convert GPS coordinates to local terrain coordinates

 

Stephane,

If you TXP database is in a flat-earth projection, like UTM or state plane, the 
osg::Ellipsoid functions will not help. They convert to and from geocentric 
(earth-centered) coordinates.

TerraVista generates a  projInfo.txt file along with the TXP database. This 
contains the txpOffsetX and txpOffsetY properties that tell the local 
offset of the lower-left corner of your TXP terrain, relative to the geographic 
projection in which you generated the terrain. 

So to go from lat/lon to scene coordinates, you need to:

1. convert lat/lon to the terrain's projection (e.g., UTM)
2. translate the resulting coordinates by the offset in the projInfo.txt file

hth -gw

On Dec 3, 2007 9:59 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

Hello,

 

I'm new on OSG scene.

Here is my issue:

I have a TXP terrain on which I know the local origin coordinates. This 
coordinates are:

Longitude : -117.64

Latitude : 33.09

 

I now whant to know the local coordinates (within my TXP terrain) of a know 
location (GPS cocordinate):

Longitude: -117.3636264412 

Latitude: 33.2940335740

 

I use ElModel-convertLatLongHeightToXYZ to transform the goedesic coordinates 
in caretsian ones. What I need now if to transform the resulting coordinates 
according to the origin's location in order to take care of my offset.

 

Any idea of how to perform this?

 

I tried the following:

 

 OriLongitude=-117.64 /*origin*/;

 OriLatitude=33.09/*origin*/;

 OriAltitude=0;

 ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(OriLatitude),

 osg::DegreesToRadians(OriLongitude), 

OriAltitude,  

oriX,  

oriY,  

oriZ );

 

 

ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(33.2940335740),

osg::DegreesToRadians(-117.3636264412), 

0,  

x,  

y,  

z );

 

 

xl=-sin(OriLongitude)*(x-oriX)+ cos(OriLongitude)*(y-oriY);

yl=-sin(OriLatitude)*cos(OriLongitude)*(x-oriX)

  -sin(OriLatitude)*sin(OriLongitude)*(y-oriY)

  +cos(OriLatitude)*(z-oriZ);

zl=cos(OriLatitude)*cos(OriLongitude)*(x-oriX)

  +cos(OriLatitude)*sin(OriLongitude)*(y-oriY)

  +sin(OriLatitude)*(z-oriZ);

 

But I still cannot have good results.

I have some doubts about the - sign applied to the longitude for a West 
direction.

 

Thanks for your help,

 

Best regards,

 

Stephane

 

 

 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791 

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] convert GPS coordinates to local terrain coordinates

2007-12-03 Thread Glenn Waldron
Stephane,

The TXP doesn't explicitly contain its projection. You need to go back to
the TerraVista project. We can make an educated guess though; Where is your
database? City, country?

As for converting the lat/lon, OSG does not do this natively. You can use
OGR (http://gdal.org/ogr/) which is part of GDAL. Or (shameless plug) use
the osgGIS library (http://osggis.org) which has a SpatialReference class
that encapsulates OGR/PROJ4 coordinate conversion.

-gw


On Dec 3, 2007 11:08 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

  Thanks Glenn,



 It helped a lot as I was completely wrong.



 My projInfo.txt file is as following, meaning my offsets are set to 0?



 My csm=Projected

 originlat=33.094356133212699

 originlon=-117.642398847633000

 zunits=1.000

 selectorId=6

 dcType=NONE

 dcSelectorId=0

 txpOffsetX=0.00

 txpOffsetY=0.00

 txpOffsetZ=0.00



 By the way how can I retrieve the terrain projection type?

 And then, how can I convert lat/lon to the terrain's projection?



 BR,


 Stephane


  --

 *De :* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *De la part de* Glenn Waldron
 *Envoyé :* lundi 3 décembre 2007 16:47
 *À :* OpenSceneGraph Users
 *Objet :* Re: [osg-users] convert GPS coordinates to local terrain
 coordinates



 Stephane,

 If you TXP database is in a flat-earth projection, like UTM or state
 plane, the osg::Ellipsoid functions will not help. They convert to and from
 geocentric (earth-centered) coordinates.

 TerraVista generates a  projInfo.txt file along with the TXP database.
 This contains the txpOffsetX and txpOffsetY properties that tell the
 local offset of the lower-left corner of your TXP terrain, relative to the
 geographic projection in which you generated the terrain.

 So to go from lat/lon to scene coordinates, you need to:

 1. convert lat/lon to the terrain's projection (e.g., UTM)
 2. translate the resulting coordinates by the offset in the projInfo.txtfile

 hth -gw

 On Dec 3, 2007 9:59 AM, Stephane DUGUET [EMAIL PROTECTED] wrote:

 Hello,



 I'm new on OSG scene.

 Here is my issue:

 I have a TXP terrain on which I know the local origin coordinates. This
 coordinates are:

 Longitude : -117.64

 Latitude : 33.09



 I now whant to know the local coordinates (within my TXP terrain) of a
 know location (GPS cocordinate):

 Longitude: -117.3636264412

 Latitude: 33.2940335740



 I use ElModel-convertLatLongHeightToXYZ to transform the goedesic
 coordinates in caretsian ones. What I need now if to transform the resulting
 coordinates according to the origin's location in order to take care of my
 offset.



 Any idea of how to perform this?



 I tried the following:



  OriLongitude=-117.64 /*origin*/;

  OriLatitude=33.09/*origin*/;

  OriAltitude=0;

  ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(OriLatitude),

  osg::DegreesToRadians(OriLongitude),

 OriAltitude,

 oriX,

 oriY,

 oriZ );





 ElModel-convertLatLongHeightToXYZ (osg::DegreesToRadians(33.2940335740),

 osg::DegreesToRadians(-117.3636264412),


 0,

 x,

 y,

 z );





 xl=-sin(OriLongitude)*(x-oriX)+ cos(OriLongitude)*(y-oriY);

 yl=-sin(OriLatitude)*cos(OriLongitude)*(x-oriX)

   -sin(OriLatitude)*sin(OriLongitude)*(y-oriY)

   +cos(OriLatitude)*(z-oriZ);

 zl=cos(OriLatitude)*cos(OriLongitude)*(x-oriX)

   +cos(OriLatitude)*sin(OriLongitude)*(y-oriY)

   +sin(OriLatitude)*(z-oriZ);



 But I still cannot have good results.

 I have some doubts about the - sign applied to the longitude for a West
 direction.



 Thanks for your help,



 Best regards,



 Stephane








 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




 --
 Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791


 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org