コード例 #1
0
        public IGeometry Union()
        {
            PointLocator locater = new PointLocator();
            // use a set to eliminate duplicates, as required for union
            var exteriorCoords = new OrderedSet<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
            ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoords.ToArray());
            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);
        }
コード例 #2
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);
 }
コード例 #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));
 }
コード例 #4
0
 ///<summary>
 /// Tests whether any representative of the target geometry intersects the test geometry.
 /// This is useful in A/A, A/L, A/P, L/P, and P/P cases.
 ///</summary>
 /// <param name="testGeom">The test geometry</param>
 /// <returns>true if any component intersects the areal test geometry</returns>
 public bool IsAnyTargetComponentInTest(IGeometry testGeom)
 {
     var locator = new PointLocator();
     foreach (Coordinate representativePoint in RepresentativePoints)
     {
         if (locator.Intersects(representativePoint, testGeom))
             return true;
     }
     return false;
 }
コード例 #5
0
        //private PointLocator _ptLocator;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="op"></param>
        /// <param name="geometryFactory"></param>
        /// <param name="ptLocator"></param>
        public PointBuilder(OverlayOp op, IGeometryFactory geometryFactory, PointLocator ptLocator)
        {
            _op = op;
            _geometryFactory = geometryFactory;
            //_ptLocator = ptLocator;
        }
コード例 #6
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));
 }
コード例 #7
0
 public PointBuilder(OverlayOp op, IGeometryFactory geometryFactory, PointLocator ptLocator = null)
     : this(op,geometryFactory)
 {
 }
コード例 #8
0
 ///<summary>
 /// Tests whether any representative point of the test Geometry intersects
 /// the target geometry.
 ///</summary>
 /// <remarks>
 /// Only handles test geometries which are Puntal (dimension 0)
 /// </remarks>
 /// <param name="testGeom">A Puntal geometry to test</param>
 /// <returns>true if any point of the argument intersects the prepared geometry</returns>
 protected bool IsAnyTestPointInTarget(IGeometry testGeom)
 {
     /*
      * This could be optimized by using the segment index on the lineal target.
      * However, it seems like the L/P case would be pretty rare in practice.
      */
     PointLocator locator = new PointLocator();
     IList<Coordinate> coords = ComponentCoordinateExtracter.GetCoordinates(testGeom);
     foreach (Coordinate p in coords)
     {
         if (locator.Intersects(p, prepLine.Geometry))
             return true;
     }
     return false;
 }