Example #1
0
		/// <summary>
		/// Tests if MultiPoint is simple.
		/// </summary>
		/// <param name="mp">Geometry to test.  Must be of type MultiPoint.</param>
		/// <returns>Returns True if geometry is simple.</returns>
		/// <remarks>A MultiPoint is simple if and only if it has no repeated points.</remarks>
		public bool IsSimple( MultiPoint mp )
		{
			if ( mp.IsEmpty() )
			{
				return true;
			}
			SortedList points = new SortedList();
			for ( int i = 0; i < mp.GetNumGeometries(); i++ ) 
			{
				Point pt = (Point) mp.GetGeometryN( i );
				Coordinate p = pt.GetCoordinate();
				if ( points.Contains( p ) )
				{
					return false;
				}
				points.Add( p, p );
			} //for ( int i = 0; i < mp.NumGeometries; i++ )
			return true;
		} // public bool IsSimple( MultiPoint mp )
		/// <summary>
		/// Converts a MultiPoint to &lt;MultiPoint Text&gt; format, then
		/// Appends it to the writer.
		/// </summary>
		/// <param name="multiPoint">The MultiPoint to process.</param>
		/// <param name="writer">The output stream writer to Append to.</param>
		protected void AppendMultiPointText(MultiPoint multiPoint,  TextWriter writer)
		{
			if (multiPoint.IsEmpty()) 
			{
				//writer.Write("EMPTY");
			}
			else 
			{
				for (int i = 0; i < multiPoint.GetNumGeometries(); i++) 
				{
					AppendPointTaggedText( multiPoint.GetCoordinate(i), writer, _precisionModel);
				}
			}
		}
		/// <summary>
		/// Converts a MultiPoint to &lt;MultiPoint Tagged Text&gt;
		/// format, then Appends it to the writer.
		/// </summary>
		/// <param name="multipoint">The MultiPoint to process.</param>
		/// <param name="writer">The output writer to Append to.</param>
		protected void AppendMultiPointTaggedText(MultiPoint multipoint, TextWriter writer)
		{
			//writer.Write("<g>");
			AppendMultiPointText(multipoint,  writer);
			//writer.Write("</g>");
		}
		/// <summary>
		/// Converts a MultiPoint to &lt;MultiPoint Text&gt; format, then
		/// Appends it to the writer.
		/// </summary>
		/// <param name="multiPoint">The MultiPoint to process.</param>
		/// <param name="level"></param>
		/// <param name="writer">The output stream writer to Append to.</param>
		protected void AppendMultiPointText(MultiPoint multiPoint, int level, StringWriter writer)
		{
			
			if  ( multiPoint.IsEmpty() ) 
			{
				writer.Write("EMPTY");
			}
			else 
			{
				writer.Write("(");
				for (int i = 0; i < multiPoint.GetNumGeometries(); i++) 
				{
					if (i > 0) 
					{
						writer.Write(", ");
					}
						AppendCoordinate( multiPoint.GetCoordinates()[i], writer,
						multiPoint.PrecisionModel );
				}
				writer.Write(")");
			}
				
		}
		/// <summary>
		/// Converts a MultiPoint to &lt;MultiPoint Tagged Text&gt;
		/// format, then Appends it to the writer.
		/// </summary>
		/// <param name="multipoint">The MultiPoint to process.</param>
		/// <param name="level"></param>
		/// <param name="writer">The output writer to Append to.</param>
		protected void AppendMultiPointTaggedText(MultiPoint multipoint, int level, StringWriter writer)
		{
			
			writer.Write("MULTIPOINT ");
			AppendMultiPointText(multipoint, level, writer);
			
		}
		/// <summary>
		/// Writes a multipoint.
		/// </summary>
		/// <param name="mp">The multipoint to be written.</param>
		private void WriteMultiPoint(MultiPoint mp, byte format)
		{
			//Get the number of points in this multipoint.
			int numPoints = mp.GetNumPoints();

			//Write the number of points.
			_bWriter.Write(numPoints);

			//Loop on the number of points.
			for(int i = 0; i < numPoints; i++)
			{
				//write the multipoint header
				_bWriter.Write(format);
				_bWriter.Write(4);

				_bWriter.Write(numPoints);

				//Write each point.
				WritePoint((Point)mp[i]);
			}
		}