コード例 #1
0
		/// <summary>
		/// Applies the flip filter.
		/// </summary>
		/// <remarks>
		/// The following calculation is performed on the Y coordinate.
		/// <code>
		/// coord.Y = (_max - coord.Y) + _min;
		/// </code>
		/// </remarks>
		/// <param name="geometry">The geometry object to apply the filter to.</param>
		public void Filter(Geometry geometry)
		{
			/*if (geometry is Polygon)
			{
				Polygon polygon = (Polygon)geometry;
				Filter(polygon.Shell);
				foreach(LinearRing linearring in polygon.Holes)
				{
					Filter(linearring);
				}
			}
			else*/ if (geometry is LinearRing || geometry is LineString || geometry is Point)
			{
				Coordinates coords = geometry.GetCoordinates();
				for (int i=0; i < coords.Count; i++)
				{
					coords[i].Y = (_max - coords[i].Y) + _min;
				}
			}
			/*else if (geometry is GeometryCollection)
			{
				Filter(geometry);
			}
			else
			{
				throw new NotSupportedException(geometry.GetType().Name);
			}
			geometry.GeometryChanged();*/
		}
コード例 #2
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() );
		
		}
コード例 #3
0
ファイル: Shapefile.cs プロジェクト: xuchuansheng/GenXSource
		/// <summary>
		/// Given a geomtry object, returns the equilivent shape file type.
		/// </summary>
		/// <param name="geom">A Geometry object.</param>
		/// <returns>The equilivent for the geometry object.</returns>
		public static ShapeType GetShapeType(Geometry geom) 
		{
			if (geom is Point) 
			{
				return ShapeType.Point;
			}

			if (geom is Polygon) 
			{
				return ShapeType.Polygon;
			}

			if (geom is MultiPolygon) 
			{
				return ShapeType.Polygon;
			}

			if (geom is LineString) 
			{
				return ShapeType.Arc;
			}

			if (geom is MultiLineString) 
			{
				return ShapeType.Arc;
			}
			return ShapeType.Undefined;
		}
コード例 #4
0
		public void Filter(Geometry geom)
		{
			if (geom is Point
				|| geom is LineString
				|| geom is Polygon )
				_pts.Add( geom.GetCoordinate() );
		}
コード例 #5
0
		} // public static int Locate(Coordinate p, Geometry geom)

		private static bool ContainsPoint(Coordinate p, Geometry geom)
		{
			if( geom is Polygon )
			{
				return ContainsPointInPolygon( p, (Polygon)geom );
			}
			else if( geom is GeometryCollection )
			{
				GeometryCollection gc = geom as GeometryCollection;
				foreach( Geometry g2 in gc )
				{
					if ( g2 != geom )			// TODO:  what is this line trying to do???
					{
						if ( ContainsPoint( p, g2 ) )
						{
							return true;
						}
					}
				} // foreach( Geometry g2 in geom )


			} // else if( geom is GeometryCollection )

			return false;

		} // private static bool ContainsPoint(Coordinate p, Geometry geom)
コード例 #6
0
		/// <summary>
		/// Constructs an Operation object.
		/// </summary>
		/// <param name="g0"></param>
		public GeometryGraphOperation(Geometry g0) 
		{
			SetComputationPrecision( g0.PrecisionModel );

			_arg = new GeometryGraph[1];
			_arg[0] = new GeometryGraph(0, g0);;
		}
コード例 #7
0
		/// <summary>
		///		Determines the topological relationship (location) of a single point
		///		to a Geometry.  It handles both single-element and multi-element Geometries.  
		///		The algorithm for multi-part Geometries is more complex, since it has 
		///		to take into account the boundaryDetermination rule.
		/// </summary>
		/// <param name="p"></param>
		/// <param name="geom"></param>
		/// <returns>Returns the location of the point relative to the input Geometry.</returns>
		public int Locate( Coordinate p, Geometry geom )
		{
			if ( geom.IsEmpty() ) return Location.Exterior;

			if ( geom is LineString )
			{
				return Locate( p, (LineString) geom );
			}
			if ( geom is LinearRing )
			{
				return Locate( p, (LinearRing) geom );
			}
			else if ( geom is Polygon ) 
			{
				return Locate( p, (Polygon) geom );
			}

			_isIn = false;
			_numBoundaries = 0;
			ComputeLocation( p, geom );
			if ( GeometryGraph.IsInBoundary( _numBoundaries ) )
			{
				return Location.Boundary;
			}
			if ( _numBoundaries > 0 || _isIn)
			{
				return Location.Interior;
			}
			return Location.Exterior;
		} // public int Locate( Coordinate p, Geometry geom )
コード例 #8
0
ファイル: Test.cs プロジェクト: carlhuth/GenXSource
        /// <summary>
        /// Calls the methods (property get) on the geometries that are properties of the geometry.
        /// </summary>
        /// <param name="a">The A geometry object.</param>
        /// <param name="arg">A string containing the name of the geometry. "A" or "B"</param>
        /// <param name="testToRun">The property to call.</param>
        private void RunGeometryPropertyTest(Geometry a, Geometry b, string arg, string testToRun)
        {
            Geotools.Geometries.Geometry c = a;
            if (arg == "B")
            {
                arg = "B";
                c   = b;
            }

            switch (testToRun)
            {
            case "numpoints":
                int numberOfPoints = 0;
                // set the name of the operation for viewing in the textbox...
                this._testResult.Operation = arg + ".NumPoints";
                // call the property function...
                numberOfPoints = c.GetNumPoints();
                // store the string version of the value returned for comparison later...
                this._testResult.PropertyTestResult = numberOfPoints.ToString();
                // test for pass or failure...
                TestForPassFailPropertyTestResult();
                break;

            case "dimension":
                int dimension = 0;
                // set the name of the operation for viewing in the textbox...
                this._testResult.Operation = arg + ".Dimension";
                dimension = c.GetDimension();
                // store the string version of the value returned for comparison later...
                this._testResult.PropertyTestResult = dimension.ToString();
                // test for pass or failure...
                TestForPassFailPropertyTestResult();
                break;
            }
        }
コード例 #9
0
ファイル: BufferOp.cs プロジェクト: xuchuansheng/GenXSource
		public static Geometry GetBuffer(Geometry g, double distance)
		{
			
			BufferOp gBuf = new BufferOp(g);
			Geometry geomBuf = gBuf.GetResultGeometry(distance);
			return geomBuf;
		}
コード例 #10
0
		/// <summary>
		/// Constructs an Operation object.
		/// </summary>
		/// <param name="g0"></param>
		/// <param name="g1"></param>
		public GeometryGraphOperation(Geometry g0, Geometry g1) 
		{
			SetComputationPrecision( g0.PrecisionModel );

			_arg = new GeometryGraph[2];
			_arg[0] = new GeometryGraph(0, g0);
			_arg[1] = new GeometryGraph(1, g1);
		}
コード例 #11
0
		/// <summary>
		/// Converts the geometry to svg and writes the svg to a file.
		/// </summary>
		/// <param name="filename">The name of the svg file.</param>
		/// <param name="pm">The precision model for the geometries</param>
		/// <param name="a">The geometry to be written to svg.</param>
		public void CreateSVG(string filename, Geotools.Geometries.PrecisionModel pm, Geometry a)
		{
			GeometrySVGWriter svgWriter = new GeometrySVGWriter(pm);
			StreamWriter sw = new StreamWriter(filename);
			double minx, miny, maxx, maxy;
			a.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:ltgray;stroke:blue;stroke-width:1;fill-opacity:0.2");
			sw.WriteLine("</svg>");
			sw.Close();
		}
コード例 #12
0
		/// <summary>
		///		Locate is the main location function.  It handles both single-element
		///		and multi-element Geometries.  The algorithm for multi-element Geometries
		///		is more complex, since it has to take into account the boundaryDetermination rule
		/// </summary>
		/// <param name="p"></param>
		/// <param name="geom"></param>
		/// <returns></returns>
		public static int Locate(Coordinate p, Geometry geom)
		{

			if ( geom.IsEmpty() ) return Location.Exterior;

			if ( ContainsPoint( p, geom ) )
			{
				return Location.Interior;
			}
			return Location.Exterior;
		} // public static int Locate(Coordinate p, Geometry geom)
コード例 #13
0
		/// <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;
		}
コード例 #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>
		/// The binary write method.
		/// </summary>
		/// <param name="geometry">The geometry to be written.</param>
		/// <param name="bWriter">The binary writer to be used.</param>
		/// <param name="format">The format employed (big/little endian).</param>
		public BinaryWriter Write(Geometry geometry, BinaryWriter bWriter, byte format)
		{
			//Create the binary writer.
			_bWriter = bWriter;

			//Write the format.
			_bWriter.Write(format);

			//Write the type of this geometry
			WriteType(geometry);

			//Write the geometry
			WriteGeometry(geometry, format);

			return _bWriter;
		}
コード例 #16
0
		public bool HasRepeatedPoint(Geometry g)
		{
			
			if ( g.IsEmpty() ) return false;
			if (g is Point)                   return false;
			else if (g is MultiPoint)         return false;
				// LineString also handles LinearRings
			else if (g is LineString)         
			{
				return HasRepeatedPoint(((LineString) g).GetCoordinates() );
			}
			else if (g is Polygon)            return HasRepeatedPoint((Polygon) g);
			else if (g is GeometryCollection) return HasRepeatedPoint((GeometryCollection) g);
			else  throw new NotSupportedException(g.GetType().Name);
			
		}
コード例 #17
0
ファイル: Test.cs プロジェクト: carlhuth/GenXSource
        /// <summary>
        /// Runs the methods on the geometries that return a boolean property.
        /// </summary>
        /// <param name="aGeometry">the A Geometry object</param>
        /// <param name="bGeometry">The B geometry object</param>
        /// <param name="arg">A string containing the name (A or B) of the geometry to call the method on.</param>
        /// <param name="testToRun">The name of the test to run.</param>
        private void RunBooleanReturnPropertyFunction(Geometry aGeometry, Geometry bGeometry, string arg, string testToRun)
        {
            string argToRun = "A";

            Geotools.Geometries.Geometry c = aGeometry;
            if (arg == "B")
            {
                argToRun = "B";
                c        = bGeometry;
            }
            _timer.Start();
            switch (testToRun)
            {
            case "isempty":
                this._testResult.Operation       = argToRun + ".IsEmpty";
                this._testResult.PredicateResult = c.IsEmpty();
                this._testResult.SetPredicateResultString();
                TestForPassFailBooleanResult();
                break;

            case "issimple":
                // set the name of the operation in the TestResult...
                this._testResult.Operation = argToRun + ".IsSimple";
                // call the predicate on the geometry and store the result...
                this._testResult.PredicateResult = c.IsSimple();
                // set the string value of the predicate result for comparison...
                this._testResult.SetPredicateResultString();
                // test for pass or fail...
                TestForPassFailBooleanResult();
                break;

            case "isvalid":
                // set the name of the operation in the TestResult...
                this._testResult.Operation = argToRun + ".IsValid";
                // call the predicate on the geometry and store the result...
                this._testResult.PredicateResult = c.IsValid();
                // set the string value of the predicate result for comparison...
                this._testResult.SetPredicateResultString();
                // test for pass or fail...
                TestForPassFailBooleanResult();
                break;
            }
            // stop the timer...
            _timer.Stop();
            this._testResult.TestDuration = _timer.Seconds;
        }
コード例 #18
0
ファイル: ConvexHull.cs プロジェクト: xuchuansheng/GenXSource
		/// <summary>
		/// Gets the convex hull for the given geometry.
		/// </summary>
		/// <param name="geometry"></param>
		/// <returns></returns>
		public Geometry GetConvexHull(Geometry geometry) 
		{

			this._geometry = geometry;
			UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
			geometry.Apply(filter);
			Coordinates pts = filter.GetCoordinates();

			if (pts.Count == 0) 
			{
				return new GeometryCollection(new Geometry[]{},
					geometry.PrecisionModel, geometry.GetSRID());
			}
			if (pts.Count == 1) 
			{
				return new Point(pts[0], geometry.PrecisionModel, geometry.GetSRID());
			}
			if (pts.Count == 2) 
			{
				return new LineString(pts, geometry.PrecisionModel, geometry.GetSRID());
			}

			// sort points for Graham scan.
			Coordinates pspts;
			if (pts.Count > 10) 
			{
				//Probably should be somewhere between 50 and 100?
				Coordinates rpts = Reduce(pts);
				pspts = PreSort(rpts);
			}
			else 
			{
				pspts = PreSort(pts);
			}

			// Use Graham scan to find convex hull.
			Stack cHS = GrahamScan(pspts);

			// Convert stack to an array.
			Coordinates cH = ToCoordinateArray(cHS);

			// Convert array to linear ring.
			//awcreturn lineOrPolygon(cH);
			return LineOrPolygon(cH);

		}
コード例 #19
0
		/// <summary>
		/// Applies the projection to the coordinates.
		/// </summary>
		/// <param name="geometry">The geometry object to apply the filter to.</param>
		public void Filter(Geometry geometry)
		{
			/*if (geometry is Polygon)
			{
				Polygon polygon = (Polygon)geometry;
				Filter(polygon.Shell);
				foreach(LinearRing linearring in polygon.Holes)
				{
					Filter(linearring);
				}
			}*/
			if (geometry is LinearRing || geometry is LineString || geometry is Point)
			{	
				int sourceSRID = int.Parse(_coordinateTransform.SourceCS.AuthorityCode);
				int targetSRID = int.Parse(_coordinateTransform.TargetCS.AuthorityCode);
				MapProjection projection = (MapProjection)_coordinateTransform.MathTransform;

				Coordinates projectedCoordinates = new Coordinates();
				double x=0.0;
				double y=0.0;
				Coordinate coordinate;
				for(int i=0; i < geometry.GetCoordinates().Count; i++)
				{
					coordinate = geometry.GetCoordinates()[i];
					if (geometry.GetSRID() == sourceSRID)
					{
						projection.MetersToDegrees(coordinate.X, coordinate.Y, out x, out y);	
					}
					else if (geometry.GetSRID() == targetSRID)
					{
					
						projection.DegreesToMeters(coordinate.X, coordinate.Y, out x, out y);
					}
					coordinate.X = x;
					coordinate.Y = y;
				}
			}
			/*else
			{
				throw new NotSupportedException(geometry.GetType().Name);
			}*/
		}
コード例 #20
0
ファイル: BufferOp.cs プロジェクト: xuchuansheng/GenXSource
		public static Geometry Buffer(Geometry g, double distance, int quadrantSegments)
		{
			BufferOp gBuf = new BufferOp(g);
			Geometry geomBuf = gBuf.GetResultGeometry(distance, quadrantSegments);
			return geomBuf;
		}
コード例 #21
0
ファイル: BufferOp.cs プロジェクト: xuchuansheng/GenXSource
		private void ComputeBuffer(double distance, int quadrantSegments)
		{
			if (_makePrecise) 
			{
				double scale = GetArgGeometry(0).PrecisionModel.Scale;
				distance *= scale;
			}
			BufferEdgeBuilder bufEdgeBuilder = new BufferEdgeBuilder(_cga, _li, distance, _makePrecise, quadrantSegments);
			ArrayList bufferEdgeList = bufEdgeBuilder.GetEdges(GetArgGeometry(0));

			// DEBUGGING ONLY
			//WKTWriter wktWriter = new WKTWriter();
			//Debug.println("Rings: " + wktWriter.write(toLineStrings(bufferEdgeList.iterator())));

			ArrayList nodedEdges = this.NodeEdges(bufferEdgeList);
			//TESTING - node again to ensure edges are noded completely
			/*
			List nodedEdges2 = nodeEdges(nodedEdges);
			List nodedEdges3 = nodeEdges(nodedEdges2);
			List nodedEdges4 = nodeEdges(nodedEdges3);
			List nodedEdges5 = nodeEdges(nodedEdges4);
			List nodedEdges6 = nodeEdges(nodedEdges5);
		  */
			//for (Iterator i = nodedEdges.iterator(); i.hasNext(); ) 
			foreach(object obj in nodedEdges)
			{
				Edge e = (Edge) obj;
				InsertEdge(e);
			}
			ReplaceCollapsedEdges();

			// DEBUGGING ONLY
			//Debug.println("Noded: " + wktWriter.write(toLineStrings(edgeList.iterator())));

			_graph.AddEdges(_edgeList);

			ArrayList subgraphList = CreateSubgraphs();
			PolygonBuilder polyBuilder = new PolygonBuilder(_geomFact, _cga);
			BuildSubgraphs(subgraphList, polyBuilder);
			ArrayList resultPolyList = polyBuilder.GetPolygons();

			_resultGeom = ComputeGeometry(resultPolyList);
			//computeBufferLine(graph);
		}
コード例 #22
0
ファイル: GeometryDataReader.cs プロジェクト: vmoll/geotools
 public bool Read()
 {
     _geometry = null;
     bool result=  _reader.Read();
     if (result)
     {
         byte[] wkb = (byte[])_reader["wkbgeometry"];
         _geometry = _wkbReader.Create(wkb);
     }
     return result;
 }
コード例 #23
0
        private GeometryCollection CreateCollection4()
        {
            //this is used to prevent having to rewrite this code over & over

            //create a new coordinate
            Coordinate coordinate = new Coordinate();
            //create a new point
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coordinate);
            //create a new geometries array
            Geometry[] geom = new Geometry[10];
            int c = 0;
            //fill with points
            for(int i = 9; i < 19 ; i++)
            {
                //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                coordinate = new Coordinate();
                //make the x coordinate equal to the iterator
                coordinate.X = (double)i;
                //make the y coordinate equal to the iterator plus 10
                coordinate.Y = (double)i + 10;
                //create a new point to put in the geometry
                point = gf.CreatePoint(coordinate);
                //put the point in the geometies
                geom[c] = point;
                c++;
            }
            //put the geometries into a geometry collection
            GeometryCollection geoColl = gf.CreateGeometryCollection(geom);

            return geoColl;
        }
コード例 #24
0
        private GeometryCollection CreateCollection3()
        {
            //create a new geometries array
            Geometry[] geom = new Geometry[10];

            Coordinate coordinate = new Coordinate();
            Coordinates coords = new Coordinates();
            GeometryFactory gf = new GeometryFactory(_precMod, _sRID);
            Point point = gf.CreatePoint(coordinate);

            LineString lineString = gf.CreateLineString(coords);

            for(int c = 0; c < 5; c++)
            {
                for(int i = c; i < c+5; i++)
                {
                    //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                    coordinate = new Coordinate();
                    //make the x coordinate equal to the iterator
                    coordinate.X = (double)i;
                    //make the y coordinate equal to the iterator plus 10
                    coordinate.Y = (double)i + 10;
                    coords.Add(coordinate);
                }
                lineString = gf.CreateLineString(coords);
                geom[c] = lineString;
            }
            for(int i = 5; i < 10; i++)
            {
                //if this isn't here the coordinates for all the points are reset every time the coordinate is reset
                coordinate = new Coordinate();
                //make the x coordinate equal to the iterator
                coordinate.X = (double)i;
                //make the y coordinate equal to the iterator plus 10
                coordinate.Y = (double)i + 10;
                //create a new point to put in the geometry
                point = gf.CreatePoint(coordinate);
                //put the point in the geometies
                geom[i] = point;
            }
            //put the geometries into a geometry collection
            GeometryCollection geoColl = gf.CreateGeometryCollection(geom);

            return geoColl;
        }
コード例 #25
0
		/// <summary>
		/// Gets the length in bytes the Geometry will need when written as a shape file record.
		/// </summary>
		/// <param name="geometry">The Geometry object to use.</param>
		/// <returns>The length in bytes the Geometry will use when represented as a shape file record.</returns>
		public abstract  int GetLength(Geometry geometry); //length in 16bit words
コード例 #26
0
		/// <summary>
		/// Writes to the given stream the equilivent shape file record given a Geometry object.
		/// </summary>
		/// <param name="geometry">The geometry object to write.</param>
		/// <param name="file">The stream to write to.</param>
		/// <param name="geometryFactory">The geometry factory to use.</param>
		public abstract  void Write(Geometry geometry, System.IO.BinaryWriter file,  GeometryFactory geometryFactory);
コード例 #27
0
		} // public int Locate( Coordinate p, Geometry geom )

		private void ComputeLocation(Coordinate p, Geometry geom)
		{
			if ( geom is LineString )
			{
				UpdateLocationInfo( Locate( p, (LineString) geom ) );
			}
			if ( geom is LinearRing ) 
			{
				UpdateLocationInfo( Locate( p, (LinearRing) geom ) );
			}
			else if ( geom is Polygon ) 
			{
				UpdateLocationInfo( Locate( p, (Polygon) geom ) );
			}
			else if ( geom is MultiLineString ) 
			{
				MultiLineString ml = (MultiLineString) geom;
				for ( int i = 0; i < ml.GetNumGeometries(); i++ ) 
				{
					LineString l = (LineString) ml.GetGeometryN( i );
					UpdateLocationInfo( Locate( p, l ) );
				} // for ( int i = 0; i < ml.NumGeometries; i++ )
			}
			else if ( geom is MultiPolygon ) 
			{
				MultiPolygon mpoly = (MultiPolygon) geom;
				for (int i = 0; i < mpoly.GetNumGeometries(); i++) 
				{
					Polygon poly = (Polygon) mpoly.GetGeometryN( i );
					UpdateLocationInfo( Locate( p, poly ) );
				} // for (int i = 0; i < mpoly.NumGeometries; i++)
			}
			else if ( geom is GeometryCollection ) 
			{
				GeometryCollection gc = geom as GeometryCollection;
				foreach( Geometry g2 in gc )
				{
					if ( g2 != geom )
					{
						ComputeLocation( p, g2 );
					}
				} // foreach( Geometry g2 in gc )
			} // else if ( geom is GeometryCollection )				
										 
		} // private void ComputeLocation(Coordinate p, Geometry geom)
コード例 #28
0
		public void Filter(Geometry geom)
		{
			if (geom is LineString) _lines.Add(geom);
		}
コード例 #29
0
		public static ArrayList GetLines(Geometry geom)
		{
			ArrayList lines = new ArrayList();
			geom.Apply(new LineExtracterFilter(lines));
			return lines;
		}
コード例 #30
0
		private int GetNumParts(Geometry geometry)
		{
			int numParts=1;
			if (geometry is MultiLineString)
			{
				numParts = ((MultiLineString)geometry).Count;
			}
			return numParts;
		}
コード例 #31
0
		/// <summary>
		/// Writes to the given stream the equilivent shape file record given a Geometry object.
		/// </summary>
		/// <param name="geometry">The geometry object to write.</param>
		/// <param name="file">The stream to write to.</param>
		/// <param name="geometryFactory">The geometry factory to use.</param>
		public override void Write(Geometry geometry, System.IO.BinaryWriter file, GeometryFactory geometryFactory)
		{
			MultiLineString multi = (MultiLineString) geometry;
			file.Write(int.Parse(Enum.Format(typeof(ShapeType),this.ShapeType,"d")));
        
			Envelope box = multi.GetEnvelopeInternal();
			file.Write(box.MinX);
			file.Write(box.MinY);
			file.Write(box.MaxX);
			file.Write(box.MaxY);
        
			int numParts = multi.GetNumGeometries();
			int numPoints = multi.GetNumPoints();
        
			file.Write(numParts);		
			file.Write(numPoints);
      
			//LineString[] lines = new LineString[numParts];
        
			// write the offsets
			int offset=0;
			for (int i = 0; i < numParts; i++)
			{
				Geometry g =  multi.GetGeometryN(i);
				file.Write( offset );
				offset = offset + g.GetNumPoints();
			}
        
			Coordinate	external;
			for (int part = 0; part < numParts; part++)
			{
				Coordinates points = multi.GetGeometryN(part).GetCoordinates();
				for (int i = 0; i < points.Count; i++)
				{
					external = geometryFactory.PrecisionModel.ToExternal(points[i]);
					file.Write(external.X);
					file.Write(external.Y);
				}
			}
		}
コード例 #32
0
		/// <summary>
		/// Gets the length in bytes the Geometry will need when written as a shape file record.
		/// </summary>
		/// <param name="geometry">The Geometry object to use.</param>
		/// <returns>The length in bytes the Geometry will use when represented as a shape file record.</returns>
		public override int GetLength(Geometry geometry)
		{
			int numParts=GetNumParts(geometry);
			return (22 + (2 * numParts) + geometry.GetNumPoints() * 8);
		}