示例#1
0
        public void TestMap()
        {
            var m = new Map(new Size(1024, 786)) {BackColor = Color.FloralWhite};
            const string samplePath = @"D:\GIS\FileGDB\samples\data\Topo.gdb";

            var p = new FileGdbProvider(samplePath);

            foreach (var fc in p.GetFeatureClasses("\\USA"))
            {
                if (fc.StartsWith("\\USA\\T"))
                    continue;

                Console.WriteLine(fc);
                var pUse = new FileGdbProvider(samplePath) { Table = fc };
                var vl = new VectorLayer("Layer:" + fc, pUse)
                             {
                                 SmoothingMode = SmoothingMode.HighQuality,
                                 Style = {Fill = RandomBrush(), Line = RandomPen()}
                             };
                m.Layers.Add(vl);

                var fds = new FeatureDataSet();
                vl.ExecuteIntersectionQuery(vl.Envelope, fds);
                fds.Tables[0].TableName = fc;
                var res = fds.Tables[0].Rows[0].ItemArray;
                foreach (DataColumn col in fds.Tables[0].Columns)
                    Console.Write(string.Format("{0} [{1}], ", col.ColumnName, col.DataType));
                Console.WriteLine();

                foreach (var item in res)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                Console.WriteLine();

                Console.WriteLine(pUse.GetGeometryByID(1));

                var r = pUse.GetFeature(1);
                foreach (var item in r.ItemArray)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));

                Console.WriteLine();
                Console.WriteLine();
            }
            Console.WriteLine();

            p.Dispose();
            

            m.ZoomToExtents();
            var b = m.GetMap();
            b.Save("fgdb-usa-states.png");
            
            //var fds = new FeatureDataSet();
            //lc.ExecuteIntersectionQuery(m.GetExtents().GetCentroid(), fds);
            //fds.Tables[0].TableName = lc.LayerName;
            //fds.Tables[0].WriteXml(Console.Out);
        }
        public void TestEnsureNativePathSet()
        {
            var p = new FileGdbProvider();
            p.Dispose();

            var asr = new AppSettingsReader();
            var fileGdbPath = (string)asr.GetValue("FileGdbNativeDirectory", typeof (string));
            var path = Environment.GetEnvironmentVariable("PATH");
            Assert.IsFalse(string.IsNullOrEmpty(path));
            Assert.IsTrue(path.Contains(fileGdbPath));
        }
示例#3
0
        public void TestEnsureNativePathSet()
        {
            var p = new FileGdbProvider();

            p.Dispose();

            var asr         = new AppSettingsReader();
            var fileGdbPath = (string)asr.GetValue("FileGdbNativeDirectory", typeof(string));
            var path        = Environment.GetEnvironmentVariable("PATH");

            Assert.IsFalse(string.IsNullOrEmpty(path));
            Assert.IsTrue(path.Contains(fileGdbPath));
        }
示例#4
0
        public void TestSampleSources()
        {
            var di = new DirectoryInfo(@"D:\GIS\FileGDB\samples\data");

            foreach (var tmp in di.EnumerateDirectories())
            {
                var p = new FileGdbProvider(tmp.FullName);
                Console.WriteLine("\n" + p.ConnectionID);
                foreach (var table in p.EnumerateTables())
                {
                    Console.WriteLine("\t" + table);
                }
            }
        }
        public void TestSampleSources()
        {
            var di = new DirectoryInfo(@"D:\GIS\FileGDB\samples\data");

            foreach (var tmp in di.EnumerateDirectories())
            {
                var p = new FileGdbProvider(tmp.FullName);
                Console.WriteLine("\n" + p.ConnectionID);
                foreach (var table in p.EnumerateTables())
                {
                    Console.WriteLine("\t" + table);
                }
            }
        }
        public void TestMap()
        {
            var m = new Map(new Size(1024, 786))
            {
                BackColor = Color.FloralWhite
            };
            const string samplePath = @"D:\GIS\FileGDB\samples\data\Topo.gdb";

            var p = new FileGdbProvider(samplePath);

            foreach (var fc in p.GetFeatureClasses("\\USA"))
            {
                if (fc.StartsWith("\\USA\\T"))
                {
                    continue;
                }

                Console.WriteLine(fc);
                var pUse = new FileGdbProvider(samplePath)
                {
                    Table = fc
                };
                var vl = new VectorLayer("Layer:" + fc, pUse)
                {
                    SmoothingMode = SmoothingMode.HighQuality,
                    Style         = { Fill = RandomBrush(), Line = RandomPen() }
                };
                m.Layers.Add(vl);

                var fds = new FeatureDataSet();
                vl.ExecuteIntersectionQuery(vl.Envelope, fds);
                fds.Tables[0].TableName = fc;
                var res = fds.Tables[0].Rows[0].ItemArray;
                foreach (DataColumn col in fds.Tables[0].Columns)
                {
                    Console.Write(string.Format("{0} [{1}], ", col.ColumnName, col.DataType));
                }
                Console.WriteLine();

                foreach (var item in res)
                {
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                }
                Console.WriteLine();

                Console.WriteLine(pUse.GetGeometryByID(1));

                var r = pUse.GetFeature(1);
                foreach (var item in r.ItemArray)
                {
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                }

                Console.WriteLine();
                Console.WriteLine();
            }
            Console.WriteLine();

            p.Dispose();


            m.ZoomToExtents();
            var b = m.GetMap();

            b.Save("fgdb-usa-states.png");

            //var fds = new FeatureDataSet();
            //lc.ExecuteIntersectionQuery(m.GetExtents().GetCentroid(), fds);
            //fds.Tables[0].TableName = lc.LayerName;
            //fds.Tables[0].WriteXml(Console.Out);
        }