Пример #1
0
        private void ComputeMinDistanceLinesPoints(IGeometryList lines,
                                                   IGeometryList points, DistanceLocation[] locGeom)
        {
            int nLines  = lines.Count;
            int nPoints = points.Count;

            for (int i = 0; i < nLines; i++)
            {
                LineString line = (LineString)lines[i];
                if (line == null)
                {
                    continue;
                }

                for (int j = 0; j < nPoints; j++)
                {
                    Point pt = (Point)points[j];
                    ComputeMinDistance(line, pt, locGeom);
                    if (minDistance <= terminateDistance)
                    {
                        return;
                    }
                }
            }
        }
Пример #2
0
        private void ComputeMinDistancePoints(IGeometryList points0,
                                              IGeometryList points1, DistanceLocation[] locGeom)
        {
            int nCount0 = points0.Count;
            int nCount1 = points1.Count;

            for (int i = 0; i < nCount0; i++)
            {
                Point pt0 = (Point)points0[i];
                for (int j = 0; j < nCount1; j++)
                {
                    Point  pt1  = (Point)points1[j];
                    double dist = pt0.Coordinate.Distance(pt1.Coordinate);
                    if (dist < minDistance)
                    {
                        minDistance = dist;
                        // this is wrong - need to determine closest points on both segments!!!
                        locGeom[0] = new DistanceLocation(pt0, 0, pt0.Coordinate);
                        locGeom[1] = new DistanceLocation(pt1, 0, pt1.Coordinate);
                    }
                    if (minDistance <= terminateDistance)
                    {
                        return;
                    }
                }
            }
        }
Пример #3
0
        private void ComputeContainmentDistance()
        {
            IGeometryList polys0 = PolygonExtracter.GetPolygons(geom[0]);
            IGeometryList polys1 = PolygonExtracter.GetPolygons(geom[1]);

            DistanceLocation[] locPtPoly = new DistanceLocation[2];
            // test if either geometry is wholely inside the other
            if (polys1.Count > 0)
            {
                IList insideLocs0 =
                    ConnectedElementLocationFilter.GetLocations(geom[0]);
                ComputeInside(insideLocs0, polys1, locPtPoly);
                if (minDistance <= terminateDistance)
                {
                    minDistanceLocation[0] = locPtPoly[0];
                    minDistanceLocation[1] = locPtPoly[1];
                    return;
                }
            }

            if (polys0.Count > 0)
            {
                IList insideLocs1 =
                    ConnectedElementLocationFilter.GetLocations(geom[1]);
                ComputeInside(insideLocs1, polys0, locPtPoly);
                if (minDistance <= terminateDistance)
                {
                    // flip locations, since we are testing geom 1 VS geom 0
                    minDistanceLocation[0] = locPtPoly[1];
                    minDistanceLocation[1] = locPtPoly[0];
                    return;
                }
            }
        }
Пример #4
0
		/// <returns> true if the coord is located in the interior or boundary of
		/// a geometry in the list.
		/// </returns>
		private bool IsCovered(Coordinate coord, IGeometryList geomList)
		{
			for (IGeometryEnumerator it = geomList.GetEnumerator(); it.MoveNext(); )
			{
				Geometry geom = it.Current;
				int loc = ptLocator.Locate(coord, geom);
				if (loc != LocationType.Exterior)
					return true;
			}
			return false;
		}
Пример #5
0
		private Geometry ComputeGeometry(IGeometryList resultPointList, 
            IGeometryList resultLineList, IGeometryList resultPolyList)
		{
			GeometryList geomList = new GeometryList();
			// element geometries of the result are always in the order P,L,A
			geomList.AddRange(resultPointList);
			geomList.AddRange(resultLineList);
			geomList.AddRange(resultPolyList);

			// build the most specific geometry possible
			return geomFact.BuildGeometry(geomList);
		}
Пример #6
0
		private void ComputeOverlay(OverlayType opCode)
		{
			// copy points from input Geometries.
			// This ensures that any Point geometries
			// in the input are considered for inclusion in the result set
			CopyPoints(0);
			CopyPoints(1);
			
			// node the input Geometries
			arg[0].ComputeSelfNodes(li, false);
			arg[1].ComputeSelfNodes(li, false);
			
			// compute intersections between edges of the two input geometries
			arg[0].ComputeEdgeIntersections(arg[1], li, true);
			
			EdgeCollection baseSplitEdges = new EdgeCollection();
			arg[0].ComputeSplitEdges(baseSplitEdges);
			arg[1].ComputeSplitEdges(baseSplitEdges);
//			EdgeCollection splitEdges = baseSplitEdges;
			// Add the noded edges to this result graph
			InsertUniqueEdges(baseSplitEdges);
			
			ComputeLabelsFromDepths();
			ReplaceCollapsedEdges();
			
			graph.AddEdges(edgeList.Edges);
			ComputeLabelling();

            LabelIncompleteNodes();
			
			// The ordering of building the result Geometries is important.
			// Areas must be built before lines, which must be built before points.
			// This is so that lines which are covered by areas are not included
			// explicitly, and similarly for points.
			FindResultAreaEdges(opCode);
			CancelDuplicateResultEdges();
			PolygonBuilder polyBuilder = new PolygonBuilder(geomFact);
			polyBuilder.Add(graph);
			resultPolyList = polyBuilder.Build();
			
			LineBuilder lineBuilder = new LineBuilder(this, geomFact, ptLocator);
			resultLineList = lineBuilder.Build(opCode);
			
			PointBuilder pointBuilder = new PointBuilder(this, geomFact);
			resultPointList = pointBuilder.Build(opCode);
			
			// gather the results from all calculations into a single Geometry for the result set
			resultGeom = ComputeGeometry(resultPointList, resultLineList, resultPolyList);
		}
Пример #7
0
        private void ComputeSegmentIntersection(Geometry geom)
        {
            // check segment intersection
            // get all lines from geom (e.g. if it's a multi-ring polygon)
            IGeometryList lines = LineStringExtracter.GetLines(geom);

            SegmentIntersectionTester si = new SegmentIntersectionTester();
            bool hasIntersection         = si.HasIntersectionWithLineStrings(
                rectSeq, lines);

            if (hasIntersection)
            {
                m_bIntersects = true;
                return;
            }
        }
        public bool HasIntersectionWithLineStrings(ICoordinateList seq,
                                                   IGeometryList lines)
        {
            int nGeometries = lines.Count;

            for (int i = 0; i < nGeometries; i++)
            {
                HasIntersection(seq, lines[i].Coordinates);

                if (m_bHasIntersection)
                {
                    break;
                }
            }

            return(m_bHasIntersection);
        }
Пример #9
0
        private void ComputeLineDistance()
        {
            DistanceLocation[] locGeom = new DistanceLocation[2];

            /// <summary> Geometries are not wholely inside, so compute Distance from lines and points
            /// of one to lines and points of the other
            /// </summary>
            IGeometryList lines0 = LineStringExtracter.GetLines(geom[0]);
            IGeometryList lines1 = LineStringExtracter.GetLines(geom[1]);

            IGeometryList pts0 = PointExtracter.GetPoints(geom[0]);
            IGeometryList pts1 = PointExtracter.GetPoints(geom[1]);

            // bail whenever minDistance goes to zero, since it can't get any less
            ComputeMinDistanceLines(lines0, lines1, locGeom);
            UpdateMinDistance(locGeom, false);
            if (minDistance <= terminateDistance)
            {
                return;
            }

            locGeom[0] = null;
            locGeom[1] = null;
            ComputeMinDistanceLinesPoints(lines0, pts1, locGeom);
            UpdateMinDistance(locGeom, false);
            if (minDistance <= terminateDistance)
            {
                return;
            }

            locGeom[0] = null;
            locGeom[1] = null;
            ComputeMinDistanceLinesPoints(lines1, pts0, locGeom);
            UpdateMinDistance(locGeom, true);
            if (minDistance <= terminateDistance)
            {
                return;
            }

            locGeom[0] = null;
            locGeom[1] = null;
            ComputeMinDistancePoints(pts0, pts1, locGeom);
            UpdateMinDistance(locGeom, false);
        }
Пример #10
0
        /// <summary>
        /// Add a collection of geometries to be polygonized. May be called multiple times.
        /// Any dimension of Geometry may be added; the constituent linework
        /// will be extracted and used
        /// </summary>
        /// <param name="geometryList">
        /// A list of Geometry instances with linework to be polygonized.
        /// </param>
        public void Add(IGeometryList geometryList)
        {
            if (geometryList == null)
            {
                throw new ArgumentNullException("geometryList");
            }

            int nCount = geometryList.Count;

            for (int i = 0; i < nCount; i++)
            {
                Add(geometryList[i]);
            }

//			for (IEnumerator i = geomList.GetEnumerator(); i.MoveNext(); )
//			{
//				Geometry geometry = (Geometry) i.Current;
//				Add(geometry);
//			}
        }
Пример #11
0
        private void ComputeMinDistanceLines(IGeometryList lines0,
                                             IGeometryList lines1, DistanceLocation[] locGeom)
        {
            int nCount0 = lines0.Count;
            int nCount1 = lines1.Count;

            for (int i = 0; i < nCount0; i++)
            {
                LineString line0 = (LineString)lines0[i];
                for (int j = 0; j < nCount1; j++)
                {
                    LineString line1 = (LineString)lines1[j];
                    ComputeMinDistance(line0, line1, locGeom);
                    if (minDistance <= terminateDistance)
                    {
                        return;
                    }
                }
            }
        }
Пример #12
0
        private void ComputeInside(IList locs,
                                   IGeometryList polys, DistanceLocation[] locPtPoly)
        {
            int nLocs  = locs.Count;
            int nPolys = polys.Count;

            for (int i = 0; i < nLocs; i++)
            {
                DistanceLocation loc = (DistanceLocation)locs[i];
                for (int j = 0; j < nPolys; j++)
                {
                    Polygon poly = (Polygon)polys[j];
                    ComputeInside(loc, poly, locPtPoly);
                    if (minDistance <= terminateDistance)
                    {
                        return;
                    }
                }
            }
        }
Пример #13
0
        public OverlayOp(Geometry g0, Geometry g1) : base(g0, g1)
		{
            if (g0 == null)
            {
                throw new ArgumentNullException("g0");
            }
            if (g1 == null)
            {
                throw new ArgumentNullException("g1");
            }

            ptLocator       = new PointLocator();
            edgeList        = new EdgeList();
            resultPolyList  = new GeometryList();
            resultLineList  = new GeometryList();
            resultPointList = new GeometryList();

			graph = new PlanarGraph(new OverlayNodeFactory());
			// Use factory of primary geometry.
			// Note that this does NOT handle mixed-precision arguments
			// where the second arg has greater precision than the first.
			geomFact = g0.Factory;
		}
Пример #14
0
 /// <summary>
 /// Constructs a PointExtracter filter with a list in which to store
 /// <see cref="Point"/> instances found.
 /// </summary>
 public PointExtracter(IGeometryList pts)
 {
     this.pts = pts;
 }
Пример #15
0
 /// <summary>
 /// Constructs a PolygonExtracter filter with a list in which to store
 /// <see cref="Polygon"/> class instances found.
 /// </summary>
 public PolygonExtracter(IGeometryList comps)
 {
     this.comps = comps;
 }
Пример #16
0
 /// <summary>
 /// Constructs a LineStringExtracter filter with a list in which to
 /// store <see cref="LineString"/> class instances found.
 /// </summary>
 public LineStringExtracter(IGeometryList lines)
 {
     this.lines = lines;
 }