[Proj] OT: Geotrans's Neys Projection - Modified Lambert ConformalConic

paul at toolscenter.org paul at toolscenter.org
Mon Dec 19 23:28:41 EST 2005


I personally do not work with P/Invoke unless there is a real reason for it.
If it will take me only 3 days to get a complete C# version of GeoTrans,
with all the .NET benefits, I will prefer that to getting P/Invoke right
or wrong not forgetting thread issues.

Just like in GeoTools, if I need Proj4 in C# application, I will port it.
I started this effort by removing all the macros in the Proj4, but Frank
was not willing to accept this as the main. With the many changes, I now
plan to do it for the libproj4 and then move it to C++ classes, and then
to the C#.

Simply, I avoid P/Invoke in my .NET application unless I am dealing with
third-party library or large code base I do not understand. For
open-sources, I will at most go for MC++ or C++/CLR.

Best regards,
Paul.

> 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
>
>
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>




More information about the Proj mailing list