Proj4CSharp

Porting on C# of Proj.4 library

This is a porting in pure C# code of Proj.4 C library.
Is beta release, there are many things to do.

NAD grid shift are in one big XML files for compatibility reasons, less than 1 second to load but maybe is better to have multiple grids xml files.

The I10n is done using a singleton class, this is OK, but.. if you need to use it in a SQL Server embedded routines, you need administrative privileges (is NO_SAFE)

More tests needed, actually I tried lcc, aea, latlong, geocentric, utm, tmerc and results are identical to Proj.4 C routines (Windows 32bit Proj.DLL) but there are many projections that need tests.

Below a simple program to show the usage.

:::python

using System;
using System.Collections.Generic;
using Proj4CSharp;

namespace Tester
{
class Program
{
private static IProjection srcCRS;
private static IProjection tgtCRS;

private static double[] MyX = new double[1];
private static double[] MyY = new double[1];
private static double[] MyZ = new double[1];

private static IProjection createCRS(String crsSpec)
{
    IProjection crs = null;
    // test if name is a PROJ4 spec
    if (crsSpec.IndexOf("+") >= 0)
    {
        crs = Proj4CSharp.Proj4CSharp.ProjectionFactory(crsSpec);
    }
    else
    {
        crs = Proj4CSharp.Proj4CSharp.ProjectionFactoryFromName(crsSpec);
    }
    return crs;
}

static void Main(string[] args)
{
    double X = 12.23456;
    double Y = 41.5467;
    double Z = 0;

    srcCRS = createCRS("ESRI:4326");
    tgtCRS = createCRS("ESRI:32632");
    MyX[0] = (srcCRS.IsLatLong) ? X * Proj4CSharp.Proj4CSharp.DEG_TO_RAD : X;
    MyY[0] = (srcCRS.IsLatLong) ? Y * Proj4CSharp.Proj4CSharp.DEG_TO_RAD : Y;
    MyZ[0] = Z;

    try
    {
        srcCRS.Transform(tgtCRS, 1, 1, MyX, MyY, MyZ);
        if (tgtCRS.IsLatLong)
        {
            MyX[0] *= Proj4CSharp.Proj4CSharp.RAD_TO_DEG;
            MyY[0] *= Proj4CSharp.Proj4CSharp.RAD_TO_DEG;
        }
    }
    catch (Exception ex)
    {
        // Manage Exception here
    }
}

}

}