コード例 #1
0
		/// <summary>
		/// Method to create a MultiPoint for testing purposes
		/// </summary>
		/// <returns>A MultiPoint</returns>
		private MultiPoint CreateTester1()
		{
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

			Point[] points = new Point[23];

			for(int i = 0; i < 12; i++)
			{
				points[i] = gf.CreatePoint(new Coordinate(i, i));
			}
			points[12] = gf.CreatePoint(new Coordinate(11, 12));
			points[13] = gf.CreatePoint(new Coordinate(10, 13));
			points[14] = gf.CreatePoint(new Coordinate(9, 14));
			points[15] = gf.CreatePoint(new Coordinate(8, 15));
			points[16] = gf.CreatePoint(new Coordinate(9, 16));
			points[17] = gf.CreatePoint(new Coordinate(10, 17));
			points[18] = gf.CreatePoint(new Coordinate(11, 18));
			points[19] = gf.CreatePoint(new Coordinate(12, 19));
			points[20] = gf.CreatePoint(new Coordinate(11, 20));
			points[21] = gf.CreatePoint(new Coordinate(10, 21));
			points[22] = gf.CreatePoint(new Coordinate(9, 22));

			MultiPoint mp = gf.CreateMultiPoint(points);
			return mp;
		}
コード例 #2
0
		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);

		}
コード例 #3
0
ファイル: EdgeRing.cs プロジェクト: vmoll/geotools
        private EdgeRing _shell; // if non-null, the ring is a hole and this EdgeRing is its containing shell

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the EdgeRing class.
        /// </summary>
        public EdgeRing( DirectedEdge start, GeometryFactory geometryFactory, CGAlgorithms cga )
        {
            _geometryFactory = geometryFactory;
            _cga = cga;
            ComputePoints(start);
            ComputeRing();
        }
コード例 #4
0
		private Polygon Poly1()
		{
			_coords1 = new Coordinates();
			Coordinate coord = new Coordinate(5, 1);
			_coords1.Add(coord);
			coord = new Coordinate(6, 2);
			_coords1.Add(coord);
			coord = new Coordinate(7, 3);
			_coords1.Add(coord);
			coord = new Coordinate(6, 4);
			_coords1.Add(coord);
			coord = new Coordinate(5, 5);
			_coords1.Add(coord);
			coord = new Coordinate(4, 4);
			_coords1.Add(coord);
			coord = new Coordinate(3, 3);
			_coords1.Add(coord);
			coord = new Coordinate(4, 2);
			_coords1.Add(coord);
			coord = new Coordinate(5, 1);
			_coords1.Add(coord);

			_gf = new GeometryFactory(_precMod, _sRID);
			_exterior1 = _gf.CreateLinearRing(_coords1);
			Polygon polygon = _gf.CreatePolygon(_exterior1);

			return polygon;
		}
コード例 #5
0
ファイル: BufferOp.cs プロジェクト: xuchuansheng/GenXSource
		/// <summary>
		/// Initializes a new instance of the BufferOp class.
		/// </summary>
		/// <param name="g0"></param>
		public BufferOp(Geometry g0) : base(g0)
		{
			
			_graph = new PlanarGraph(new OverlayNodeFactory());
			_geomFact = new GeometryFactory( g0.PrecisionModel,	g0.GetSRID() );
		
		}
コード例 #6
0
		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;
		}
コード例 #7
0
ファイル: TestCase.cs プロジェクト: carlhuth/GenXSource
        /// <summary>
        /// Creates the "B" geometry for this TestCase by instantiating a GeometryFactory object and
        /// calling its CreateFromWKT method. The geometry object is created from its Well-known text.
        /// </summary>
        /// <param name="precisionModel">The precision model for this run.</param>
        /// <returns>OGC.SimpleFeatures.IGeometry object.</returns>

        public IGeometry CreateBGeometry(Geotools.Geometries.PrecisionModel precisionModel)
        {
            // create the GeometryFactory object...
            Geotools.Geometries.GeometryFactory geometryFactory = new Geotools.Geometries.GeometryFactory(precisionModel, -1);
            // create the geometry and return it...
            return(geometryFactory.CreateFromWKT(this._bGeometry));
        }
コード例 #8
0
ファイル: PointTest.cs プロジェクト: vmoll/geotools
        public void test_ApplyCoordinateFilter()
        {
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(_coor);
            //CoordinateFilter filter = new CoordinateFilter();

            //todo(Ronda): Apply
            //point.Apply(filter);
        }
コード例 #9
0
ファイル: PointTest.cs プロジェクト: xuchuansheng/GenXSource
		public void test_constructor()
		{
			GeometryFactory gf = new GeometryFactory(_precMod, _sRID);

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

			//Make sure the values
			Assertion.AssertEquals("Const-x: ", 1.0, point.X);
			Assertion.AssertEquals("Const-y: ", 2.0, point.Y);
		}
コード例 #10
0
ファイル: Test.cs プロジェクト: carlhuth/GenXSource
        /// <summary>
        /// This is a temporary method that is being used to test if two geometries are equal.
        /// This is being used because the normalize methods on the geometries has not been implemented
        /// and we are getting false failures due to the WKT strings being different.
        /// This method creates two geometry objects from well-known text strings and then calls
        /// the EqualsTopology method on one of them to see if they are equal.
        /// </summary>
        /// <param name="wkt1">The well-known text string for the first geometry.</param>
        /// <param name="wkt2">The well-known text string for the second geometry.</param>
        /// <returns>
        /// True if the geometries are equal otherwise returns false.</returns>
        private bool TestTopologyEquals(string wkt1, string wkt2)
        {
            // create the GeometryFactory object...
            Geotools.Geometries.GeometryFactory geometryFactory = new Geotools.Geometries.GeometryFactory();
            // create the two geometries from the well-known text strings...
            Geometry a = (Geometry)geometryFactory.CreateFromWKT(wkt1);
            Geometry b = (Geometry)geometryFactory.CreateFromWKT(wkt2);

            // Call the EqualsTopology method and return...
            return(a.EqualsTopology(b));
        }
コード例 #11
0
		/// <summary>
		/// Reads a stream and converts the shapefile record to an equilivent geometry object.
		/// </summary>
		/// <param name="file">The stream to read.</param>
		/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
		/// <returns>The Geometry object that represents the shape file record.</returns>
		public override Geometry Read(BigEndianBinaryReader file, GeometryFactory geometryFactory)
		{
			int shapeTypeNum = file.ReadInt32();
			ShapeType shapeType = (ShapeType)Enum.Parse(typeof(ShapeType),shapeTypeNum.ToString());
			if (shapeType != ShapeType.Arc)
			{
				throw new ShapefileException("Attempting to load a non-arc as arc.");
			}
			//read and for now ignore bounds.
			double[] box = new double[4];
			for (int i = 0; i < 4; i++) 
			{
				double d= file.ReadDouble();
				box[i] =d;
			}


        
			int numParts = file.ReadInt32();
			int numPoints = file.ReadInt32();
			int[] partOffsets = new int[numParts];
			for (int i = 0; i < numParts; i++)
			{
				partOffsets[i] = file.ReadInt32();
			}
			
			LineString[] lines = new LineString[numParts];
			int start, finish, length;
			for (int part = 0; part < numParts; part++)
			{
				start = partOffsets[part];
				if (part == numParts - 1)
				{
					finish = numPoints;
				}
				else 
				{
					finish = partOffsets[part + 1];
				}
				length = finish - start;
				Coordinates points = new Coordinates();
				points.Capacity=length;
				Coordinate external;
				for (int i = 0; i < length; i++)
				{
					external = new Coordinate(file.ReadDouble(),file.ReadDouble());
					points.Add( geometryFactory.PrecisionModel.ToInternal(external));
				}
				lines[part] = geometryFactory.CreateLineString(points);

			}
			return geometryFactory.CreateMultiLineString(lines);
		}
コード例 #12
0
		public void TestGetNextWord()
		{
			string wkt = "POINT *( 3  4 )";

			GeometryFactory factory = new GeometryFactory();
			try
			{
				IGeometry geometry = factory.CreateFromWKT(wkt);
				Assertion.Fail("parse exception");
			}
			catch(ParseException)
			{
			}
		}
コード例 #13
0
		public void Test1()
		{
			string wkt = null;

			GeometryFactory factory = new GeometryFactory();
			try
			{
				IGeometry geometry = factory.CreateFromWKT(wkt);
				Assertion.Fail("parse exception");
			}
			catch(ArgumentNullException)
			{
			}
		}
コード例 #14
0
		/// <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();
		}
コード例 #15
0
		/// <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);
				}
			}	
		}
コード例 #16
0
		public void Test1()
		{
			IDbConnection connection = Global.GetEPSGDatabaseConnection();
			_CTfactory = new CoordinateTransformationEPSGFactory(connection);
			_UKNationalGrid1 = _CTfactory.CreateFromTransformationCode("1681");
			_geometryFactory = new GeometryFactory(_pm,4326);
			string wkt = "POINT ( -2.0 49.0 )";
			Assertion.AssertEquals("Point 1",true,Compare(wkt,"POINT (400000 -100000)"));

			wkt = "MULTIPOINT( -2 49, -1 50)";
			Assertion.AssertEquals("Multipoint 1",true,Compare(wkt,"MULTIPOINT (400000 -100000, 471660 11644)"));

			wkt = "MULTIPOINT EMPTY";
			Assertion.AssertEquals("Multipoint 2",true,Compare(wkt,"MULTIPOINT EMPTY"));

			wkt = "LINESTRING(50 31, 54 31, 54 29, 50 29, 50 31 )";
			Assertion.AssertEquals("LineString 1 1",true,Compare(wkt,"LINESTRING (5664915 -615242, 6117479 -308294, 6306392 -569639, 5827846 -873669, 5664915 -615242)"));

			wkt = "POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )";
			Assertion.AssertEquals("Multipoint 3",true,Compare(wkt,"POLYGON ((5664915 -615242, 6117479 -308294, 6306392 -569639, 5827846 -873669, 5664915 -615242))"));


			//wkt = "POLYGON( ( 1 1, 10 1, 10 10, 1 10, 1 1),(4 4, 5 4, 5 5, 4 5, 4 4 ))";
			//Assertion.AssertEquals("Multipoint 4",true,Compare(wkt,"POLYGON ((733898 -5416388, 1744907 -5414055, 1724214 -4397377, 728899 -4420227, 733898 -5416388), "+
			//"(1067192 -5082521, 1178905 -5081633, 1177832 -4970278, 1066275 -4971386, 1067192 -5082521))"));

			// these tests fail because the strings are too long/ have a CR in the middle of the string. Should really fix this. awc.


			//wkt = "MULTILINESTRING (( 10.05  10.28 , 20.95  20.89 ),( 20.95  20.89, 31.92 21.45)) ";
			//Assertion.AssertEquals("Multipoint 5",false,Compare(wkt,"MULTILINESTRING ((1724213.5597264355 -4397376.6478565233, 2839122.2852214454 -3022771.8465291355), \n  "+ 
			//												"(2839122.2852214454 -3022771.8465291355, 4095081.5366646093 -2776957.6041615554))"));

			//wkt = "MULTIPOLYGON (((10 10, 10 20, 20 20, 20 15 , 10 10), (50 40, 50 50, 60 50, 60 40, 50 40)))";
			//Assertion.AssertEquals("Multipoint 6",true,Compare(wkt,"MULTIPOLYGON (((1724213.5597264355 -4397376.6478565233, 1662268.9948102259 -3270049.5581512651, 2745586.9073599684 -3156174.8212744244, 2817027.1068546474 -3744257.1145197917, 1724213.5597264355 -4397376.6478565233), "+
			//	 "(4882561.4795353347 438327.55639206013, 3970695.8611971624 1430641.0215268317, 4530976.2509158608 2096414.3039089143, 5721871.0214089518 1247465.211354611, 4882561.4795353347 438327.55639206013)))"));

			//wkt = "GEOMETRYCOLLECTION(POINT ( 3 4 ),LINESTRING(50 31, 54 31, 54 29, 50 29, 50 31 ))";
			//Assertion.AssertEquals("Multipoint 7",true,Compare(wkt,"GEOMETRYCOLLECTION (POINT (955682.872367636 -5083270.4404414054),"+
			//											"LINESTRING (-7.5557896002384908 49.766496583001434, -7.555734311078294 49.766499242352, -7.5557322582139372 49.76648133658518, -7.5557875473539609 49.7664786772363, -7.5557896002384908 49.766496583001434))"));

		}	
コード例 #17
0
		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);
		}
コード例 #18
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_GetBoundaryDimension()
        {
            //create a multilinestring
            MultiLineString multiLS = CreateMLS();

            //this returns a zero because it is not closed
            Assertion.AssertEquals("GetBoundaryDimension-1: ", 0, multiLS.GetBoundaryDimension());

            //now try it with a null multilinestring
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            //this returns a zero because it is not closed
            Assertion.AssertEquals("GetBoundaryDimension-2: ", 0, multiLS.GetBoundaryDimension());

            //now try it with a closed multilinestring
            multiLS = closedMLS();

            //this returns a -1 because it is closed
            Assertion.AssertEquals("GetBoundaryDimension-3: ", -1, multiLS.GetBoundaryDimension());
        }
コード例 #19
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_Geometry()
        {
            LineString[] linestrings = new LineString[2];
            Coordinates coords1 = new Coordinates();
            Coordinate coord = new Coordinate(5,3);
            coords1.Add(coord);
            coord = new Coordinate(4,5);
            coords1.Add(coord);
            coord = new Coordinate(3,4);
            coords1.Add(coord);

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LineString ls = gf.CreateLineString(coords1);
            linestrings[0] = ls;

            Coordinates coords2 = new Coordinates();
            coord = new Coordinate(2,7);
            coords2.Add(coord);
            coord = new Coordinate(9,2);
            coords2.Add(coord);
            coord = new Coordinate(7,9);
            coords2.Add(coord);

            ls = gf.CreateLineString(coords2);
            linestrings[1] = ls;

            MultiLineString mls = gf.CreateMultiLineString(linestrings);

            Assertion.AssertEquals("Geometry-1: ", "LineString:(5, 3, NaN),(4, 5, NaN),(3, 4, NaN)", mls.GetGeometryN(0).ToString());
            Assertion.AssertEquals("Geometry-2: ", "LineString:(2, 7, NaN),(9, 2, NaN),(7, 9, NaN)", mls.GetGeometryN(1).ToString());
        }
コード例 #20
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_EqualExact()
        {
            //create a geomerty collection
            MultiLineString multiLS1 = CreateMLS();
            //create another geometry collection that is null
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            MultiLineString multiLS2 = gf.CreateMultiLineString(null);
            //create another geometry collection that is different
            MultiLineString multiLS3 = CreateMLS1();
            //create another geometry collection that is different
            MultiLineString multiLS4 = closedMLS();
            //create another geometry collection that is the same as the first
            MultiLineString multiLS5 = CreateMLS();

            Assertion.AssertEquals("Equals-1: ", true , multiLS1.Equals(multiLS5));
            Assertion.AssertEquals("Equals-2: ", false, multiLS1.Equals(multiLS2));
            Assertion.AssertEquals("Equals-3: ", false, multiLS1.Equals(multiLS3));
            Assertion.AssertEquals("Equals-4: ", false, multiLS1.Equals(multiLS4));
        }
コード例 #21
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_Envelope()
        {
            //create a new collection
            MultiLineString multiLS = CreateMLS();

            //put the envelope into a geometry
            Geometry env = multiLS.GetEnvelope() as Geometry;

            //make sure there is something in the envelope
            Assertion.AssertEquals("Envelope-1: ", false, env.IsEmpty());

            Coordinates coords = env.GetCoordinates();
            //check the first set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-2: ", 0.0, coords[0].X);
            Assertion.AssertEquals("Envelope-3: ", 5.0, coords[0].Y);

            //check the second set of coordinates (maxX, minY)
            Assertion.AssertEquals("Envelope-4: ", 18.0, coords[1].X);
            Assertion.AssertEquals("Envelope-5: ", 5.0, coords[1].Y);

            //check the third set of coordinates (maxX, maxY)
            Assertion.AssertEquals("Envelope-6: ", 18.0, coords[2].X);
            Assertion.AssertEquals("Envelope-7: ", 23.0, coords[2].Y);

            //check the forth set of coordinates (minX, maxY)
            Assertion.AssertEquals("Envelope-8: ", 0.0, coords[3].X);
            Assertion.AssertEquals("Envelope-9: ", 23.0, coords[3].Y);

            //check the fifth set of coordinates (minX, minY)
            Assertion.AssertEquals("Envelope-10: ", 0.0, coords[4].X);
            Assertion.AssertEquals("Envelope-11: ", 5.0, coords[4].Y);

            //create a null collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            //put the envelope into a geometry
            env = multiLS.GetEnvelope() as Geometry;

            //make sure there is something in the envelope
            Assertion.AssertEquals("Envelope-12: ", true, env.IsEmpty());
        }
コード例 #22
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        private MultiLineString CreateMLS1()
        {
            Coordinates coords = new Coordinates();
            Coordinate coord = new Coordinate();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LineString lineString = gf.CreateLineString(coords);
            LineString[] ls = new LineString[10];
            int c = 0;
            for(int i = 10; i > 0; i--)
            {
                for(int j = i; j < i+10; j++)
                {
                    coord = new Coordinate();
                    coord.X = (double)j;
                    coord.Y = (double)j+5;
                    coords.Add(coord);
                }
                lineString = gf.CreateLineString(coords);
                ls[c] = lineString;
                c++;
            }
            MultiLineString multiLS = gf.CreateMultiLineString(ls);

            return multiLS;
        }
コード例 #23
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_NumPoints()
        {
            //create a geomerty collection
            MultiLineString multiLS = CreateMLS();

            Assertion.AssertEquals("NumPoints-1: ", 100, multiLS.GetNumPoints());

            //now try it with a null geometry collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            Assertion.AssertEquals("NumPoints-2: ", 0, multiLS.GetNumPoints());

            //now try it with a different geometry collection
            multiLS = closedMLS();

            Assertion.AssertEquals("NumPoints-3: ", 30, multiLS.GetNumPoints());

            //now try it with a mixed geometry collection
            multiLS = nonSimpleMLS();

            Assertion.AssertEquals("NumPoints-4: ", 18, multiLS.GetNumPoints());
        }
コード例 #24
0
ファイル: GeometryDataReader.cs プロジェクト: vmoll/geotools
 /// <summary>
 /// Initializes a new instance of the IGeometryDataReader class.
 /// </summary>
 public GeometryDataReader(GeometryFactory geometryFactory, IDataReader reader)
 {
     _reader = reader;
     _geometryFactory = geometryFactory;
     _wkbReader = new GeometryWkbReader( geometryFactory );
 }
コード例 #25
0
ファイル: LinearRingTest.cs プロジェクト: vmoll/geotools
        private LinearRing ThrowsException()
        {
            Coordinates coords = new Coordinates();
            Coordinate coord ;//Coordinate(0, 0);

            coord = new Coordinate(10, 13);
            coords.Add(coord);
            coord = new Coordinate(11, 13);
            coords.Add(coord);
            coord = new Coordinate(12, 13);
            coords.Add(coord);
            coord = new Coordinate(13, 14);
            coords.Add(coord);
            coord = new Coordinate(14, 15);
            coords.Add(coord);
            coord = new Coordinate(15, 16);
            coords.Add(coord);
            coord = new Coordinate(15, 17);
            coords.Add(coord);
            coord = new Coordinate(15, 18);
            coords.Add(coord);
            coord = new Coordinate(14, 19);
            coords.Add(coord);
            coord = new Coordinate(13, 20);
            coords.Add(coord);
            coord = new Coordinate(12, 21);
            coords.Add(coord);
            coord = new Coordinate(11, 21);
            coords.Add(coord);
            coord = new Coordinate(10, 21);
            coords.Add(coord);
            coord = new Coordinate(9, 20);
            coords.Add(coord);
            coord = new Coordinate(8, 19);
            coords.Add(coord);
            coord = new Coordinate(7, 18);
            coords.Add(coord);
            coord = new Coordinate(7, 17);
            coords.Add(coord);
            coord = new Coordinate(7, 16);
            coords.Add(coord);
            coord = new Coordinate(8, 15);
            coords.Add(coord);
            coord = new Coordinate(9, 14);
            coords.Add(coord);

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LinearRing lr = gf.CreateLinearRing(coords);
            return lr;
        }
コード例 #26
0
ファイル: LinearRingTest.cs プロジェクト: vmoll/geotools
        /// <summary>
        /// Method to create a NonSimple LinearRing for testing purposes
        /// </summary>
        /// <returns>A LinearRing</returns>
        private LinearRing NonSimple()
        {
            Coordinates coords = new Coordinates();
            Coordinate coord = new Coordinate(0, 0);

            coord = new Coordinate(2, 2);
            coords.Add(coord);
            coord = new Coordinate(3, 1);
            coords.Add(coord);
            coord = new Coordinate(4, 2);
            coords.Add(coord);
            coord = new Coordinate(5, 3);
            coords.Add(coord);
            coord = new Coordinate(6, 4);
            coords.Add(coord);
            coord = new Coordinate(7, 5);
            coords.Add(coord);
            coord = new Coordinate(7, 6);
            coords.Add(coord);
            coord = new Coordinate(7, 7);
            coords.Add(coord);
            coord = new Coordinate(7, 8);
            coords.Add(coord);
            coord = new Coordinate(7, 9);
            coords.Add(coord);
            coord = new Coordinate(6, 10);
            coords.Add(coord);
            coord = new Coordinate(5, 11);
            coords.Add(coord);
            coord = new Coordinate(6, 12);
            coords.Add(coord);
            coord = new Coordinate(7, 13);
            coords.Add(coord);
            coord = new Coordinate(8, 14);
            coords.Add(coord);
            coord = new Coordinate(9, 13);
            coords.Add(coord);
            coord = new Coordinate(10, 12);
            coords.Add(coord);
            coord = new Coordinate(10, 11);
            coords.Add(coord);
            coord = new Coordinate(10, 10);
            coords.Add(coord);
            coord = new Coordinate(10, 9);
            coords.Add(coord);
            coord = new Coordinate(9, 8);
            coords.Add(coord);
            coord = new Coordinate(8, 7);
            coords.Add(coord);
            coord = new Coordinate(7, 7);
            coords.Add(coord);
            coord = new Coordinate(6, 7);
            coords.Add(coord);
            coord = new Coordinate(5, 8);
            coords.Add(coord);
            coord = new Coordinate(4, 8);
            coords.Add(coord);
            coord = new Coordinate(3, 7);
            coords.Add(coord);
            coord = new Coordinate(2, 6);
            coords.Add(coord);
            coord = new Coordinate(1, 5);
            coords.Add(coord);
            coord = new Coordinate(2, 4);
            coords.Add(coord);
            coord = new Coordinate(1, 3);
            coords.Add(coord);
            coord = new Coordinate(2, 2);
            coords.Add(coord);

            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LinearRing lr = gf.CreateLinearRing(coords);
            return lr;
        }
コード例 #27
0
		///<summary>
		///  Returns this Geometrys bounding box.
		///</summary>
		///<remarks>If this Geometry  is the empty geometry, returns an empty Point.
		///  If the Geometry  is a point, returns a non-empty Point. Otherwise, returns a  Polygon whose 
		///  points are (minx, miny), (maxx, miny), (maxx,  maxy), (minx, maxy), (minx, miny).</remarks>
		///<returns>
		///Returns an empty Point (for empty Geometrys), a  Point (for Points) or a Polygon  
		///(in all other cases)
		///</returns>
		public virtual Geometry GetEnvelope() 
		{
			return GeometryFactory.ToGeometry( GetEnvelopeInternal(), _precisionModel, _SRID );
		} // public Geometry Envelope()
コード例 #28
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_IsEmpty()
        {
            //create a geomerty collection
            MultiLineString multiLS = CreateMLS();

            Assertion.AssertEquals("IsEmpty-1: ", false, multiLS.IsEmpty());

            //now try it with a null geometry collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            Assertion.AssertEquals("IsEmpty-2: ", true, multiLS.IsEmpty());

            //now try it with a different geometry collection
            multiLS = CreateMLS1();

            Assertion.AssertEquals("IsEmpty-3: ", false, multiLS.IsEmpty());

            //now try it again
            multiLS = closedMLS();

            Assertion.AssertEquals("IsEmpty-4: ", false, multiLS.IsEmpty());
        }
コード例 #29
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_IsSimple()
        {
            //create a geomerty collection
            MultiLineString multiLS = CreateMLS();

            Assertion.AssertEquals("IsSimple-1: ", false, multiLS.IsSimple());

            //now try it with a null geometry collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            Assertion.AssertEquals("IsSimple-2: ", true, multiLS.IsSimple());

            //now try it with a different geometry collection
            multiLS = CreateMLS1();

            //TODO: This is really slow!!!!!!!!!  Why?
            //Assertion.AssertEquals("IsSimple-3: ", false, multiLS.IsSimple());

            //now try it with a mixed geometry collection
            multiLS = nonSimpleMLS();

            Assertion.AssertEquals("IsSimple-4: ", false, multiLS.IsSimple());

            //now try it with a closed geometry collection
            multiLS = closedMLS();

            //TODO: Uncomment when IsSimple is working.
            Assertion.AssertEquals("IsSimple-5: ", true, multiLS.IsSimple());
        }
コード例 #30
0
		///<summary>
		///Initializes aGeometry.  
		///</summary>
		///<param name="precisionModel">The specification of the grid of allowable points  for this Geometry.</param>
		///<param name="SRID">The ID of the Spatial Reference System used by this Geometry.</param>
		internal Geometry(PrecisionModel precisionModel, int SRID) 
		{
			this._precisionModel = precisionModel;
			this._SRID = SRID;
			this._geometryFactory = new GeometryFactory(_precisionModel, _SRID);
		}
コード例 #31
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        private MultiLineString closedMLS()
        {
            Coordinates coords = new Coordinates();
            Coordinate coord = new Coordinate();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LineString lineString = gf.CreateLineString(coords);
            LineString[] ls = new LineString[2];

            coord = new Coordinate(10, 13);
            coords.Add(coord);
            coord = new Coordinate(11, 13);
            coords.Add(coord);
            coord = new Coordinate(12, 13);
            coords.Add(coord);
            coord = new Coordinate(13, 14);
            coords.Add(coord);
            coord = new Coordinate(14, 15);
            coords.Add(coord);
            coord = new Coordinate(15, 16);
            coords.Add(coord);
            coord = new Coordinate(15, 17);
            coords.Add(coord);
            coord = new Coordinate(15, 18);
            coords.Add(coord);
            coord = new Coordinate(14, 19);
            coords.Add(coord);
            coord = new Coordinate(13, 20);
            coords.Add(coord);
            coord = new Coordinate(12, 21);
            coords.Add(coord);
            coord = new Coordinate(11, 21);
            coords.Add(coord);
            coord = new Coordinate(10, 21);
            coords.Add(coord);
            coord = new Coordinate(9, 20);
            coords.Add(coord);
            coord = new Coordinate(8, 19);
            coords.Add(coord);
            coord = new Coordinate(7, 18);
            coords.Add(coord);
            coord = new Coordinate(7, 17);
            coords.Add(coord);
            coord = new Coordinate(7, 16);
            coords.Add(coord);
            coord = new Coordinate(8, 15);
            coords.Add(coord);
            coord = new Coordinate(9, 14);
            coords.Add(coord);
            coord = new Coordinate(10, 13);
            coords.Add(coord);
            ls[0] = gf.CreateLineString(coords);

            coords = new Coordinates();
            coord = new Coordinate(5, 1);
            coords.Add(coord);
            coord = new Coordinate(6, 2);
            coords.Add(coord);
            coord = new Coordinate(7, 3);
            coords.Add(coord);
            coord = new Coordinate(6, 4);
            coords.Add(coord);
            coord = new Coordinate(5, 5);
            coords.Add(coord);
            coord = new Coordinate(4, 4);
            coords.Add(coord);
            coord = new Coordinate(3, 3);
            coords.Add(coord);
            coord = new Coordinate(4, 2);
            coords.Add(coord);
            coord = new Coordinate(5, 1);
            coords.Add(coord);
            ls[1] = gf.CreateLineString(coords);

            MultiLineString multiLS = gf.CreateMultiLineString(ls);

            return multiLS;
        }
コード例 #32
0
		/// <summary>
		/// Initializes a new instance of the MaximalEdgeRing class.
		/// A MaximalEdgeRing is a ring of edges which may contain nodes of degree > 2.
		/// A MaximalEdgeRing may represent two different spatial entities:
		/// &lt;ul&gt;
		/// &lt;li&gt;a single polygon possibly containing inversions (if the ring is oriented CW)
		/// &lt;li&gt;a single hole possibly containing exversions (if the ring is oriented CCW)
		/// &lt;/ul&gt;
		/// If the MaximalEdgeRing represents a polygon,
		/// the interior of the polygon is strongly connected.
		/// These are the form of rings used to define polygons under some spatial data models.
		/// However, under the OGC SFS model, {@link MinimalEdgeRings} are required.
		/// A MaximalEdgeRing can be converted to a list of MinimalEdgeRings using the
		/// { BuildMinimalRings() } method.
		/// </summary>
		public MaximalEdgeRing( DirectedEdge start, GeometryFactory geometryFactory, CGAlgorithms cga ) : base( start, geometryFactory, cga )
		{
		}
コード例 #33
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        private MultiLineString nonSimpleMLS()
        {
            Coordinates coords = new Coordinates();
            Coordinate coord = new Coordinate();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            LineString lineString = gf.CreateLineString(coords);
            LineString[] ls = new LineString[1];

            coord = new Coordinate(2, 2);
            coords.Add(coord);
            coord = new Coordinate(3, 3);
            coords.Add(coord);
            coord = new Coordinate(4, 4);
            coords.Add(coord);
            coord = new Coordinate(5, 5);
            coords.Add(coord);
            coord = new Coordinate(6, 6);
            coords.Add(coord);
            coord = new Coordinate(7, 7);
            coords.Add(coord);
            coord = new Coordinate(8, 8);
            coords.Add(coord);
            coord = new Coordinate(9, 7);
            coords.Add(coord);
            coord = new Coordinate(10, 6);
            coords.Add(coord);
            coord = new Coordinate(10, 5);
            coords.Add(coord);
            coord = new Coordinate(9, 4);
            coords.Add(coord);
            coord = new Coordinate(8, 3);
            coords.Add(coord);
            coord = new Coordinate(7, 4);
            coords.Add(coord);
            coord = new Coordinate(7, 5);
            coords.Add(coord);
            coord = new Coordinate(6, 6);
            coords.Add(coord);
            coord = new Coordinate(5, 7);
            coords.Add(coord);
            coord = new Coordinate(4, 8);
            coords.Add(coord);
            coord = new Coordinate(3, 9);
            coords.Add(coord);
            ls[0] = gf.CreateLineString(coords);

            MultiLineString multiLS = gf.CreateMultiLineString(ls);

            return multiLS;
        }
コード例 #34
0
ファイル: MultiLineStringTest.cs プロジェクト: vmoll/geotools
        public void test_Coordinates()
        {
            //create a geomerty collection
            MultiLineString multiLS = CreateMLS();

            //this geometry conatins 10 sets of coordinates
            Assertion.AssertEquals("Coordinates-1: ", 100, multiLS.GetCoordinates().Count);

            //now try it with a null geometry collection
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            multiLS = gf.CreateMultiLineString(null);

            Assertion.AssertEquals("Coordinates-2: ", 0, multiLS.GetCoordinates().Count);

            //now try it with a different geometry collection
            multiLS = CreateMLS1();

            //1000 sets of coordinates
            Assertion.AssertEquals("Cordinates-3: ", 1000, multiLS.GetCoordinates().Count);
        }