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));
 }
        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);
        }
 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);
 }
 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));
 }