Re : Spatial conversion

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re : Spatial conversion

ytse
I've tried using PROJ4 but there's something I dont' understand, if anyone is at ease with this project :

this command line works
proj -I -f "%.14f" +proj=lcc +lat_1=46.8 +lat_2=0 +lat_0=46.8 +lon_0=2.33722916666667 +x_0=600000.000 +y_0=2200000.000 +a=6378249.200 +b=6356515.000 +units=m -v

but this code won't work

        [DllImport("proj.dll")]
        static extern IntPtr pj_init(int argc, string[] args);
        [DllImport("proj.dll")]
        static extern string pj_free(IntPtr projPJ);
        [DllImport("proj.dll")]
        static extern UV pj_fwd(UV uv, IntPtr projPJ);
        static void Main(string[] args)
        {
            string[] NTF_Paris_France_II = new string[] { "proj=lcc", "lat_1=46.8", "lat_2=0", "lat_0=46.8", "lon_0=2.33722916666667", "x_0=600000.000", "y_0=2200000.000", "a=6378249.200", "b=6356515.000", "units=m" };            // from nad\esri
            IntPtr projPJ = pj_init(NTF_Paris_France_II.Length, NTF_Paris_France_II);
            UV lonlat = pj_fwd(new UV(663218.111631, 1795540.110104), projPJ);
            pj_free(projPJ);
            Console.WriteLine("Lon=" + lonlat.U + ",Lat=" + lonlat.V);
            Console.ReadLine();
        }
but I obtained U=V = +infinite, and using pj_inv I get some coords but they don't match the good ones from the command line

I've sent a mail to [hidden email] but if anyone can help even though it's not directly related to FDO, thanks


----- Message d'origine ----
De : Dan Stoica <[hidden email]>
À : Gavin Cramer <[hidden email]>; Ytse <[hidden email]>; [hidden email]
Envoyé le : Lundi, 12 Février 2007, 17h42mn 44s
Objet : RE: [fdo-users] Spatial conversion


" ... but I haven't obtained anything else that "Default" in GetName() for my test files ?"

GetName() returns the name of the Spatial Context.
Look for GetCoordinateSystem() and GetCoordinateSystemWkt() for info pertaining the Coordinate System.

Dan.


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Gavin Cramer
Sent: Monday, February 12, 2007 11:28 AM
To: Ytse; [hidden email]
Subject: RE: [fdo-users] Spatial conversion

FDO does not itself support coordinate conversion.  What you will get from the Spatial Context is the name or definition of a coordinate system.  There are several ways to get do what you want...

1.  If you are using MapGuide, its API can do it.  The open-source version effectively results in the next approach...

2.  Use OGR directly.  Both this solution and #1 above will result in calls to PROJ.4 (http://www.remotesensing.org/proj/).

3. Spin your own solution, using whatever general solution (like PROJ.4) that you have available.  You can save time coding access to the FGF content by using a handy example class that sits in GeometryTest.cpp, in the FDO unit test.  Look for the GeometryConverter class.  You just have to fill in or override the ConvertPosition() methods to call whatever conversion package you choose.

I haven't worked much directly with the components for #1 or #2 above, so hopefully someone else will give more details if one of those fits your case.

Gavin


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Ytse
Sent: Monday, February 12, 2007 9:38 AM
To: [hidden email]
Subject: [fdo-users] Spatial conversion

Hi everyone,

are there any ways to convert coordinates from one system to another using FDO ?
(In my case that would be from LAMBERT IIe to WGS84)

By the way I know my files are in this system, but is it possible to detect it using FDO ?
I thought I'd be able to do this by using using OSGeo.FDO.Commands.SpatialContext but I haven't obtained anything else that "Default" in GetName() for my test files ?

thank you


   

   
       
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users


       

       
               
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

RE: Re : Spatial conversion

Dan Stoica
In order to have some Coord. System information, one must use a .PRJ file.
For the Hawaii dataset there is one in the SHP provider /TestData/Hawaii/ folder. For convenience, it is attached.

Dan.
 
-----Original Message-----
From: Ytse [mailto:[hidden email]]
Sent: Tuesday, February 13, 2007 6:05 AM
To: Dan Stoica; Gavin Cramer; [hidden email]
Subject: Re : [fdo-users] Spatial conversion

Dan>
Hum first of all I forgot to mention I'm working on SHP files (guess that can change things, as spatial context is only listed as "get spatial context = Y" in provider capabilities)

everything is empty ("") except for name which is "Default"
Here's the code I use
            // spatial context
            IGetSpatialContexts get;
            ISpatialContextReader screader;
            get = (IGetSpatialContexts)connection.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_GetSpatialContexts);
            screader = get.Execute();
            while (screader.ReadNext())
            {
                Console.WriteLine("Context Name : " + screader.GetName());
                Console.WriteLine("Context Description : " + screader.GetDescription());
                Console.WriteLine("Context Coordinate System WKT : " + screader.GetCoordinateSystemWkt());
                Console.WriteLine("Context Coordinate System : " + screader.GetCoordinateSystem());
            }
I have only one shp file in the directory, "hawaii.shp" from the internet (I've also tried with

Gavin> thank you, I'll try to investigate this (would you recommend focusing on PROJ.4 or trying teh more recent LIBPROJ4 ?)

I'm using Mapguide Server 6.5 but never had to use its API before (exwcept fo SdfToolkit and MapGuide Viewer). I had found another conversion library (ConversApi.dll) but I can't use it as it requires to write into the registry during runtime.



----- Message d'origine ----
De : Dan Stoica <[hidden email]>
À : Gavin Cramer <[hidden email]>; Ytse <[hidden email]>; [hidden email]
Envoyé le : Lundi, 12 Février 2007, 17h42mn 44s
Objet : RE: [fdo-users] Spatial conversion


" ... but I haven't obtained anything else that "Default" in GetName() for my test files ?"

GetName() returns the name of the Spatial Context.
Look for GetCoordinateSystem() and GetCoordinateSystemWkt() for info pertaining the Coordinate System.

Dan.


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Gavin Cramer
Sent: Monday, February 12, 2007 11:28 AM
To: Ytse; [hidden email]
Subject: RE: [fdo-users] Spatial conversion

FDO does not itself support coordinate conversion.  What you will get from the Spatial Context is the name or definition of a coordinate system.  There are several ways to get do what you want...

1.  If you are using MapGuide, its API can do it.  The open-source version effectively results in the next approach...

2.  Use OGR directly.  Both this solution and #1 above will result in calls to PROJ.4 (http://www.remotesensing.org/proj/).

3. Spin your own solution, using whatever general solution (like PROJ.4) that you have available.  You can save time coding access to the FGF content by using a handy example class that sits in GeometryTest.cpp, in the FDO unit test.  Look for the GeometryConverter class.  You just have to fill in or override the ConvertPosition() methods to call whatever conversion package you choose.

I haven't worked much directly with the components for #1 or #2 above, so hopefully someone else will give more details if one of those fits your case.

Gavin


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Ytse
Sent: Monday, February 12, 2007 9:38 AM
To: [hidden email]
Subject: [fdo-users] Spatial conversion

Hi everyone,

are there any ways to convert coordinates from one system to another using FDO ?
(In my case that would be from LAMBERT IIe to WGS84)

By the way I know my files are in this system, but is it possible to detect it using FDO ?
I thought I'd be able to do this by using using OSGeo.FDO.Commands.SpatialContext but I haven't obtained anything else that "Default" in GetName() for my test files ?

thank you


   

   
       
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users


       

       
               
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users

coast_n83.prj (584 bytes) Download Attachment