Пример #1
0
        ///<summary>
        /// Returns true if the two Geometrys have the same class and if the data which they store
        /// internally are equal.
        ///</summary>
        ///<remarks>This method is stricter equality than equals. If this and the other
        /// Geometrys are composites and any children are not Geometrys, returns false.</remarks>
        ///<param name="obj">The Geometry with which to compare this Geometry.</param>
        ///<returns>
        /// Returns true if this and the other Geometry are of the same class and have equal
        /// internal data.
        ///</returns>
        public override bool Equals(object obj)
        {
            Geometry geometry = obj as Geometry;

            if (geometry != null)
            {
                if (!IsEquivalentClass(geometry))
                {
                    return(false);
                }
                LineString otherLS = geometry as LineString;
                if (otherLS != null)
                {
                    if (_points.Count != otherLS.GetCoordinates().Count)
                    {
                        return(false);
                    }
                    for (int i = 0; i < _points.Count; i++)
                    {
                        if (!_points[i].Equals(otherLS.GetCoordinateN(i)))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }             // if ( geometry != null )
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Returns a deep copy of a LinearRing.
        /// </summary>
        /// <returns>A deep copy LinearRing.</returns>
        public override Geometry Clone()
        {
            LineString ls = (LineString)base.Clone();
            LinearRing lr = _geometryFactory.CreateLinearRing(ls.GetCoordinates());

            return(lr);           // return the clone
        }
Пример #3
0
		} //private void UpdateLocationInfo( int loc )

		/// <summary>
		/// 
		/// </summary>
		/// <param name="p"></param>
		/// <param name="l"></param>
		/// <returns></returns>
		private int Locate( Coordinate p, LineString l )
		{
			Coordinates pt = l.GetCoordinates();
			if ( !l.IsClosed() ) 
			{
				if ( p.Equals( pt[0] ) || p.Equals( pt[pt.Count - 1] ) ) 
				{
					return Location.Boundary;
				}
			}
			if ( _cga.IsOnLine( p, pt ) )
			{
				return Location.Interior;
			}
			return Location.Exterior;
		} // private int Locate( Coordinate p, LineString l )
Пример #4
0
		private void ComputeMinDistance(LineString line0, LineString line1)
		{
			if (line0.GetEnvelopeInternal().Distance(line1.GetEnvelopeInternal())> _minDistance)
				return;
			Coordinates coord0 = line0.GetCoordinates();
			Coordinates coord1 = line1.GetCoordinates();
			// brute force approach!
			for (int i = 0; i < coord0.Count - 1; i++) 
			{
				for (int j = 0; j < coord1.Count - 1; j++) 
				{
					double dist = CGAlgorithms.DistanceLineLine(
						coord0[i], coord0[i + 1],
						coord1[j], coord1[j + 1] );
					UpdateMinDistance(dist);
				}
			}
		}
Пример #5
0
		/// <summary>
		/// Converts a LineString to &lt;LineString Text&gt; format, then
		/// Appends it to the writer.
		/// </summary>
		/// <param name="lineString">The LineString to process.</param>
		/// <param name="level"></param>
		/// <param name="doIndent"></param>
		/// <param name="writer">The output stream to Append to.</param>
		protected void AppendLineStringText(LineString lineString, int level, bool doIndent, StringWriter writer)
		{
			
			if ( lineString.IsEmpty() ) 
			{
				writer.Write("EMPTY");
			}
			else 
			{
				if (doIndent)
				{
					Indent(level, writer);
				}
				writer.Write("(");
				for (int i = 0; i < lineString.GetNumPoints(); i++) 
				{
					if (i > 0) 
					{
						writer.Write(", ");
						if (i % 10 == 0) Indent(level + 2, writer);
					}
					//AppendCoordinate(lineString.GetCoordinateN(i), writer, lineString.PrecisionModel);
					AppendCoordinate( lineString.GetCoordinates()[i], writer, lineString.PrecisionModel );
				}
				writer.Write(")");
			}
			
		}
Пример #6
0
        private void AddLineString(LineString line)
        {
            Coordinates coord = line.GetCoordinates();

            // add the edge for the LineString
            // line edges do not have locations for their left and right sides
            Edge e = new Edge( coord, new Label( _argIndex, Location.Interior ) );
            _lineEdgeMap[ line]=e ;
            InsertEdge( e );
            /**
             * Add the boundary points of the LineString, if any.
             * Even if the LineString is closed, add both points as if they were endpoints.
             * This allows for the case that the node already exists and is a boundary point.
             */
            if( coord.Count < 2 )
            {
                throw new InvalidOperationException("Found LineString with single point");
            }
            InsertBoundaryPoint( _argIndex, coord[0] );
            InsertBoundaryPoint( _argIndex, coord[coord.Count- 1] );
        }
Пример #7
0
		/// <summary>
		/// Writes a linestring.
		/// </summary>
		/// <param name="ls">The linestring to be written.</param>
		private void WriteLineString(LineString ls, byte format)
		{
			//Write the number of points in this linestring.
			_bWriter.Write( ls.GetNumPoints() );

			//Loop on each set of coordinates.
			foreach(Coordinate coord in ls.GetCoordinates() )
			{
				//Create a new point from the coordinates & write it.
				WritePoint(_geometryFactory.CreatePoint(coord));
			}
		}
Пример #8
0
		/// <summary>
		/// Add a LineString to the graph
		/// </summary>
		/// <param name="line"></param>
		private void AddLineString(LineString line)
		{
			if (_distance <= 0.0) return;
			Coordinates coords = Coordinates.RemoveRepeatedPoints(line.GetCoordinates());
		
			ArrayList lineList = _lineBuilder.GetLineBuffer(coords, _distance);
			AddEdges(lineList, Location.Exterior, Location.Interior);
			
		}