GetBoundingBox() public méthode

The minimum bounding box for this Geometry.
public GetBoundingBox ( ) : BoundingBox
Résultat BoundingBox
Exemple #1
0
		public void Linestring()
		{
			LineString l = new LineString();
			Assert.IsTrue(l.IsEmpty());
			Assert.IsNull(l.GetBoundingBox());
			Assert.AreEqual(0, l.Length);
			Assert.IsFalse(l.Equals(null));
			Assert.IsTrue(l.Equals(new LineString()));

			Collection<Point> vertices = new Collection<Point>();
			vertices.Add(new Point(54, 23));
			vertices.Add(new Point(93, 12));
			vertices.Add(new Point(104, 32));
			l.Vertices = vertices;
			Assert.IsFalse(l.IsEmpty());
			Assert.IsFalse(l.IsClosed);
			Assert.AreEqual(3, l.NumPoints);
			Assert.AreEqual(new Point(54, 23), l.StartPoint);
			Assert.AreEqual(new Point(104,32), l.EndPoint);
			l.Vertices.Add(new Point(54, 23));
			Assert.IsTrue(l.IsClosed);
			Assert.AreEqual(114.15056678325843, l.Length);
			Assert.AreNotSame(l.Clone(), l);
			Assert.AreNotSame(l.Clone().Vertices[0], l.Vertices[0]);
			Assert.AreEqual(l.Clone(), l);
			LineString l2 = l.Clone();
			l2.Vertices[2] = l2.Vertices[2] + new Point(1, 1);
			Assert.AreNotEqual(l2, l);
			l2 = l.Clone();
			l2.Vertices.Add(new Point(34, 23));
			Assert.AreNotEqual(l2, l);
		}
		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);
		}