[Proj] OT: Geotrans's Neys Projection - Modified Lambert ConformalConic
Eric Miller
EMiller at dfg.ca.gov
Mon Dec 19 16:02:44 PST 2005
Not to make this a C# and Geotrans list, but it might be a little less work to just implement "Platform Invoke" functions for those functions and data types defined in engine.h. Then your code just loads the geotrans2.dll and calls its functions as if they were native to C# (more or less). You have to figure out a few things like calling convention (cdecl vs. stdcall) and how to send fixed length string buffers (hint: StringBuilder). Most pointers to simple types can be handled with "ref" or "out" modifiers and pointers to opaque types are handled with the "IntPtr" type (C#'s answer to void pointers).
To bring it back to PROJ.4, you can refer to my C# wrapper for some idea how to define external functions. See http://ftp.dfg.ca.gov/outgoing/nafwb/proj4/csharp/
Unlike proj.4, you probably won't need any "unsafe" pointer code constructs for geotrans.
Luck,
>>> paul at toolscenter.org 12/19/2005 3:23:33 PM >>>
Sorry, the C# codes were part of a work I did for my former company.
Off course, I can always do it if there is a need. But the process is simple
and should take you less than 3 days.
Each Geotrans *.h/*.c pair file is an indepedendent projection, so can be
compiled individually with the exception of the (T)Mercator.
Here are the steps: C ---> C++ ---> C#
1. Change the *.c file extension to C++, and add a C++ class
2. The *.c contains static/globals fields, move all as members of the class
3. For quick C# conversion, try to maintain all the codes in the *.h file.
4. Make functions defined in the *.h/*.c files methods of the class.
5. For the C#, make the #defines "const" or "readonly" members
6. Use the Math.* for the maths functions
7. Use exceptions for the error codes. Each *.c contains the actual
message of the error codes in its comments, so simply copy these as
throw new YourException("message");
and return "void" - may be subject to your design.
8. Change the comments to the C# style and add the test sample as part of
the comment for quick copy and paste testing codes and if you have the
time
and need, change these for NUnit tests. Some of the codes do not give the
expected results in the documentations though.
I should have the intermediate/C++ codes somewhere in my PC, since I did
this at home, I could look for it if you need this one.
Best regards,
Paul.
________________________________
From: proj-bounces at lists.maptools.org
[mailto:proj-bounces at lists.maptools.org] On Behalf Of Friend, Darris E
Sent: Tuesday, December 20, 2005 6:36 AM
To: proj at lists.maptools.org
Subject: [Proj] OT: Geotrans's Neys Projection - Modified Lambert
ConformalConic
Paul,
Would you be willing to share the C# code you converted?
Thanks
D. F.
GIS Technician
Gainesville Regional Utilities
> Hello,
> Thanks for the the information. I have now found the document. It
is
> located in the users package. I was only using the developers
package.
> By the way, I have nothing against GeoTrans. It is more suitable
for
> a work I am doing now in .NET Framework. I easily ported it to C++
> and then moved it to C# without any problem.
> Best regard,
> Paul.
_______________________________________________
Proj mailing list
Proj at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/proj
More information about the Proj
mailing list