Nuget GDAL

Topics: General Topics
Dec 14, 2012 at 12:24 PM

I just grabbed the latest nuget package for GDAL 1.9.1.  i get an exception calling OSGeo.OSR.Osr.GetUserInputAsWKT().  there are no instructions I can find anywhere on configuring the nuget package.  Can you provide some?  Thanks.

-reilly.

Coordinator
Dec 14, 2012 at 2:01 PM

Using this test class reveals you either need to call

  • GdalConfiguration.ConfigureGdal() or
  • GdalConfiguration.ConfigureOgr()

prior to accessing any OSGeo.OSR.Osr method/function.

Hth FObermaier

namespace GDALNuGetPackageTest
{
    public class TestOsr
    {
        /*
         * Either this Test will work, or the other two
         * The exception is probably cached
         */ 

        //[NUnit.Framework.Test, NUnit.Framework.Sequential]
        //public void Test1OsrThrowsTypeInitialization()
        //{
        //    string wkt;
        //    NUnit.Framework.Assert.Throws<TypeInitializationException>(() => OSGeo.OSR.Osr.GetUserInputAsWKT("EPSG:31467", out wkt));
        //}

        [NUnit.Framework.Test]
        public void Test2OsrDoesNotThrowGdal()
        {
            GdalConfiguration.ConfigureGdal();
            string wkt;
            NUnit.Framework.Assert.DoesNotThrow(() => OSGeo.OSR.Osr.GetUserInputAsWKT("EPSG:31467", out wkt));
        }

        [NUnit.Framework.Test]
        public void Test2OsrDoesNotThrowOgr()
        {
            GdalConfiguration.ConfigureOgr();
            string wkt;
            NUnit.Framework.Assert.DoesNotThrow(() => OSGeo.OSR.Osr.GetUserInputAsWKT("EPSG:31467", out wkt));
        }
    }
}