/// <summary>
		/// Writes the type number for this geometry.
		/// </summary>
		/// <param name="geometry">The geometry to determine the type of.</param>
		private void WriteType(Geometry geometry)
		{
			//Determine the type of the geometry.
			switch( geometry.GetGeometryType() )
			{
				//Points are type 1.
				case "Point":
					_bWriter.Write(1);
					break;
				//Linestrings are type 2.
				case "LineString":
					_bWriter.Write(2);
					break;
				//Polygons are type 3.
				case "Polygon":
					_bWriter.Write(3);
					break;
				//Mulitpoints are type 4.
				case "MultiPoint":
					_bWriter.Write(4);
					break;
				//Multilinestrings are type 5.
				case "MultiLineString":
					_bWriter.Write(5);
					break;
				//Multipolygons are type 6.
				case "MultiPolygon":
					_bWriter.Write(6);
					break;
				//Geometrycollections are type 7.
				case "GeometryCollection":
					_bWriter.Write(7);
					break;
				//If the type is not of the above 7 throw an exception.
				default:
					throw new ArgumentException("Invalid Geometry Type");
			}
		}
示例#2
0
		/// <summary>
		/// Runs a test. Each test is executed in a try/catch block to catch any exception that might be thrown.
		/// </summary>
		/// <param name="aGeometry">The A geometry object</param>
		/// <param name="bGeometry">The B geometry object</param>
		/// <param name="detailedExceptionMessages">boolean to see if detailed exception messages are desired.</param>
		/// <returns>A TestResult object containing the results of the test.</returns>
		public TestResult Run(Geometry aGeometry, Geometry bGeometry, bool detailedExceptionMessages)
		{
			// Grab the types of the a and b geometries and store them
			// in the TestResult object...
			this._testResult.AGeometryType = aGeometry.GetGeometryType();
			// make sure the bGeometry is not null...
			if(bGeometry != null)
			{
				this._testResult.BGeometryType = bGeometry.GetGeometryType();
			}

			// Grab the name of the test to run...
			string testToRun = this.Operation.Name;

			// set up arg1...
			string arg1 = "A";
			if(this._op.Arg1 == "B")
			{
				arg1 = "B";
			}

			// make it lowercase...
			testToRun = testToRun.ToLower();

			// run the tests in a try/catch block to trap any exceptions that may
			// be thrown...
			try
			{
				// determine which test to run and then call the appropriate function...
				switch(testToRun)
				{
					case "getboundary":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "convexhull":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "intersection":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "union":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "difference":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "symdifference":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "buffer":
						RunGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "dimension":
						RunGeometryPropertyTest(aGeometry, bGeometry, arg1, testToRun);
						break;
					case "numpoints":
						RunGeometryPropertyTest(aGeometry, bGeometry, arg1, testToRun);
						break;
					case "overlaps":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "contains":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "within":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "crosses":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "intersects":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "touches":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "disjoint":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "relate":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "equals":
						RunBooleanReturnGeometryFunction(aGeometry, bGeometry, testToRun);
						break;
					case "isvalid":
						RunBooleanReturnPropertyFunction(aGeometry, bGeometry, arg1, testToRun);
						break;
					case "isempty":
						RunBooleanReturnPropertyFunction(aGeometry, bGeometry, arg1, testToRun);
						break;
					case "issimple":
						RunBooleanReturnPropertyFunction(aGeometry, bGeometry, arg1, testToRun);
						break;
					default:
						break;
				}
			}
			catch(System.Exception e)
			{
				// load the details of the exception in the TestResult...
				SetExceptionData(e, detailedExceptionMessages);
			}

			if(this._testResult.PassFailWKT == true)
			{
				_passed = true;
			}
			else
			{
				_passed = false;
			}

			return this._testResult;
		}
		/// <summary>
		/// Writes the geometry to the binary writer.
		/// </summary>
		/// <param name="geometry">The geometry to be written.</param>
		private void WriteGeometry(Geometry geometry, byte format)
		{
			switch( geometry.GetGeometryType() )
			{
				//Write the point.
				case "Point":
					Point point = (Point)geometry;
					WritePoint(point);
					break;
				//Write the Linestring.
				case "LineString":
					LineString ls = (LineString)geometry;
					WriteLineString(ls, format);
					break;
				//Write the Polygon.
				case "Polygon":
					Polygon poly = (Polygon)geometry;
					WritePolygon(poly, format);
					break;
				//Write the Multipoint.
				case "MultiPoint":
					MultiPoint mp = (MultiPoint)geometry;
					WriteMultiPoint(mp, format);
					break;
				//Write the Multilinestring.
				case "MultiLineString":
					MultiLineString mls = (MultiLineString)geometry;
					WriteMultiLineString(mls, format);
					break;
				//Write the Multipolygon.
				case "MultiPolygon":
					MultiPolygon mPoly = (MultiPolygon)geometry;
					WriteMultiPolygon(mPoly, format);
					break;
				//Write the Geometrycollection.
				case "GeometryCollection":
					GeometryCollection gc = (GeometryCollection)geometry;
					WriteGeometryCollection(gc, format);
					break;
				//If the type is not of the aboce 7 throw an exception.
				default:
					throw new ArgumentException("Invalid Geometry Type");
			}
		}
示例#4
0
		private void SetResultGeometryType(Geometry g)
		{
			this._testResult.ResultGeometryType = g.GetGeometryType();
		}