Exemplo n.º 1
0
        /// <summary>
        /// Label an isolated node with its relationship to the target point.
        /// </summary>
        private void LabelIncompleteNode(GraphComponent n, int targetIndex)
        {
            var loc = _ptLocator.Locate(n.Coordinate, arg[targetIndex].Geometry);

            // MD - 2008-10-24 - experimental for now
            //int loc = arg[targetIndex].Locate(n.Coordinate);
            n.Label.SetLocation(targetIndex, loc);
        }
        public void TestPolygon()
        {
            var pointLocator = new PointLocator();
            var polygon      = reader.Read("POLYGON ((70 340, 430 50, 70 50, 70 340))");

            Assert.That(pointLocator.Locate(new Coordinate(420, 340), polygon), Is.EqualTo(Location.Exterior));
            Assert.That(pointLocator.Locate(new Coordinate(350, 50), polygon), Is.EqualTo(Location.Boundary));
            Assert.That(pointLocator.Locate(new Coordinate(410, 50), polygon), Is.EqualTo(Location.Boundary));
            Assert.That(pointLocator.Locate(new Coordinate(190, 150), polygon), Is.EqualTo(Location.Interior));
        }
Exemplo n.º 3
0
        public void testPointLocator()
        {
            var pointLocator = new PointLocator();
            var polygon      = reader.Read("POLYGON ((70 340, 430 50, 70 50, 70 340))");

            Assert.AreEqual(Location.Exterior, pointLocator.Locate(new Coordinate(420, 340), polygon));
            Assert.AreEqual(Location.Boundary, pointLocator.Locate(new Coordinate(350, 50), polygon));
            Assert.AreEqual(Location.Boundary, pointLocator.Locate(new Coordinate(410, 50), polygon));
            Assert.AreEqual(Location.Interior, pointLocator.Locate(new Coordinate(190, 150), polygon));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Label an isolated edge of a graph with its relationship to the target point.
 /// If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
 /// If the target has dim 0, the edge must be in the exterior.
 /// </summary>
 /// <param name="e"></param>
 /// <param name="targetIndex"></param>
 /// <param name="target"></param>
 private void LabelIsolatedEdge(Edge e, int targetIndex, IGeometry target)
 {
     // this won't work for GeometryCollections with both dim 2 and 1 geoms
     if (target.Dimension > 0)
     {
         // since edge is not in boundary, may not need the full generality of PointLocator?
         // Possibly should use ptInArea locator instead?  We probably know here
         // that the edge does not touch the bdy of the target Geometry
         Locations loc = ptLocator.Locate(e.Coordinate, target);
         e.Label.SetAllLocations(targetIndex, loc);
     }
     else e.Label.SetAllLocations(targetIndex, Locations.Exterior);            
 }
Exemplo n.º 5
0
        /// <summary>
        /// Label an isolated node with its relationship to the target geometry.
        /// </summary>
        private void  LabelIsolatedLine(Edge e, int targetIndex)
        {
            int loc = ptLocator.Locate(e.Coordinate,
                                       op.GetArgGeometry(targetIndex));

            e.Label.SetLocation(targetIndex, loc);
        }
Exemplo n.º 6
0
 private void ComputeInside(Coordinate pt, Polygon poly)
 {
     if (Location.Exterior != _ptLocator.Locate(pt, poly))
     {
         _minDistance = 0.0;
     }
 }
        public IGeometry Union()
        {
            PointLocator locater = new PointLocator();
            // use a set to eliminate duplicates, as required for union
            var exteriorCoords = new HashSet <Coordinate>();

            foreach (IPoint point in PointExtracter.GetPoints(_pointGeom))
            {
                Coordinate coord = point.Coordinate;
                Location   loc   = locater.Locate(coord, _otherGeom);

                if (loc == Location.Exterior)
                {
                    exteriorCoords.Add(coord);
                }
            }

            // if no points are in exterior, return the other geom
            if (exteriorCoords.Count == 0)
            {
                return(_otherGeom);
            }

            // make a puntal geometry of appropriate size
            var exteriorCoordsArray = new Coordinate[exteriorCoords.Count];

            exteriorCoords.CopyTo(exteriorCoordsArray, 0);
            Array.Sort(exteriorCoordsArray);
            ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoordsArray);
            IGeometry           ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords);

            // add point component to the other geometry
            return(GeometryCombiner.Combine(ptComp, _otherGeom));
        }
Exemplo n.º 8
0
        public void testPointLocatorLinearRingLineString()
        {
            var pointLocator = new PointLocator();
            var gc           = reader.Read("GEOMETRYCOLLECTION( LINESTRING(0 0, 10 10), LINEARRING(10 10, 10 20, 20 10, 10 10))");

            Assert.AreEqual(Location.Boundary, pointLocator.Locate(new Coordinate(10, 10), gc));
        }
        public Location Locate(Coordinate p)
        {
            // TODO: optimize this with a segment index
            var locator = new PointLocator();

            return(locator.Locate(p, _inputGeom));
        }
        private void RunPtLocator(Location expected, Coordinate pt, string wkt)
        {
            var geom         = reader.Read(wkt);
            var pointLocator = new PointLocator();
            var loc          = pointLocator.Locate(pt, geom);

            Assert.AreEqual(expected, loc);
        }
Exemplo n.º 11
0
        }         // private void LabelIsolatedEdges( int thisIndex, int targetIndex )

        /// <summary>
        /// Label an isolated edge of a graph with its relationship to the target geometry.
        /// If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
        /// If the target has dim 0, the edge must be in the exterior.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="targetIndex"></param>
        /// <param name="target"></param>
        private void LabelIsolatedEdge(Edge e, int targetIndex, Geometry target)
        {
            // this won't work for GeometryCollections with both dim 2 and 1 geoms
            if (target.GetDimension() > 0)
            {
                // since edge is not in boundary, may not need the full generality of PointLocator?
                // Possibly should use ptInArea locator instead?  We probably know here
                // that the edge does not touch the bdy of the target Geometry
                int loc = _ptLocator.Locate(e.GetCoordinate(), target);
                e.Label.SetAllLocations(targetIndex, loc);
            }             // if ( target.Dimension > 0)
            else
            {
                e.Label.SetAllLocations(targetIndex, Location.Exterior);
            }
            //Trace.WriteLine( e.Label.ToString() );
        }         // private void LabelIsolatedEdge(Edge e, int targetIndex, Geometry target)
Exemplo n.º 12
0
        private void RunPtLocator(Location expected, Coordinate pt, String wkt)
        {
            IGeometry    geom         = reader.Read(wkt);
            PointLocator pointLocator = new PointLocator();
            Location     loc          = pointLocator.Locate(pt, geom);

            Assert.AreEqual(expected, loc);
        }
Exemplo n.º 13
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;
            }
        }
Exemplo n.º 14
0
 private void ComputeContainmentDistance(GeometryLocation ptLoc,
     Polygon poly,
     GeometryLocation[] locPtPoly)
 {
     var pt = ptLoc.Coordinate;
     // if pt is not in exterior, distance to geom is 0
     if (Location.Exterior != _ptLocator.Locate(pt, poly))
     {
         _minDistance = 0.0;
         locPtPoly[0] = ptLoc;
         locPtPoly[1] = new GeometryLocation(poly, pt);
     }
 }
Exemplo n.º 15
0
 // MD - experimental for now
 /// <summary>
 /// Determines the <see cref="Location"/> of the given <see cref="Coordinate"/> in this geometry.
 /// </summary>
 /// <param name="pt">The point to test</param>
 /// <returns>
 /// The location of the point in the geometry
 /// </returns>
 public Location Locate(Coordinate pt)
 {
     if (_parentGeom is IPolygonal && _parentGeom.NumGeometries > 50)
     {
         // lazily init point locator
         if (_areaPtLocator == null)
         {
             _areaPtLocator = new IndexedPointInAreaLocator(_parentGeom);
         }
         return(_areaPtLocator.Locate(pt));
     }
     return(_ptLocator.Locate(pt, _parentGeom));
 }
Exemplo n.º 16
0
 // MD - experimental for now
 ///<summary>
 /// Determines the <see cref="Location"/> of the given <see cref="Coordinate"/> in this geometry.
 ///</summary>
 /// <param name="pt">The point to test</param>
 /// <returns>
 /// The location of the point in the geometry
 /// </returns>
 public Location Locate(Coordinate pt)
 {
     if (_parentGeom is IPolygonal && _parentGeom.NumGeometries > 50)
     {
         // lazily init point locator
         if (_areaPtLocator == null)
         {
             _areaPtLocator = new NetTopologySuite.Algorithm.Locate.IndexedPointInAreaLocator(_parentGeom);
         }
         return _areaPtLocator.Locate(pt);
     }
     return _ptLocator.Locate(pt, _parentGeom);
 }
Exemplo n.º 17
0
        private void ComputeInside(DistanceLocation ptLoc, Polygon poly,
                                   DistanceLocation[] locPtPoly)
        {
            Coordinate pt = ptLoc.Coordinate;

            if (LocationType.Exterior != ptLocator.Locate(pt, poly))
            {
                minDistance  = 0.0;
                locPtPoly[0] = ptLoc;
                DistanceLocation locPoly = new DistanceLocation(poly, pt);
                locPtPoly[1] = locPoly;
                return;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ptLoc"></param>
        /// <param name="poly"></param>
        /// <param name="locPtPoly"></param>
        private void ComputeInside(GeometryLocation ptLoc, IGeometry poly, GeometryLocation[] locPtPoly)
        {
            Coordinate pt = ptLoc.Coordinate;

            if (LocationType.Exterior == _ptLocator.Locate(pt, poly))
            {
                return;
            }
            _minDistance = 0.0;
            locPtPoly[0] = ptLoc;
            GeometryLocation locPoly = new GeometryLocation(poly, pt);

            locPtPoly[1] = locPoly;
            return;
        }
Exemplo n.º 19
0
        public Location GetLocation(Coordinate pt)
        {
            if (IsWithinToleranceOfBoundary(pt))
            {
                return(Location.Boundary);
            }

            /*
             * double dist = linework.distance(point);
             *
             * // if point is close to boundary, it is considered to be on the boundary
             * if (dist < tolerance)
             * return Location.BOUNDARY;
             */

            // now we know point must be clearly inside or outside geometry, so return actual location value
            return(_ptLocator.Locate(pt, _g));
        }
Exemplo n.º 20
0
        public IGeometry Union()
        {
            PointLocator locater = new PointLocator();

            // use a set to eliminate duplicates, as required for union
#if Goletas
            HashSet <ICoordinate> exteriorCoords = new HashSet <ICoordinate>();
#else
            TreeSet exteriorCoords = new TreeSet();
#endif

            foreach (IPoint point in PointExtracter.GetPoints(_pointGeom))
            {
                ICoordinate coord = point.Coordinate;
                Locations   loc   = locater.Locate(coord, _otherGeom);

                if (loc == Locations.Exterior)
                {
                    exteriorCoords.Add(coord);
                }
            }

            // if no points are in exterior, return the other geom
            if (exteriorCoords.Count == 0)
            {
                return(_otherGeom);
            }

            // make a puntal geometry of appropriate size
            IGeometry           ptComp = null;
            ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoords.ToArray());
            ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords);

            // add point component to the other geometry
            return(GeometryCombiner.Combine(ptComp, _otherGeom));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Label an isolated node with its relationship to the target point.
        /// </summary>
        private void LabelIncompleteNode(Node n, int targetIndex)
        {
            LocationType loc = _ptLocator.Locate(n.Coordinate, Arg[targetIndex].Geometry);

            n.Label.SetLocation(targetIndex, loc);
        }
Exemplo n.º 22
0
        }         // private void LabelIncompleteNodes()

        /// <summary>
        /// Label an isolated node with its relationship to the target geometry.
        /// </summary>
        /// <param name="n"></param>
        /// <param name="targetIndex"></param>
        private void LabelIncompleteNode(Node n, int targetIndex)
        {
            int loc = _ptLocator.Locate(n.GetCoordinate(), _arg[targetIndex].Geometry);

            n.Label.SetLocation(targetIndex, loc);
        }         // private void LabelIncompleteNode( Node n, int targetIndex )
Exemplo n.º 23
0
        /// <summary>
        /// Label an isolated node with its relationship to the target point.
        /// </summary>
        private void LabelIncompleteNode(GraphComponent n, int targetIndex)
        {
            var loc = ptLocator.Locate(n.Coordinate, arg[targetIndex].Geometry);

            n.Label.SetLocation(targetIndex, loc);
        }