예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="line0"></param>
 /// <param name="line1"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistance(ILineString line0, ILineString line1, GeometryLocation[] locGeom)
 {
     if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > minDistance)
     {
         return;
     }
     ICoordinate[] coord0 = line0.Coordinates;
     ICoordinate[] coord1 = line1.Coordinates;
     // brute force approach!
     for (int i = 0; i < coord0.Length - 1; i++)
     {
         for (int j = 0; j < coord1.Length - 1; j++)
         {
             double dist = CGAlgorithms.DistanceLineLine(
                 coord0[i], coord0[i + 1],
                 coord1[j], coord1[j + 1]);
             if (dist < minDistance)
             {
                 minDistance = dist;
                 LineSegment   seg0      = new LineSegment(coord0[i], coord0[i + 1]);
                 LineSegment   seg1      = new LineSegment(coord1[j], coord1[j + 1]);
                 ICoordinate[] closestPt = seg0.ClosestPoints(seg1);
                 locGeom[0] = new GeometryLocation(line0, i, closestPt[0]);
                 locGeom[1] = new GeometryLocation(line1, j, closestPt[1]);
             }
             if (minDistance <= terminateDistance)
             {
                 return;
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        private void ComputeContainmentDistance()
        {
            IList polys0 = PolygonExtracter.GetPolygons(geom[0]);
            IList polys1 = PolygonExtracter.GetPolygons(geom[1]);

            GeometryLocation[] locPtPoly = new GeometryLocation[2];
            // test if either point 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;
                }
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <param name="pt"></param>
        /// <param name="locGeom"></param>
        private void ComputeMinDistance(ILineString line, IPoint pt, GeometryLocation[] locGeom)
        {
            if (line.EnvelopeInternal.Distance(pt.EnvelopeInternal) > minDistance)
            {
                return;
            }
            ICoordinate[] coord0 = line.Coordinates;
            ICoordinate   coord  = pt.Coordinate;

            // brute force approach!
            for (int i = 0; i < coord0.Length - 1; i++)
            {
                double dist = CGAlgorithms.DistancePointLine(coord, coord0[i], coord0[i + 1]);
                if (dist < minDistance)
                {
                    minDistance = dist;
                    LineSegment seg             = new LineSegment(coord0[i], coord0[i + 1]);
                    ICoordinate segClosestPoint = seg.ClosestPoint(coord);
                    locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
                    locGeom[1] = new GeometryLocation(pt, 0, coord);
                }
                if (minDistance <= terminateDistance)
                {
                    return;
                }
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ptLoc"></param>
        /// <param name="poly"></param>
        /// <param name="locPtPoly"></param>
        private void ComputeInside(GeometryLocation ptLoc, IPolygon poly, GeometryLocation[] locPtPoly)
        {
            ICoordinate pt = ptLoc.Coordinate;

            if (Locations.Exterior != ptLocator.Locate(pt, poly))
            {
                minDistance  = 0.0;
                locPtPoly[0] = ptLoc;
                GeometryLocation locPoly = new GeometryLocation(poly, pt);
                locPtPoly[1] = locPoly;
                return;
            }
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="locs"></param>
 /// <param name="polys"></param>
 /// <param name="locPtPoly"></param>
 private void ComputeInside(IList locs, IList polys, GeometryLocation[] locPtPoly)
 {
     for (int i = 0; i < locs.Count; i++)
     {
         GeometryLocation loc = (GeometryLocation)locs[i];
         for (int j = 0; j < polys.Count; j++)
         {
             IPolygon poly = (IPolygon)polys[j];
             ComputeInside(loc, poly, locPtPoly);
             if (minDistance <= terminateDistance)
             {
                 return;
             }
         }
     }
 }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        private void ComputeLineDistance()
        {
            GeometryLocation[] locGeom = new GeometryLocation[2];

            /*
             * Geometries are not wholely inside, so compute distance from lines and points
             * of one to lines and points of the other
             */
            IList lines0 = LinearComponentExtracter.GetLines(geom[0]);
            IList lines1 = LinearComponentExtracter.GetLines(geom[1]);

            IList pts0 = PointExtracter.GetPoints(geom[0]);
            IList 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);
        }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="points0"></param>
 /// <param name="points1"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistancePoints(IList points0, IList points1, GeometryLocation[] locGeom)
 {
     for (int i = 0; i < points0.Count; i++)
     {
         IPoint pt0 = (IPoint)points0[i];
         for (int j = 0; j < points1.Count; j++)
         {
             IPoint pt1  = (IPoint)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 GeometryLocation(pt0, 0, pt0.Coordinate);
                 locGeom[1] = new GeometryLocation(pt1, 0, pt1.Coordinate);
             }
             if (minDistance <= terminateDistance)
             {
                 return;
             }
         }
     }
 }
예제 #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="locGeom"></param>
 /// <param name="flip"></param>
 private void UpdateMinDistance(GeometryLocation[] locGeom, bool flip)
 {
     // if not set then don't update
     if (locGeom[0] == null)
         return;
     if (flip)
     {
         minDistanceLocation[0] = locGeom[1];
         minDistanceLocation[1] = locGeom[0];
     }
     else
     {
         minDistanceLocation[0] = locGeom[0];
         minDistanceLocation[1] = locGeom[1];
     }
 }
예제 #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="locs"></param>
 /// <param name="polys"></param>
 /// <param name="locPtPoly"></param>
 private void ComputeInside(IList locs, IList polys, GeometryLocation[] locPtPoly)
 {
     for (int i = 0; i < locs.Count; i++)
     {
         GeometryLocation loc = (GeometryLocation)locs[i];
         for (int j = 0; j < polys.Count; j++)
         {
             IPolygon poly = (IPolygon) polys[j];
             ComputeInside(loc, poly, locPtPoly);
             if (minDistance <= terminateDistance)
                 return;
         }
     }
 }
예제 #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lines"></param>
 /// <param name="points"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistanceLinesPoints(IList lines, IList points, GeometryLocation[] locGeom)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         ILineString line = (ILineString) lines[i];
         for (int j = 0; j < points.Count; j++)
         {
             IPoint pt = (IPoint) points[j];
             ComputeMinDistance(line, pt, locGeom);
             if (minDistance <= terminateDistance) return;
         }
     }
 }
예제 #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lines0"></param>
 /// <param name="lines1"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistanceLines(IList lines0, IList lines1, GeometryLocation[] locGeom)
 {
     for (int i = 0; i < lines0.Count; i++)
     {
         ILineString line0 = (ILineString) lines0[i];
         for (int j = 0; j < lines1.Count; j++)
         {
             ILineString line1 = (ILineString) lines1[j];
             ComputeMinDistance(line0, line1, locGeom);
             if (minDistance <= terminateDistance) return;
         }
     }
 }
예제 #12
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="line"></param>
 /// <param name="pt"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistance(ILineString line, IPoint pt, GeometryLocation[] locGeom)
 {
     if (line.EnvelopeInternal.Distance(pt.EnvelopeInternal) > minDistance) return;
     ICoordinate[] coord0 = line.Coordinates;
     ICoordinate coord = pt.Coordinate;
     // brute force approach!
     for (int i = 0; i < coord0.Length - 1; i++)
     {
         double dist = CGAlgorithms.DistancePointLine(coord, coord0[i], coord0[i + 1]);
         if (dist < minDistance)
         {
             minDistance = dist;
             LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]);
             ICoordinate segClosestPoint = seg.ClosestPoint(coord);
             locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
             locGeom[1] = new GeometryLocation(pt, 0, coord);
         }
         if (minDistance <= terminateDistance)
             return;
     }
 }
예제 #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="line0"></param>
 /// <param name="line1"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistance(ILineString line0, ILineString line1, GeometryLocation[] locGeom)
 {
     if (line0.EnvelopeInternal.Distance(line1.EnvelopeInternal) > minDistance)
         return;
     ICoordinate[] coord0 = line0.Coordinates;
     ICoordinate[] coord1 = line1.Coordinates;
     // brute force approach!
     for (int i = 0; i < coord0.Length - 1; i++)
     {
         for (int j = 0; j < coord1.Length - 1; j++)
         {
             double dist = CGAlgorithms.DistanceLineLine(
                                             coord0[i], coord0[i + 1],
                                             coord1[j], coord1[j + 1]);
             if (dist < minDistance)
             {
                 minDistance = dist;
                 LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]);
                 LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]);
                 ICoordinate[] closestPt = seg0.ClosestPoints(seg1);
                 locGeom[0] = new GeometryLocation(line0, i, closestPt[0]);
                 locGeom[1] = new GeometryLocation(line1, j, closestPt[1]);
             }
             if (minDistance <= terminateDistance) return;
         }
     }
 }
예제 #14
0
        /// <summary>
        /// 
        /// </summary>
        private void ComputeLineDistance()
        {
            GeometryLocation[] locGeom = new GeometryLocation[2];

            /*
             * Geometries are not wholely inside, so compute distance from lines and points
             * of one to lines and points of the other
             */
            IList lines0 = LinearComponentExtracter.GetLines(geom[0]);
            IList lines1 = LinearComponentExtracter.GetLines(geom[1]);

            IList pts0 = PointExtracter.GetPoints(geom[0]);
            IList 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);
        }
예제 #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ptLoc"></param>
 /// <param name="poly"></param>
 /// <param name="locPtPoly"></param>
 private void ComputeInside(GeometryLocation ptLoc, IPolygon poly, GeometryLocation[] locPtPoly)
 {
     ICoordinate pt = ptLoc.Coordinate;
     if (Locations.Exterior != ptLocator.Locate(pt, poly))
     {
         minDistance = 0.0;
         locPtPoly[0] = ptLoc;
         GeometryLocation locPoly = new GeometryLocation(poly, pt);
         locPtPoly[1] = locPoly;
         return;
     }
 }
예제 #16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="points0"></param>
 /// <param name="points1"></param>
 /// <param name="locGeom"></param>
 private void ComputeMinDistancePoints(IList points0, IList points1, GeometryLocation[] locGeom)
 {
     for (int i = 0; i < points0.Count; i++)
     {
         IPoint pt0 = (IPoint) points0[i];
         for (int j = 0; j < points1.Count; j++)
         {
             IPoint pt1 = (IPoint) 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 GeometryLocation(pt0, 0, pt0.Coordinate);
                 locGeom[1] = new GeometryLocation(pt1, 0, pt1.Coordinate);
             }
             if (minDistance <= terminateDistance) return;
         }
     }
 }
예제 #17
0
        /// <summary>
        /// 
        /// </summary>
        private void ComputeContainmentDistance()
        {
            IList polys0 = PolygonExtracter.GetPolygons(geom[0]);
            IList polys1 = PolygonExtracter.GetPolygons(geom[1]);

            GeometryLocation[] locPtPoly = new GeometryLocation[2];
            // test if either point 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;
                }
            }
        }