Пример #1
0
        public void TestCaseSensitiveKeyColumn()
        {
            var path = Path.GetTempFileName();

            try
            {
                var sqlite = new System.Data.SQLite.SQLiteConnection("Data Source=" + path);
                sqlite.Open();
                var cmd = sqlite.CreateCommand();
                cmd.CommandText = "create table test(col_ID integer primary key, name text, shape blob)";
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                sqlite.Close();
                sqlite.Dispose();
                using (var sq = new ManagedSpatiaLite("Data Source=" + path, "test", "shape", "COL_ID"))
                {
                    var ext = new Envelope();
                    var ds  = new SharpMap.Data.FeatureDataSet();
                    sq.ExecuteIntersectionQuery(ext, ds);
                    NUnit.Framework.Assert.AreEqual(0, ds.Tables[0].Count);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Got exception, should not happen");
            }
            finally
            {
                File.Delete(path);
            }
        }
Пример #2
0
        public void TestMap2()
        {
            var m = new Map(_mapSize);

            m.BackgroundLayer.Add(new TileLayer(new OsmTileSource(new OsmRequest(KnownOsmTileServers.MapQuest)), "MapQuest"));

            var codeBase = Path.GetDirectoryName(GetType().Assembly.CodeBase);
            var cn       = string.Format("Data Source={0};",
                                         Path.Combine(new Uri(codeBase).LocalPath, "TestData", "osm_aurich.sqlite"));

            var ct = Wgs84ToWebMercator;
            //Env[7,45731445821406 : 7,53454260528903, 53,4342695512313 : 53,478793942147]
            var box     = new Envelope(7.45731445821406, 7.53454260528903, 53.4342695512313, 53.478793942147);
            var box3857 = GeometryTransform.TransformBox(box, ct.MathTransform);

            m.ZoomToBox(box3857);

            foreach (var msp in ManagedSpatiaLite.GetSpatialTables(cn))
            {
                var l = new VectorLayer(msp.Table, msp);
                switch (msp.Table.Substring(0, 2).ToLower())
                {
                case "pt":
                    l.Style = VectorStyle.CreateRandomPuntalStyle();
                    break;

                case "ln":
                    l.Style = VectorStyle.CreateRandomLinealStyle();
                    break;

                case "pg":
                    l.Style = VectorStyle.CreateRandomPolygonalStyle();
                    break;

                default:
                    l.Style = VectorStyle.CreateRandomStyle();
                    break;
                }

                l.CoordinateTransformation = ct;
                m.Layers.Add(l);
            }

            var f = GetFormatter();

            BruTile.Utility.AddBruTileSurrogates(GetFormatter());

            Map mD = null;

            Assert.DoesNotThrow(() => mD = SandD(m, f));

            TestMaps("Test2", m, mD);
        }
Пример #3
0
        public void TestSpatiaLite2()
        {
            var spatiaLite2S = new ManagedSpatiaLite("Data Source=test-2.3.sqlite;Database=Regions;",
                                                     "Roads", "Geometry", "PK_UID");

            var spatiaLite2 = SandD(spatiaLite2S, GetFormatter());

            Assert.AreEqual(spatiaLite2S.ConnectionString, spatiaLite2.ConnectionString);
            Assert.AreEqual(spatiaLite2S.Table, spatiaLite2.Table);
            Assert.AreEqual(spatiaLite2S.GeometryColumn, spatiaLite2.GeometryColumn);
            Assert.AreEqual(spatiaLite2S.ObjectIdColumn, spatiaLite2.ObjectIdColumn);
            Assert.AreEqual(spatiaLite2S.SRID, spatiaLite2.SRID);
        }
Пример #4
0
        public void TestMap2()
        {
            var m = new Map(_mapSize);

            m.BackgroundLayer.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingHybridStaging), "BingHybridStaging"));

            string cn = $"Data Source={TestUtility.GetPathToTestFile("osm_aurich.sqlite")};";

            var ct = Wgs84ToWebMercator;
            //Env[7,45731445821406 : 7,53454260528903, 53,4342695512313 : 53,478793942147]
            var box     = new Envelope(7.45731445821406, 7.53454260528903, 53.4342695512313, 53.478793942147);
            var box3857 = GeometryTransform.TransformBox(box, ct.MathTransform);

            m.ZoomToBox(box3857);

            foreach (var msp in ManagedSpatiaLite.GetSpatialTables(cn))
            {
                var l = new VectorLayer(msp.Table, msp);
                switch (msp.Table.Substring(0, 2).ToLower())
                {
                case "pt":
                    l.Style = VectorStyle.CreateRandomPuntalStyle();
                    break;

                case "ln":
                    l.Style = VectorStyle.CreateRandomLinealStyle();
                    break;

                case "pg":
                    l.Style = VectorStyle.CreateRandomPolygonalStyle();
                    break;

                default:
                    l.Style = VectorStyle.CreateRandomStyle();
                    break;
                }

                l.CoordinateTransformation = ct;
                m.Layers.Add(l);
            }

            var f = GetFormatter();
            //BruTile.Utility.AddBruTileSurrogates(GetFormatter());

            Map mD = null;

            Assert.DoesNotThrow(() => mD = SandD(m, f));

            TestMaps("Test2", m, mD);
        }