示例#1
0
        /// <summary>
        /// Method to ensure the static constructor is being called.
        /// </summary>
        /// <remarks>Be sure to call this function before using Gdal/Ogr/Osr</remarks>
        public static void ConfigureOgr()
        {
            if (_configuredOgr) return;

            // Register drivers
            Ogr.RegisterAll();
            _configuredOgr = true;

            PrintDriversOgr();
        }
示例#2
0
        private static void PrintDriversOgr()
        {
#if DEBUG
            var num = Ogr.GetDriverCount();
            for (var i = 0; i < num; i++)
            {
                var driver = Ogr.GetDriver(i);
                Console.WriteLine(string.Format("OGR {0}: {1}", i, driver.name));
            }
#endif
        }
示例#3
0
        /// <summary>
        /// Method to ensure the static constructor is being called.
        /// </summary>
        /// <remarks>Be sure to call this function before using Gdal/Ogr/Osr</remarks>
        public static void ConfigureOgr()
        {
            if (_configuredOgr)
            {
                return;
            }

            // Register drivers
            Ogr.RegisterAll();
            _configuredOgr = true;
        }
示例#4
0
 private static void PrintDriversOgr()
 {
     if (DebugUtil._debug)
     {
         var num = Ogr.GetDriverCount();
         for (var i = 0; i < num; i++)
         {
             var driver = Ogr.GetDriver(i);
             DebugUtil.WriteLine(string.Format("OGR {0}: {1}", i, driver.name));
         }
     }
 }
示例#5
0
        ///// <summary>
        ///// Loads a Ogr datasource with the specified layer
        ///// </summary>
        ///// <param name="filename">datasource</param>
        ///// <param name="layerName">name of layer</param>
        /////If you want this functionality use
        /////<example>
        /////SharpMap.Data.Providers.Ogr prov = new SharpMap.Data.Providers.Ogr(datasource);
        /////prov.LayerName = layerName;
        /////</example>
        //[Obsolete("This constructor does not work well with VB.NET. Use LayerName property instead")]
        //public Ogr(string filename, string layerName)
        //{
        //    Filename = filename;

        //    _ogrDataSource = OgrOgr.Open(filename, 1);
        //    _ogrLayer = _ogrDataSource.GetLayerByName(layerName);
        //    OsrSpatialReference spatialReference = _ogrLayer.GetSpatialRef();
        //    if (spatialReference != null)
        //        SRID = spatialReference.AutoIdentifyEPSG();
        //}

        /// <summary>
        /// Loads a Ogr datasource with the specified layer
        /// </summary>
        /// <param name="filename">datasource</param>
        /// <param name="layerNum">number of layer</param>
        public Ogr(string filename, int layerNum)
        {
            Filename = filename;

            _ogrDataSource = OgrOgr.Open(filename, 0);
            _ogrLayer      = _ogrDataSource.GetLayerByIndex(layerNum);
            OsrSpatialReference spatialReference = _ogrLayer.GetSpatialRef();

            if (spatialReference != null)
            {
                SRID = spatialReference.AutoIdentifyEPSG();
            }
        }
示例#6
0
        public Ogr(string filename, string layerName)
        {
            Filename = filename;

            _ogrDataSource = OgrOgr.Open(filename, 1);
            _ogrLayer      = _ogrDataSource.GetLayerByName(layerName);
            OsrSpatialReference spatialReference = _ogrLayer.GetSpatialRef();

            if (spatialReference != null)
            {
                _srid = spatialReference.AutoIdentifyEPSG();
            }
        }
        private static void PrintDriversOgr()
        {
#if DEBUG
            if (_usable)
            {
                var num = Ogr.GetDriverCount();
                for (var i = 0; i < num; i++)
                {
                    var driver = Ogr.GetDriver(i);
                    Trace.WriteLine($"OGR {i}: {driver.GetName()}", "Debug");
                }
            }
#endif
        }
示例#8
0
        /// <summary>
        /// Method to ensure the static constructor is being called.
        /// </summary>
        /// <remarks>Be sure to call this function before using Gdal/Ogr/Osr</remarks>
        public static void ConfigureOgr()
        {
            if (_configuredOgr)
            {
                return;
            }

            // Register drivers
            Ogr.GetDriverByName("S57");

            //Ogr.RegisterAll();
            _configuredOgr = true;

            PrintDriversOgr();
        }
示例#9
0
        ///// <summary>
        ///// Loads a Ogr datasource with the specified layer
        ///// </summary>
        ///// <param name="filename">datasource</param>
        ///// <param name="layerName">name of layer</param>
        /////If you want this functionality use
        /////<example>
        /////SharpMap.Data.Providers.Ogr prov = new SharpMap.Data.Providers.Ogr(datasource);
        /////prov.LayerName = layerName;
        /////</example>
        //[Obsolete("This constructor does not work well with VB.NET. Use LayerName property instead")]
        //public Ogr(string filename, string layerName)
        //{
        //    Filename = filename;

        //    _ogrDataSource = OgrOgr.Open(filename, 1);
        //    _ogrLayer = _ogrDataSource.GetLayerByName(layerName);
        //    OsrSpatialReference spatialReference = _ogrLayer.GetSpatialRef();
        //    if (spatialReference != null)
        //        SRID = spatialReference.AutoIdentifyEPSG();
        //}

        /// <summary>
        /// Loads a Ogr datasource with the specified layer
        /// </summary>
        /// <param name="filename">datasource</param>
        /// <param name="layerNum">number of layer</param>
        public Ogr(string filename, int layerNum)
        {
            Filename     = filename;
            ConnectionID = filename;

            _ogrDataSource = OgrOgr.OpenShared(filename, 0);
            using (var ogrLayer = GetLayer(layerNum))
            {
                OsrSpatialReference spatialReference = ogrLayer.GetSpatialRef();
                if (spatialReference != null)
                {
                    SRID = spatialReference.AutoIdentifyEPSG();
                }
            }
            _layerIndex = layerNum;
        }
示例#10
0
 /// <summary>
 /// Method to get a layer based on a private copy of the data source
 /// </summary>
 /// <param name="layerIndex">The layer index</param>
 /// <param name="ogrDataSource">The data source</param>
 /// <returns></returns>
 private OgrLayer GetLayer(int layerIndex, out OgrDataSource ogrDataSource)
 {
     ogrDataSource = OgrOgr.OpenShared(Filename, 0);
     return(ogrDataSource.GetLayerByIndex(layerIndex));
 }
示例#11
0
 static Ogr()
 {
     FwToolsHelper.Configure();
     OgrOgr.RegisterAll();
 }