public void TestRoundTrip(string filename)
		{
			//
			// can't round trip since I added the ToExternal/ ToInternal to the shapefile readers and writers.
			// 
			PrecisionModel pm = new PrecisionModel();
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			int differenceCount=0;
			string testName="";
			string srcShpFilename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\"+filename;
			string destShpFilename = Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\testroundtrip"+filename;

			// do the round trip
			ShapefileReader shpReader = new ShapefileReader(srcShpFilename+".shp", geometryFactory);
			GeometryCollection shapes = shpReader.ReadAll();

			ShapefileWriter.Write(destShpFilename,shapes, geometryFactory);

			// perfom binary compare on the .shp 
			testName = String.Format("Test round trip .shp - {0}",filename);
			differenceCount = Compare.BinaryCompare(srcShpFilename+".shp", destShpFilename+".shp");
			Assertion.AssertEquals(testName,0,differenceCount);

			// perfom binary compare on the .shx file
			testName = String.Format("Test round trip .shx - {0}",filename);
			differenceCount = Compare.BinaryCompare(srcShpFilename+".shx", destShpFilename+".shx");
			Assertion.AssertEquals(testName,0,differenceCount);

		}
		public static bool TestHelper(string wkt)
		{
			PrecisionModel pm = new PrecisionModel(1, 0, 0);
			GeometryFactory fact = new GeometryFactory(pm, 0);

			//read wkt
			Geometry a = (Geometry)fact.CreateFromWKT(wkt);

			//write wkb
			FileStream fs = new FileStream("TestFile.wkb", FileMode.Create);
			BinaryWriter bw = new BinaryWriter(fs);
			GeometryWKBWriter bWriter = new GeometryWKBWriter(fact);
			bWriter.Write(a, bw, (byte)1);
			bw.Close();
			fs.Close();

			//read wkb
			fs = new FileStream("TestFile.wkb", FileMode.Open);
			byte[] bytes = new byte[fs.Length];
			for(int i = 0; i < fs.Length; i++)
			{
				bytes[i] = (byte)fs.ReadByte();
			}
			GeometryWKBReader bReader = new GeometryWKBReader(fact);
			Geometry geom = bReader.Create(bytes);
			fs.Close();

			//write to wkt & compare with original text.
			bool results = ( Compare.WktStrings(wkt,a.ToText()));
			return results;
		}
		public abstract  int GetLength(Geometry geometry); //length in 16bit words

		public static Envelope GetEnvelopeExternal(PrecisionModel precisionModel, Envelope envelope)
		{
			// get envelopse in external coordinates
			Coordinate min = new Coordinate(envelope.MinX, envelope.MinY); 
			Coordinate max = new Coordinate(envelope.MaxX, envelope.MaxY);
			min = precisionModel.ToExternal(min);
			max = precisionModel.ToExternal(max);
			Envelope bounds = new Envelope(min.X, max.X, min.Y, max.Y);
			return bounds;
		}
		/// <summary>
		/// Initializes a GeometryCollection.
		/// </summary>
		/// <param name="geometries">
		/// The Geometries for this GeometryCollection, or null or an 
		/// empty array to create the empty geometry.  Elements may be empty 
		/// Geometries, but not nulls.
		/// </param>
		/// <param name="precisionModel">
		/// The specification of the grid of allowable points for this GeometryCollection.
		/// </param>
		/// <param name="SRID">
		/// The ID of the Spatial Reference System used by this GeometryCollection.
		/// </param>
		public GeometryCollection(Geometry[] geometries, PrecisionModel precisionModel, int SRID) : base(precisionModel,SRID) 
		{
			if(geometries == null) 
			{
				geometries = new Geometry[]{};
			}
			if(HasNullElements(geometries)) 
			{
				throw new ArgumentException("Geometries must not contain null elements.");
			}
			this._geometries = geometries;
		}
		/// <summary>
		/// Initializes a new instance of the MultiPolygon class.
		/// </summary>
		/// <param name="polygons">
		/// The Polygons for this MultiPolygon, or null or an empty array to create 
		/// the empty geometry.  Elements may be empty Polygons, but not nulls. The 
		/// polygons must conform to the assertions specified in the 
		/// OpenGIS Simple Features Specification.
		/// </param>
		/// <param name="precisionModel">The specification of the grid of allowable 
		/// points for this MultiPolygon.</param>
		/// <param name="SRID">
		///	The ID of the Spatial Reference System used by this MultiPolygon.
		/// </param>
		internal MultiPolygon(Polygon[] polygons, PrecisionModel precisionModel, int SRID) : base(polygons, precisionModel, SRID)
		{
			if(polygons == null)
			{
				polygons = new Polygon[]{};
			}
			if (HasNullElements(polygons))
			{
				throw new ArgumentNullException("Polygon array must not contain null elements.");
			}
			_geometries = polygons;
		}
		/// <summary>
		/// Initializes a new instance of the MultiLineString class.
		/// </summary>
		/// <param name="lineStrings">
		/// The LineStrings for this MultiLineString, or null or an 
		/// empty array to create the empty MultiLineString.  Elements may be empty 
		/// LineStrings, but not nulls.
		/// </param>
		/// <param name="precisionModel">
		/// The specification of the grid of allowable points for this MultiLineString.
		/// </param>
		/// <param name="SRID">
		/// The ID of the Spatial Reference System used by this MultiLineString.
		/// </param>
		internal MultiLineString(LineString[] lineStrings, PrecisionModel precisionModel, int SRID)
			: base(lineStrings, precisionModel, SRID)
		{
			if(lineStrings == null)
			{
				lineStrings = new LineString[]{};
			}
			if(HasNullElements(lineStrings))
			{
				throw new ArgumentException("MultiLineStrings cannot have nulls.");
			}
			_geometries = lineStrings;
		}
Beispiel #7
0
		/// <summary>
		/// Initializes a new instance LinearRing with the given points.
		/// </summary>
		/// <param name="points">
		/// Points forming a closed and simple linestring, or null or an empty array 
		/// to create the empty geometry. This array must not contain null elements. 
		/// Consecutive  points may not be equal.
		/// </param>
		/// <param name="precisionModel">
		/// The specification of the grid of allowable points for this LinearRing.
		/// </param>
		/// <param name="SRID">
		/// The ID of the Spatial Reference System used by this LinearRing.
		/// </param>
		internal LinearRing(Coordinates points, PrecisionModel precisionModel, int SRID) 
			: base(points,precisionModel,SRID)
		{
			if (!IsEmpty() && !base.IsClosed()) 
			{
				// uses base.IsClosed() since this.IsClosed() always returns true.
				throw new ArgumentException("Points must form a closed linestring.");
			}
			if ((points != null) && (points.Count >= 1 && points.Count <= 3)) 
			{
				throw new ArgumentException("Points must contain 0 or >3 elements.");
			}
		}
Beispiel #8
0
		/// <summary>
		/// Constructs a LineString with the given points.
		/// </summary>
		/// <param name="points">
		/// The points of the linestring, or null to create the empty geometry. This array must not contain null 
		/// elements. Consecutive points may not be equal.
		/// </param>
		/// <param name="precisionModel">The specification of the grid of allowable points for this LineString.</param>
		/// <param name="SRID"> The ID of the Spatial Reference System used by this LineString.</param>
		internal LineString(Coordinates points, PrecisionModel precisionModel, int SRID) : base( precisionModel, SRID)
		{
			if (points == null) 
			{
				points = new Coordinates();
			}
			if (HasNullElements(points))
			{
				throw new ArgumentNullException("point array must not contain null elements");
			}
			if (points.Count == 1)
			{
				throw new ArgumentException("point array must contain 0 or >1 elements");
			}
			this._points = points;
		}
		/// <summary>
		/// Writes three geometries to an svg file
		/// </summary>
		/// <param name="filename">The path of the svg file.</param>
		/// <param name="a">The A geometry</param>
		/// <param name="b">The B geometry</param>
		/// <param name="c">The C geometry</param>
		public void DisplayTest(string filename, Geometry a, Geometry b, Geometry c)
		{
			Geotools.Geometries.PrecisionModel pm = new Geotools.Geometries.PrecisionModel(1, 0, 0);
			GeometryFactory fact = new GeometryFactory(pm, 0);
			GeometrySVGWriter svgWriter = new GeometrySVGWriter(fact.PrecisionModel);
			StreamWriter sw = new StreamWriter(filename);
			GeometryCollection geomCollection= fact.CreateGeometryCollection(new Geometry[]{a,b,c});
			double minx, miny, maxx, maxy;
			geomCollection.Extent2D(out minx, out miny, out maxx, out maxy);
			sw.WriteLine(String.Format("<svg viewBox=\"{0} {1} {2} {3}\">",minx,miny,maxx,maxy*1.2));
			svgWriter.Write(a,sw,"fill-rule:evenodd;","fill:none;stroke:blue;stroke-width:1;fill-opacity:0.2");
			svgWriter.Write(b,sw,"fill-rule:evenodd;","fill:none;stroke:red;stroke-width:1;fill-opacity:0.2");
			svgWriter.Write(c,sw,"fill-rule:evenodd;","fill:yellow;stroke:green;stroke-width:2;fill-opacity:0.5;stroke-dasharray:2,2");
			sw.WriteLine("</svg>");
			sw.Close();
		}
		/// <summary>
		///	 Creates the DecimalFormat used to write doubles
		///  with a sufficient number of decimal places.
		/// </summary>
		/// <param name="precisionModel">The precision model used to determine the number of
		/// decimal places to write.</param>
		/// <returns>Returns a DecimalFormat object that writes doubles without scientific notation.</returns>
		private static string CreateFormatter(PrecisionModel precisionModel) 
		{
			return "r";
			/*
			// the default number of decimal places is 16, which is sufficient
			// to accomodate the maximum precision of a double.
			int decimalPlaces = 16;
			if (! precisionModel.isFloating()) 
			{
				decimalPlaces = 1 + (int) Math.ceil(Math.log(precisionModel.GetScale()) / Math.log(10));
			}
			return new DecimalFormat("#" + (decimalPlaces > 0 ? "." : "")
				+ stringOfChar('#', decimalPlaces));
				
		
			return null;*/
		}
		/// <summary>
		/// Test getting and setting the properties
		/// </summary>
		public void Test_MultipleRead() 
		{
			PrecisionModel pm = new PrecisionModel(1,0,0);
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop.shp";
			
			// tests two readers reading the file as the same time.
			Geotools.IO.ShapefileReader shpFile = new Geotools.IO.ShapefileReader(filename, geometryFactory);
			Geotools.IO.ShapefileReader shpFile2 = new Geotools.IO.ShapefileReader(filename, geometryFactory);
			foreach(object row in shpFile)
			{
				Assertion.AssertNotNull(row);
				foreach(object row2 in shpFile2)
				{
					Assertion.AssertNotNull(row2);
				}
			}	
		}
		public void Test_CreateDataTable()
		{
			PrecisionModel pm = new PrecisionModel(100,0,0);
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop";
			DataTable table = Geotools.IO.Shapefile.CreateDataTable(filename, "State", geometryFactory);
			DataSet ds = new DataSet();
			ds.Tables.Add(table);

			// make sure the datagrid gets the column headings.
			DataGrid grid = new DataGrid();
			grid.DataSource = ds;
			grid.DataMember="State";
			grid.DataBind();

			TextWriter tempWriter = new StringWriter();
			grid.RenderControl(new HtmlTextWriter(tempWriter));
			string html = tempWriter.ToString();
			bool same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\ExpectedDataGridDataReader.txt",html);
			Assertion.AssertEquals("Datagrid properties",true,same);
		}
Beispiel #13
0
		/// <summary>
		/// Initializes a Polygon with the given exterior boundary.  The shell and holes 
		/// must conform to the assertions specified in the OpenGIS Simple Features
		/// Specification for SQL.
		/// </summary>
		/// <param name="shell">
		///	The outer boundary of the new Polygon, or null or an empty LinearRing if the empty
		///	geometry is to be created. Must be oriented clockwise.
		/// </param>
		/// <param name="holes">
		/// The inner boundaries of the new Polygon, or null or empty LinearRings if the empty 
		/// geometry is to be created. Each must be oriented counterclockwise.
		/// </param>
		/// <param name="precisionModel">
		/// The specification of the grid of allowable points for this Polygon.
		/// </param>
		/// <param name="SRID">
		/// The ID of the Spatial Reference System used by this Polygon.
		/// </param>
		internal Polygon(LinearRing shell, LinearRing[] holes, PrecisionModel precisionModel, int SRID) : base(precisionModel, SRID)
		{
			if (shell == null) 
			{
				shell = _geometryFactory.CreateLinearRing(null);
			}
			if (holes == null) 
			{
				holes = new LinearRing[]{};
			}
			//OPTIMIZE: - if fully optimzed, don't bother doing this test.
			if (HasNullElements(holes)) 
			{
				throw new ArgumentNullException("holes must not contain null elements");
			}
			if (shell.IsEmpty() && HasNonEmptyElements(holes)) 
			{
				throw new ArgumentException("shell is empty but holes are not");
			}
			_shell = shell;
			_holes = holes;
		}
		public void Test_TestRead() 
		{
			PrecisionModel pm = new PrecisionModel(100000,0,0);
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			//DataSets can be enumerated thru, or you can use Read(). This one tests the read;
			string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop";
			ShapefileDataReader shpDataReader = Geotools.IO.Shapefile.CreateDataReader(filename, geometryFactory);

			int i=0;
			while (shpDataReader.Read())
			{
				i++;
			}
			Assertion.AssertEquals("Read using Read()",49,i);
		}
		public void Test_TestGets() 
		{
			PrecisionModel pm = new PrecisionModel(1,0,0);
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop";
			ShapefileDataReader shpDataReader = Geotools.IO.Shapefile.CreateDataReader(filename, geometryFactory);


			// note alaska and hawaii are missing - hence 48 states not 50.
			
			// tests GetValues().
			object[] values = new object[shpDataReader.FieldCount];
			foreach(object columnValues in shpDataReader)
			{
				if (columnValues==null)
				{
					Assertion.Fail("columnValues should have data.");
				}
				// get  values using GetValue()
				for(int i = 0; i < shpDataReader.FieldCount; i++)
				{
					values[i] = shpDataReader.GetValue(i);
				}

				// get values using GetValues()
				object[] values2=new object[shpDataReader.FieldCount];
				shpDataReader.GetValues(values2);

				// ensure they are both the same.
				for(int i = 0; i < shpDataReader.FieldCount; i++)
				{
					Assertion.AssertEquals("Values "+i, values[i], values2[i]);
				}
			}		
		}
		public GeometrySVGWriter(PrecisionModel precisionModel, string xmlNamespace, int decimalPlaces)
		{
			_formatterString = CreateFormatter(decimalPlaces);
			_namespace = xmlNamespace;
			_precisionModel = precisionModel;
		}
		/// <summary>
		/// Initializes a new instance of the GeometrySVGWriter class.
		/// </summary>
		public GeometrySVGWriter(PrecisionModel precisionModel): this(precisionModel,"",5)
		{

		}
		/// <summary>
		/// Converts a Coordinate to &lt;Point&gt; format, then Appends
		/// it to the writer. 
		/// </summary>
		/// <param name="coordinate">The Coordinate to process.</param>
		/// <param name="writer">The output writer to Append to.</param>
		/// <param name="precisionModel">The PrecisionModel to use to convert
		/// from a precise coordinate to an external coordinate</param>
		protected void AppendCoordinate(Coordinate coordinate, TextWriter writer, PrecisionModel precisionModel)
		{
			//throw new NotFiniteNumberException();
			Coordinate externalCoordinate = new Coordinate();
			precisionModel.ToExternal(coordinate, externalCoordinate);
			writer.Write(" " + WriteNumber(externalCoordinate.X) + " " + WriteNumber(externalCoordinate.Y));
			//writer.Write(WriteNumber(coordinate.X) + " " + WriteNumber(coordinate.Y));
			
		}
		/// <summary>
		/// Converts a Coordinate to &lt;Point Tagged Text&gt; format,
		/// then Appends it to the writer.
		/// </summary>
		/// <param name="coordinate">the <code>Coordinate</code> to process</param>
		/// <param name="writer">the output writer to Append to</param>
		/// <param name="precisionModel">the PrecisionModel to use to convert
		///  from a precise coordinate to an external coordinate</param>
		protected void AppendPointTaggedText(Coordinate coordinate,  TextWriter writer, 	PrecisionModel precisionModel)
		{
			Coordinate externalCoordinate = new Coordinate();
			precisionModel.ToExternal(coordinate, externalCoordinate);
			if (this._cssClass!="")
			{
				writer.WriteLine(String.Format("<{5}circle class=\"{0}\" style=\"{1}\" cx=\"{2}\" cy=\"{3}\" r=\"{4}\"/>",_cssClass,_style,WriteNumber(externalCoordinate.X),WriteNumber(externalCoordinate.Y),_radius,_namespace));			
			}
			else
			{
				writer.WriteLine(String.Format("<{4}circle  style=\"{0}\" cx=\"{1}\" cy=\"{2}\" r=\"{3}\"/>",_style,WriteNumber(externalCoordinate.X),WriteNumber(externalCoordinate.Y),_radius,_namespace));			
			}
		}
		/// <summary>
		/// Converts a Coordinate to &lt;Point Tagged Text&gt; format,
		/// then Appends it to the writer.
		/// </summary>
		/// <param name="coordinate">the <code>Coordinate</code> to process</param>
		/// <param name="level"></param>
		/// <param name="writer">the output writer to Append to</param>
		/// <param name="precisionModel">the PrecisionModel to use to convert
		///  from a precise coordinate to an external coordinate</param>
		protected void AppendPointTaggedText(Coordinate coordinate, int level, StringWriter writer,
											 PrecisionModel precisionModel)
		{
			
			writer.Write("POINT ");
			AppendPointText(coordinate, level, writer, precisionModel);
			
		}
Beispiel #21
0
		public void Test2()
		{
			IDbConnection connection = Global.GetEPSGDatabaseConnection();
			PrecisionModel pm = new PrecisionModel(100.0, 0.0, 0.0);
			CoordinateTransformationEPSGFactory CTfactory = new CoordinateTransformationEPSGFactory(connection);
			ICoordinateTransformation UKNationalGrid1 = CTfactory.CreateFromTransformationCode("1681");
			GeometryFactory geometryFactory = new GeometryFactory(pm,4326);

			string wkt = "POINT ( -1 50 )";
			Assertion.AssertEquals("Point 1",true,Compare2(wkt,"POINT (471659.59 11644.49)", geometryFactory, UKNationalGrid1));
			
		}
		/// <summary>
		/// Creates a GeometryFactory that creates Geometrys using the given precisionModel and SRID.
		/// </summary>
		/// <param name="precisionModel">the specification of the grid of allowable points for Geometrys created by this GeometryFactory.</param>
		/// <param name="SRID">The ID of the Spatial Reference System used by Geometry created by this GeometryFactory.</param>
		public GeometryFactory(PrecisionModel precisionModel, int SRID) 
		{
			_precisionModel = precisionModel;
			_SRID = SRID;
		}
Beispiel #23
0
        public void test_Coords()
        {
            PrecisionModel precisionModel = new PrecisionModel();

            //Set the coord to be empty
            Coordinate coord = new Coordinate();
            coord = null;
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coord);

            //test that true is returned because the coordinates are empty.
            Assertion.AssertEquals("Coords - true: ", true, point.IsEmpty());

            //Put something into the coordinates
            Coordinate coordinate = new Coordinate(1.0,2.0);

            //create a new point
            point = gf.CreatePoint(coordinate);

            //test that false is returned because the coordinates are not empty.
            Assertion.AssertEquals("Coords - false: ", false, point.IsEmpty());
        }
		/// <summary>
		/// Copy constructor to create a new PrecisionModel from an existing one.
		/// </summary>
		/// <param name="pm">The existing precisionmodel to use to create the new one.</param>
		public PrecisionModel(PrecisionModel pm) 
		{
			_modelType = pm.ModelType;
			_scale = pm.Scale;
			_offsetX = pm.OffsetX;
			_offsetY = pm.OffsetY;
		}
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the GeometryGraph class.
 /// </summary>
 public GeometryGraph( int argIndex, Geometry parentGeometry )
 {
     _argIndex = argIndex;
     _parentGeometry = parentGeometry;
     if ( parentGeometry != null )
     {
         _precisionModel = parentGeometry.PrecisionModel;
         _SRID = parentGeometry.GetSRID();
         Add( parentGeometry );
     }
 }
		/// <summary>
		/// Converts a Coordinate to Point Text format then Appends it to the writer.
		/// </summary>
		/// <param name="coordinate">The Coordinate to process.</param>
		/// <param name="level"></param>
		/// <param name="writer">The output stream writer to Append to.</param>
		/// <param name="precisionModel">The PrecisionModel to use to convert from a precise
		/// coordinate to an external coordinate.</param>
		protected void AppendPointText( Coordinate coordinate, int level, StringWriter writer,
										PrecisionModel precisionModel)
		{
			
			if (coordinate == null) 
			{
				writer.Write("EMPTY");
			}
				else 
			{
				writer.Write("(");
				AppendCoordinate(coordinate, writer, precisionModel);
				writer.Write(")");
			}
			
		}
		public void Test_TestConstructor() 
		{
			PrecisionModel pm = new PrecisionModel(100000,0,0);
			GeometryFactory geometryFactory = new GeometryFactory(pm,-1);

			string filename= Global.GetUnitTestRootDirectory()+@"\IO\Shapefile\Testfiles\statepop";
			ShapefileDataReader shpDataReader = Geotools.IO.Shapefile.CreateDataReader(filename, geometryFactory);

			int i=0;
			//for( i=0;i<shpDataReader.FieldCount;i++)
			//{
			//	Console.WriteLine(i+" "+shpDataReader.GetName(i) +" " +shpDataReader.GetFieldType(i));
			//}
			
			Assertion.AssertEquals("Dbase header: Num records", 49, shpDataReader.RecordCount);
			Assertion.AssertEquals("Dbase header: Num fields", 253, shpDataReader.FieldCount);
			
			Assertion.AssertEquals("Field 1: name", "STATE_NAME", shpDataReader.GetName(1));
			Assertion.AssertEquals("Field 1: name", typeof(string), shpDataReader.GetFieldType(1));

			Assertion.AssertEquals("Field 252: name", "SAMP_POP", shpDataReader.GetName(252));
			Assertion.AssertEquals("Field 252: name", typeof(double), shpDataReader.GetFieldType(252));


			// note alaska and hawaii are missing - hence 48 states not 50.
			i=0;
			foreach(object columnValues in shpDataReader)
			{
				if (columnValues==null)
				{
					Assertion.Fail("columnValues should not be null.");
				}
				if (i==0)
				{
					Assertion.AssertEquals("Row1: STATE_NAME:","Illinois", shpDataReader.GetString(1));
					Assertion.AssertEquals("Row1: STATE_FIPS:","17", shpDataReader.GetValue(2));
					Assertion.AssertEquals("Row1: SAMP_POP", 1747776.0, shpDataReader.GetDouble(252));
				}
				if (i==48)
				{
					Assertion.AssertEquals("Row1: STATE_NAME:","Washington", shpDataReader.GetString(1));
					Assertion.AssertEquals("Row1: STATE_FIPS:","53", shpDataReader.GetValue(2));
					Assertion.AssertEquals("Row1: SAMP_POP", 736744.0, shpDataReader.GetDouble(252));
				}
				i++;
			}
			Assertion.AssertEquals("49 Records",49,i);

			// try opening the file again, to make sure file is not locked from previous reader.
			ShapefileDataReader shpDataReader2 = Geotools.IO.Shapefile.CreateDataReader(filename, geometryFactory);
			i=0;
			while (shpDataReader2.Read())
			{
				if (i==0)
				{
					Assertion.AssertEquals("Row1: STATE_NAME:","Illinois", shpDataReader2.GetString(1));
					Assertion.AssertEquals("Row1: STATE_FIPS:","17", shpDataReader2.GetValue(2));
					Assertion.AssertEquals("Row1: SAMP_POP", 1747776.0, shpDataReader2.GetDouble(252));
				}
				if (i==48)
				{
					Assertion.AssertEquals("Row1: STATE_NAME:","Washington", shpDataReader2.GetString(1));
					Assertion.AssertEquals("Row1: STATE_FIPS:","53", shpDataReader2.GetValue(2));
					Assertion.AssertEquals("Row1: SAMP_POP", 736744.0, shpDataReader2.GetDouble(252));
				}
				i++;
			}
			Assertion.AssertEquals("49 Records",49,i);
		}
Beispiel #28
0
		private void PerformSystemTest(string filename)
		{
				
			//Geometries.PrecisionModel pm = new Geometries.PrecisionModel();
			Run run = GetTestRun(filename);
			int testCount=0;
			int failCount=0;
			int opCount=0;
			int resultCount=0;
			foreach(TestRunner.TestCase testcase in run)
			{
				foreach(TestRunner.Test test in testcase)
				{
					Geotools.Geometries.PrecisionModel pm;
					
					if (run.PrecisionModel.Type=="FLOATING")
					{
						pm = new Geotools.Geometries.PrecisionModel();
					}
					else
					{
						pm = new Geotools.Geometries.PrecisionModel(double.Parse(run.PrecisionModel.Scale), double.Parse(run.PrecisionModel.OffSetX), double.Parse(run.PrecisionModel.OffSetY));
					}

					testCount++;
					Geometry a = null;
					Geometry b = null;
					if (testcase.A.Trim()!="")
					{
						a= (Geometry)testcase.CreateAGeometry(pm);
					}
					if (testcase.B.Trim()!="")
					{
						b= (Geometry)testcase.CreateBGeometry(pm);
					}
					test.Run(a, b, true);

					if(test.Passed == false)
					{
						Console.WriteLine(test.Operation.Name + " failed."+filename);
						failCount++;
					}
					else
					{
						//Console.WriteLine(t.Operation.Name + " passed.");
						//passedTests++;
					}
				}	
			}
			//Console.WriteLine(filename);
			//Console.WriteLine("tests: "+testCount);
			//Console.WriteLine("failed "+failCount);
			//Console.WriteLine("Ops "+opCount);
			//Console.WriteLine("Creates "+resultCount);
			//Console.WriteLine("-----------------------------");
			if (failCount>0)
			{
				Assertion.Fail(String.Format("{0} had {1} fails.",filename, failCount));
			}
		}
		/// <summary>
		/// Converts a Coordinate to &lt;Point&gt; format, then Appends
		/// it to the writer. 
		/// </summary>
		/// <param name="coordinate">The Coordinate to process.</param>
		/// <param name="writer">The output writer to Append to.</param>
		/// <param name="precisionModel">The PrecisionModel to use to convert
		/// from a precise coordinate to an external coordinate</param>
		protected void AppendCoordinate(Coordinate coordinate, StringWriter writer, PrecisionModel precisionModel)
		{
			
			Coordinate externalCoordinate = new Coordinate();
			precisionModel.ToExternal(coordinate, externalCoordinate);
			writer.Write(WriteNumber(externalCoordinate.X) + " " + WriteNumber(externalCoordinate.Y));
			
		}
Beispiel #30
0
 /// <summary>
 /// This constructor is used by clients that wish to add Edges explicitly, rather than adding a Geometry.  (An example is BufferOp).
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="precisionModel"></param>
 /// <param name="SRID"></param>
 public GeometryGraph(int argIndex, PrecisionModel precisionModel, int SRID)
     : this(argIndex, null)
 {
     _precisionModel = precisionModel;
     _SRID = SRID;
 }