public void InsertFeaturesTest() { FeatureDataTable<uint> schema = new FeatureDataTable<uint>("OID"); schema.Columns.AddRange(new DataColumn[] { new DataColumn("Name", typeof (String)), new DataColumn("DateCreated", typeof (DateTime)), new DataColumn("Visits", typeof (Int64)), new DataColumn("Weight", typeof (double)) }); ShapeFileProvider shapeFile = ShapeFileProvider.Create("UnitTestData", "Test3", ShapeType.PolyLine, schema); shapeFile.Open(); Random rnd = new Random(); BoundingBox computedBounds = BoundingBox.Empty; List<FeatureDataRow<uint>> rows = new List<FeatureDataRow<uint>>(); for (int i = 0; i < 10000; i++) { DateTime dateCreated = new DateTime(rnd.Next(1900, 2155), rnd.Next(1, 12), rnd.Next(1, 28)); FeatureDataRow<uint> feature = schema.NewRow((uint) i); char[] chars = new char[rnd.Next(0, 254)]; for (int charIndex = 0; charIndex < chars.Length; charIndex++) { chars[charIndex] = (char) (byte) rnd.Next(32, 126); } feature["Name"] = new String(chars); feature["DateCreated"] = dateCreated; feature["Visits"] = rnd.Next(0, Int32.MaxValue) << rnd.Next(0, 32); feature["Weight"] = rnd.NextDouble()*rnd.Next(0, 100000); LineString line = new LineString(); int pointCount = rnd.Next(1, 100); for (int pointIndex = 0; pointIndex < pointCount; pointIndex++) { Point p = new Point(rnd.NextDouble()*rnd.Next(200000, 700000), (rnd.NextDouble()*rnd.Next(1000000)) + 50000000); line.Vertices.Add(p); } computedBounds.ExpandToInclude(line.GetBoundingBox()); feature.Geometry = line; rows.Add(feature); } shapeFile.Insert(rows); shapeFile.Close(); shapeFile = new ShapeFileProvider(@"UnitTestData\Test3.shp", true); shapeFile.Open(); Assert.AreEqual(10000, shapeFile.GetFeatureCount()); Assert.AreEqual(computedBounds, shapeFile.GetExtents()); FeatureDataSet dataSet = new FeatureDataSet("ShapeFile test"); shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), dataSet); Assert.AreEqual(1, dataSet.Tables.Count); Assert.AreEqual(10000, dataSet.Tables[0].Rows.Count); }
public void GetExtentsTest() { ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP"); BoundingBox expected = new BoundingBox(7332083.2127965018, 236823.71867240831, 7538428.618, 405610.34692560317); BoundingBox actual = shapeFile.GetExtents(); Assert.AreEqual(expected, actual); }
public void ExecuteIntersectionQueryByBoundingBoxTest() { Console.WriteLine("EN ExecuteIntersectionQueryByBoundingBoxTest"); //ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP"); ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\rivers.shp"); shapeFile.Open(); FeatureDataSet data = new FeatureDataSet("ShapeFile test"); shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), data); foreach (FeatureDataTable fdt in data.Tables) { Console.WriteLine("una fdt"); foreach (FeatureDataRow fdr in fdt.Rows) { Geometry geom = fdr.Geometry; Console.WriteLine("fdr.Geometry:" + geom.AsText()); } Console.WriteLine("fdt.Rows.Count:" + fdt.Rows.Count); } Assert.AreEqual(1, data.Tables.Count); Assert.AreEqual(shapeFile.GetFeatureCount(), data.Tables[0].Rows.Count); shapeFile.Close(); }
public void ExecuteIntersectionQueryByBoundingBoxWhenClosedThrowsExceptionTest() { ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP"); FeatureDataSet data = new FeatureDataSet("ShapeFile test"); shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), data); }
public void GetGeometriesInViewTest() { ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP"); shapeFile.Open(); List<Geometry> geometries = new List<Geometry>(); geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(shapeFile.GetExtents())); Assert.AreEqual(shapeFile.GetFeatureCount(), geometries.Count); geometries.Clear(); geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(BoundingBox.Empty)); Assert.AreEqual(0, geometries.Count); }