Exemplo n.º 1
0
		public void NewWithoutFileBasedSpatialIndexTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			Assert.IsNotNull(shapeFile);
			shapeFile.Close();
		}
Exemplo n.º 2
0
		public void NewWithFileBasedSpatialIndexTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP", true);
			Assert.IsNotNull(shapeFile);
			shapeFile.Open();
			Assert.IsTrue(File.Exists(@"..\..\..\TestData\BCROADS.shp.sidx"));
			shapeFile.Close();
			File.Delete(@"..\..\..\TestData\BCROADS.shp.sidx");
		}
Exemplo n.º 3
0
		public void SridTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			shapeFile.Open();
			Assert.AreEqual(0, shapeFile.Srid);
			shapeFile.Close();


			shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADSWithoutDbf.SHP");
			shapeFile.Open();
			Assert.AreEqual(-1, shapeFile.Srid);
			shapeFile.Close();
		}
Exemplo n.º 4
0
		public void InsertFeatureTest()
		{
			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 (int)),
			                        		new DataColumn("Weight", typeof (float))
			                        	});

			ShapeFileProvider shapeFile = ShapeFileProvider.Create("UnitTestData", "Test2", ShapeType.Point, schema);
			shapeFile.Open();

			DateTime dateCreated = DateTime.Now;
			FeatureDataRow<uint> feature = schema.NewRow(1);
			feature["Name"] = "Test feature";
			feature["DateCreated"] = dateCreated;
			feature["Visits"] = 0;
			feature["Weight"] = 100.0f;
			feature.Geometry = new Point(1, 1);

			shapeFile.Insert(feature);
			shapeFile.Close();

			shapeFile = new ShapeFileProvider(@"UnitTestData\Test2.shp");
			shapeFile.Open();

			Assert.AreEqual(1, shapeFile.GetFeatureCount());

            FeatureDataSet dataSet = new FeatureDataSet("ShapeFile test");

			shapeFile.ExecuteIntersectionQuery(new BoundingBox(1, 1, 1, 1), dataSet);

			Assert.AreEqual(1, dataSet.Tables.Count);
			Assert.AreEqual(1, dataSet.Tables[0].Rows.Count);

			FeatureDataRow<uint> newFeature = dataSet.Tables[0].Rows[0] as FeatureDataRow<uint>;
			Assert.AreEqual(new Point(1, 1), newFeature.Geometry);
			Assert.AreEqual(newFeature["Name"], "Test feature");
			DateTime dateCreatedActual = (DateTime) newFeature["DateCreated"];
			Assert.AreEqual(dateCreatedActual.Year, dateCreated.Year);
			Assert.AreEqual(dateCreatedActual.Month, dateCreated.Month);
			Assert.AreEqual(dateCreatedActual.Day, dateCreated.Day);
			Assert.AreEqual(newFeature["Visits"], 0);
			Assert.AreEqual(newFeature["Weight"], 100.0f);
			shapeFile.Close();
		}
Exemplo n.º 5
0
		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();
		}
Exemplo n.º 6
0
		public void GetFeatureTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			shapeFile.Open();
			FeatureDataRow<uint> feature = shapeFile.GetFeature(0);
			Assert.AreEqual(0, feature.Id);
			shapeFile.Close();
		}
Exemplo n.º 7
0
		public void HasDbfWithoutDbfFileIsFalseTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADSWithoutDbf.SHP");
			Assert.IsFalse(shapeFile.HasDbf);
			shapeFile.Close();
		}
Exemplo n.º 8
0
		public void IsOpenTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			Assert.IsFalse(shapeFile.IsOpen);
			shapeFile.Open();
			Assert.IsTrue(shapeFile.IsOpen);
			shapeFile.Close();
			Assert.IsFalse(shapeFile.IsOpen);
		}
Exemplo n.º 9
0
		public void GetShapeTypeTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADSWithoutDbf.SHP");
			shapeFile.Open();
			Assert.AreEqual(ShapeType.PolyLine, shapeFile.ShapeType);
			shapeFile.Close();
		}
Exemplo n.º 10
0
		public void GetDbfFilenameTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			Assert.AreEqual(0, String.Compare(
			                   	Path.Combine(new DirectoryInfo(@"..\..\..\TestData").FullName, "BCROADS.DBF"),
			                   	shapeFile.DbfFilename,
			                   	true));
			shapeFile.Close();
		}
Exemplo n.º 11
0
		public void NoPrjFileSetCoordinateSystemTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADSWithoutDbf.SHP");
			shapeFile.Open();
			string wkt = File.ReadAllText(@"..\..\..\TestData\BCROADS.prj");
			IProjectedCoordinateSystem cs = CoordinateSystemWktReader.Parse(wkt) as IProjectedCoordinateSystem;
			shapeFile.SpatialReference = cs;
			Assert.IsNotNull(shapeFile.SpatialReference);

			Geometry g = shapeFile.GetGeometryById(0);

			Assert.IsTrue(g.SpatialReference.EqualParams(createExpectedCoordinateSystem()));

			shapeFile.Close();
		}
Exemplo n.º 12
0
		public void NoPrjFileImpliesCoordinateSystemIsNullTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADSWithoutDbf.SHP");
			shapeFile.Open();
			Assert.IsNull(shapeFile.SpatialReference);
			shapeFile.Close();
		}
Exemplo n.º 13
0
		public void GetCoordinateSystemHavingPrjFileTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			shapeFile.Open();
			Assert.IsNotNull(shapeFile.SpatialReference);
			Assert.IsInstanceOfType(typeof (IProjectedCoordinateSystem), shapeFile.SpatialReference);
			IProjectedCoordinateSystem cs = shapeFile.SpatialReference as IProjectedCoordinateSystem;

			Assert.IsNotNull(cs);
			Assert.AreEqual("NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601", cs.Name);

			IProjectedCoordinateSystem expected = createExpectedCoordinateSystem();

			Assert.IsTrue(expected.EqualParams(cs));
			shapeFile.Close();
		}
Exemplo n.º 14
0
		public void RebuildSpatialIndexTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP", true);
			shapeFile.Open();
			File.Delete(@"..\..\..\TestData\BCROADS.shp.sidx");
			shapeFile.RebuildSpatialIndex();
			Assert.IsTrue(File.Exists(@"..\..\..\TestData\BCROADS.shp.sidx"));
			shapeFile.Close();
			File.Delete(@"..\..\..\TestData\BCROADS.shp.sidx");
		}
Exemplo n.º 15
0
		public void RebuildSpatialIndexWhenClosedThrowsExceptionTest()
		{
			ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP");
			shapeFile.RebuildSpatialIndex();
			shapeFile.Close();
		}