예제 #1
0
		/// <summary>
		/// Converts a MultiPolygon to &lt;MultiPolygon Tagged
		/// Text&gt; format, then Appends it to the writer.
		/// </summary>
		/// <param name="multiPolygon">The MultiPolygon to process</param>
		/// <param name="writer">The output stream writer to Append to.</param>
		protected void AppendMultiPolygonTaggedText(MultiPolygon multiPolygon,  TextWriter writer)
		{
			AppendPath(writer);
			AppendMultiPolygonText(multiPolygon,  writer);
			AppendEndPath(writer);	
		}
예제 #2
0
		/// <summary>
		/// Converts a MultiPolygon to &lt;MultiPolygon Text&gt; format, then Appends to it to the writer.
		/// </summary>
		/// <param name="multiPolygon">The MultiPolygon to process.</param>
		/// <param name="writer">The output stream to Append to.</param>
		protected void AppendMultiPolygonText(MultiPolygon multiPolygon, TextWriter writer)
		{
			
			if (multiPolygon.IsEmpty()) 
			{
				writer.Write("EMPTY");
			}
			else 
			{
				//writer.Write("M");
				for (int i = 0; i < multiPolygon.GetNumGeometries(); i++) 
				{
					/*if (i > 0 && (i<multiPolygon.GetNumGeometries()-1) ) 
					{
						writer.Write(", ");
					}*/
					AppendPolygonText((Polygon) multiPolygon.GetGeometryN(i), writer);
				}
				//writer.Write("Z");
			}
			
			
		}
예제 #3
0
		/// <summary>
		/// Converts a MultiPolygon to &lt;MultiPolygon Tagged
		/// Text&gt; format, then Appends it to the writer.
		/// </summary>
		/// <param name="multiPolygon">The MultiPolygon to process</param>
		/// <param name="level"></param>
		/// <param name="writer">The output stream writer to Append to.</param>
		protected void AppendMultiPolygonTaggedText(MultiPolygon multiPolygon, int level, StringWriter writer)
		{
			
			writer.Write("MULTIPOLYGON ");
			AppendMultiPolygonText(multiPolygon, level, writer);
			
		}
예제 #4
0
		/// <summary>
		/// Converts a MultiPolygon to &lt;MultiPolygon Text&gt; format, then Appends to it to the writer.
		/// </summary>
		/// <param name="multiPolygon">The MultiPolygon to process.</param>
		/// <param name="level"></param>
		/// <param name="writer">The output stream to Append to.</param>
		protected void AppendMultiPolygonText(MultiPolygon multiPolygon, int level, StringWriter writer)
		{
			
			if ( multiPolygon.IsEmpty() ) 
			{
				writer.Write("EMPTY");
			}
			else 
			{
				int level2 = level;
				bool doIndent = false;
				writer.Write("(");
				for (int i = 0; i < multiPolygon.GetNumGeometries(); i++) 
				{
					if (i > 0) 
					{
						writer.Write(", ");
						level2 = level + 1;
						doIndent = true;
					}
					//AppendPolygonText((Polygon) multiPolygon.GetGeometryN(i), level2, doIndent, writer);
					AppendPolygonText((Polygon) multiPolygon.GetGeometryN(i), level2, doIndent, writer);
				}
				writer.Write(")");
			}
			
		}
예제 #5
0
		/// <summary>
		/// Writes a multipolygon.
		/// </summary>
		/// <param name="mp">The mulitpolygon to be written.</param>
		private void WriteMultiPolygon(MultiPolygon mp, byte format)
		{
			//Get the number of polygons in this multipolygon.
			int numpolygons = mp.GetNumGeometries();

			//Write the number of polygons.
			_bWriter.Write(numpolygons);

			//Loop on the number of polygons.
			for(int i = 0; i < numpolygons; i++)
			{
				//Write the polygon header
				_bWriter.Write(format);
				_bWriter.Write(6);

				//Write each polygon.
				WritePolygon((Polygon)mp[i], format);
			}
		}
예제 #6
0
		/// <summary>
		/// Converts the List to an array.
		/// </summary>
		/// <param name="multiPolygons">The List to convert.</param>
		/// <returns>The List in array format.</returns>
		public static MultiPolygon[] ToMultiPolygonArray(ArrayList multiPolygons) 
		{
			MultiPolygon[] multiPolygonArray = new MultiPolygon[multiPolygons.Count];
			return (MultiPolygon[]) multiPolygons.ToArray(typeof(MultiPolygon));
		}
예제 #7
0
 /// <summary>
 /// Converts the List to an array.
 /// </summary>
 /// <param name="multiPolygons">The List to convert.</param>
 /// <returns>The List in array format.</returns>
 public static MultiPolygon[] ToMultiPolygonArray(ArrayList multiPolygons)
 {
     MultiPolygon[] multiPolygonArray = new MultiPolygon[multiPolygons.Count];
     return((MultiPolygon[])multiPolygons.ToArray(typeof(MultiPolygon)));
 }
예제 #8
0
/*
		private void SLOWCheckHolesNotNested(Polygon p)
		{
			
			for (int i = 0; i < p.GetNumInteriorRing(); i++) 
			{
				LinearRing innerHole = p.GetInteriorRingN( i );
				Coordinates innerHolePts = innerHole.GetCoordinates();
				for (int j = 0; j < p.GetNumInteriorRing(); j++) 
				{
					// don't test hole against itself!
					if (i == j) continue;

					LinearRing searchHole = p.GetInteriorRingN( j );

					// if envelopes don't overlap, holes are not nested
					if (! innerHole.GetEnvelopeInternal().Overlaps(searchHole.GetEnvelopeInternal()))
						continue;

					Coordinates searchHolePts = searchHole.GetCoordinates();
					Coordinate innerholePt = FindPtNotNode(innerHolePts, searchHole, _arg[0]);
					//Assert.isTrue(innerholePt != null, "Unable to find a hole point not a node of the search hole");
					bool inside = _cga.IsPointInPolygon(innerholePt, searchHolePts);
					if ( inside ) 
					{
						_validErr = new TopologyValidationError(
							TopologyValidationError.NestedHoles,
							innerholePt);
						return;
					}
				}
			}
		}
*/		
		/// <summary>
		///  Test that no element polygon is wholly in the interior of another element polygon.
		/// </summary>
		/// <remarks>
		///  TODO: It handles the case that one polygon is nested inside a hole of another.
		///  
		///  Preconditions:
		///  <ul>
		///  <li>shells do not partially overlap</li>
		///  <li>shells do not touch along an edge</li>
		///  <li>no duplicate rings exist</li>
		///  </ul>
		///  This routine relies on the fact that while polygon shells may touch at one or
		///  more vertices, they cannot touch at ALL vertices.
		/// </remarks>
		/// <param name="mp"></param>
		/// <param name="graph"></param>
		private void CheckShellsNotNested(MultiPolygon mp, GeometryGraph graph)
		{
			
			for (int i = 0; i < mp.GetNumGeometries(); i++) 
			{
				Polygon p = (Polygon) mp.GetGeometryN(i);
				LinearRing shell = (LinearRing) p.GetExteriorRing();
				for (int j = 0; j < mp.GetNumGeometries(); j++) 
				{
					if (i == j) continue;
					Polygon p2 = (Polygon) mp.GetGeometryN(j);
					CheckShellNotNested(shell, p2, graph);
					if (_validErr != null) return;
				}
			}
			
		}
예제 #9
0
		private void CheckValid(MultiPolygon g)
		{
			GeometryGraph graph = new GeometryGraph(0, g);

			CheckConsistentArea(graph);
			if (_validErr != null) return;
			CheckNoSelfIntersectingRings(graph);
			if (_validErr != null) return;

			for (int i = 0; i < g.GetNumGeometries(); i++) 
			{
				Polygon p = (Polygon) g.GetGeometryN(i);
				CheckHolesInShell(p, graph);
				if (_validErr != null) return;
			}
			for (int i = 0; i < g.GetNumGeometries(); i++) 
			{
				Polygon p = (Polygon) g.GetGeometryN(i);
				CheckHolesNotNested(p, graph);
				if (_validErr != null) return;
			}
			CheckShellsNotNested(g, graph);
			if (_validErr != null) return;
			CheckConnectedInteriors(graph);
			
		}