/// <summary> 
 /// Constructs a TopologyLocation specifying how points on, to the left of, and to the
 /// right of some GraphComponent relate to some Geometry. Possible values for the
 /// parameters are Location.Null, Location.Exterior, Location.Boundary, 
 /// and Location.Interior.
 /// </summary>        
 /// <param name="on"></param>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public TopologyLocation(Location on, Location left, Location right)
 {
     Init(3);
     _location[(int) Positions.On] = on;
     _location[(int) Positions.Left] = left;
     _location[(int) Positions.Right] = right;
 }
 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);
 }
 /// <summary>
 /// Computes the factor for the change in depth when moving from one location to another.
 /// E.g. if crossing from the Interior to the Exterior the depth decreases, so the factor is -1.
 /// </summary>
 public static int DepthFactor(Location currLocation, Location nextLocation)
 {
     if (currLocation == Location.Exterior && nextLocation == Location.Interior)
         return 1;
     else if (currLocation == Location.Interior && nextLocation == Location.Exterior)
         return -1;
     return 0;
 }
Example #4
0
 private static Location MergeLocation(Location loc1, Location loc2)
 {
     Location mergeLoc = loc1;
     if (loc2 == GeoAPI.Geometries.Location.Interior)
     {
         mergeLoc = GeoAPI.Geometries.Location.Interior;
     }
     return mergeLoc;
 }
 /// <summary>
 /// Creates a {SegmentString} for a coordinate list which is a raw offset curve,
 /// and adds it to the list of buffer curves.
 /// The SegmentString is tagged with a Label giving the topology of the curve.
 /// The curve may be oriented in either direction.
 /// If the curve is oriented CW, the locations will be:
 /// Left: Location.Exterior.
 /// Right: Location.Interior.
 /// </summary>
 private void AddCurve(Coordinate[] coord, Location leftLoc, Location rightLoc)
 {
     // don't add null or trivial curves!
     if (coord == null || coord.Length < 2)
         return;
     // add the edge for a coordinate list which is a raw offset curve
     var e = new NodedSegmentString(coord, new Label(0, Location.Boundary, leftLoc, rightLoc));
     _curveList.Add(e);
 }
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, String wkt)
        {
            IGeometry geom = reader.Read(wkt);
            Assert.AreEqual(expectedLoc, RayCrossingCounter.LocatePointInRing(pt, geom.Coordinates));
            IPolygon poly = geom as IPolygon;
            if (poly == null)
                return;

            Assert.AreEqual(expectedLoc, RayCrossingCounter.LocatePointInRing(pt, poly.ExteriorRing.CoordinateSequence));
        }
Example #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_location"></param>
        /// <returns></returns>
        public static int DepthAtLocation(Location _location)
        {
            if (_location == Location.Exterior) 
                return 0;

            if (_location == Location.Interior) 
                return 1;

            return @null;
        }
       protected override void RunPtInRing(Location expectedLoc, Coordinate pt, String wkt)
       {
           // isPointInRing is not defined for pts on boundary
           if (expectedLoc == Location.Boundary)
 	            return;
 	 
           IGeometry geom = reader.Read(wkt);
           bool expected = expectedLoc == Location.Interior;
           Assert.AreEqual(expected, CGAlgorithms.IsPointInRing(pt, geom.Coordinates));
       }
Example #9
0
 /// <summary>
 /// Converts the location value to a location symbol, for example, <c>EXTERIOR => 'e'</c>.
 /// </summary>
 /// <param name="locationValue"></param>
 /// <returns>Either 'e', 'b', 'i' or '-'.</returns>
 public static char ToLocationSymbol(Location locationValue)
 {
     switch (locationValue)
     {
         case Location.Exterior:
             return 'e';
         case Location.Boundary:
             return 'b';
         case Location.Interior:
             return 'i';
         case Location.Null:
             return '-';
     }
     throw new ArgumentException("Unknown location value: " + locationValue);
 }
       protected override void RunPtInRing(Location expectedLoc, Coordinate pt, String wkt)
       {
 	        // isPointInRing is not defined for pts on boundary
 	        if (expectedLoc == Location.Boundary)
 		        return;
 	 
           IGeometry geom = reader.Read(wkt);
           if (!(geom is Polygon))
               return;
   
           LinearRing ring = (LinearRing)((Polygon) geom).ExteriorRing;
           bool expected = expectedLoc == Location.Interior;
           MCPointInRing pir = new MCPointInRing(ring);
           bool result = pir.IsInside(pt);
           Assert.AreEqual(expected, result);
       }
Example #11
0
 /// <summary>
 /// Construct a Label with On, Left and Right locations for both Geometries.
 /// Initialize the locations for both Geometries to the given values.
 /// </summary>
 /// <param name="onLoc"></param>
 /// <param name="leftLoc"></param>
 /// <param name="rightLoc"></param>
 public Label(Location onLoc, Location leftLoc, Location rightLoc)
 {
     elt[0] = new TopologyLocation(onLoc, leftLoc, rightLoc);
     elt[1] = new TopologyLocation(onLoc, leftLoc, rightLoc);
 }
Example #12
0
 /// <summary>
 /// Construct a Label with a single location for both Geometries.
 /// Initialize the locations to Null.
 /// </summary>
 /// <param name="onLoc"></param>
 public Label(Location onLoc)
 {
     elt[0] = new TopologyLocation(onLoc);
     elt[1] = new TopologyLocation(onLoc);
 }
Example #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_location"></param>
 public  void SetAllLocationsIfNull(Location _location)
 {
     SetAllLocationsIfNull(0, _location);
     SetAllLocationsIfNull(1, _location);
 }
Example #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="_location"></param>
 public  void SetLocation(int geomIndex, Location _location)
 {
     elt[geomIndex].SetLocation(Positions.On, _location);
 }
        private static void ReportResult(SpatialFunction overlayOp, Location[] location, bool expectedInterior)
        {
#if !PCL
// ReSharper disable RedundantStringFormatCall
            // String.Format needed to build 2.0 release!
            Debug.WriteLine(String.Format("{0}:" + " A:{1} B:{2} expected:{3} actual:{4}", 
                overlayOp,
                LocationUtility.ToLocationSymbol(location[0]), 
                LocationUtility.ToLocationSymbol(location[1]), expectedInterior ? 'i' : 'e', 
                LocationUtility.ToLocationSymbol(location[2])));
// ReSharper restore RedundantStringFormatCall
#endif
        }
 private static bool HasLocation(Location[] location, Location loc)
 {
     for (int i = 0; i < 3; i++)
     {
         if (location[i] == loc)
             return true;
     }
     return false;
 }
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, string wkt)
        {
            IGeometry geom = reader.Read(wkt);
            Assert.AreEqual(expectedLoc, CGAlgorithms.LocatePointInRing(pt, geom.Coordinates));

        }
Example #18
0
 /// <summary>
 /// Changes the value of one of this <see cref="IntersectionMatrix" /> elements.
 /// </summary>
 /// <param name="row">
 /// The row of this <see cref="IntersectionMatrix" />,
 /// indicating the interior, boundary or exterior of the first <see cref="IGeometry"/>
 /// </param>
 /// <param name="column">
 /// The column of this <see cref="IntersectionMatrix" />,
 /// indicating the interior, boundary or exterior of the second <see cref="IGeometry"/>
 /// </param>
 /// <param name="dimensionValue">The new value of the element</param>        
 public void Set(Location row, Location column, Dimension dimensionValue)
 {
     _matrix[(int)row, (int)column] = dimensionValue;
 }
        private static bool IsValidResult(SpatialFunction overlayOp, Location[] location)
        {
            bool expectedInterior = OverlayOp.IsResultOfOp(location[0], location[1], overlayOp);

            bool resultInInterior = (location[2] == Location.Interior);
            // MD use simpler: boolean isValid = (expectedInterior == resultInInterior);
            bool isValid = !(expectedInterior ^ resultInInterior);

            if (!isValid) ReportResult(overlayOp, location, expectedInterior);

            return isValid;
        }
Example #20
0
 /// <summary>
 /// Changes the specified element to <c>minimumDimensionValue</c> if the element is less.
 /// </summary>
 /// <param name="row">
 /// The row of this <see cref="IntersectionMatrix" />, 
 /// indicating the interior, boundary or exterior of the first <see cref="IGeometry"/>.
 /// </param>
 /// <param name="column">
 /// The column of this <see cref="IntersectionMatrix" />, 
 /// indicating the interior, boundary or exterior of the second <see cref="IGeometry"/>.
 /// </param>
 /// <param name="minimumDimensionValue">
 /// The dimension value with which to compare the
 /// element. The order of dimension values from least to greatest is
 /// <c>True, False, Dontcare, 0, 1, 2</c>.
 /// </param>
 public void SetAtLeast(Location row, Location column, Dimension minimumDimensionValue)
 {
     if (_matrix[(int)row, (int)column] < minimumDimensionValue)
         _matrix[(int)row, (int)column] = minimumDimensionValue;
 }
Example #21
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="posIndex"></param>
 /// <param name="_location"></param>
 public  void SetLocation(int geomIndex, Positions posIndex, Location _location)
 {
     elt[geomIndex].SetLocation(posIndex, _location);
 }
Example #22
0
 /// <summary>
 /// If row >= 0 and column >= 0, changes the specified element to <c>minimumDimensionValue</c>
 /// if the element is less. Does nothing if row is smaller to 0 or column is smaller to 0.
 /// </summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <param name="minimumDimensionValue"></param>
 public void SetAtLeastIfValid(Location row, Location column, Dimension minimumDimensionValue)
 {
     if (row >= Location.Interior && column >= Location.Interior)
         SetAtLeast(row, column, minimumDimensionValue);
 }
Example #23
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="_location"></param>
 public  void SetAllLocationsIfNull(int geomIndex, Location _location)
 {
     elt[geomIndex].SetAllLocationsIfNull(_location);
 }
Example #24
0
 /// <summary>
 /// Returns the value of one of this <see cref="IntersectionMatrix" />s
 /// elements.
 /// </summary>
 /// <param name="row">
 /// The row of this <see cref="IntersectionMatrix" />, indicating
 /// the interior, boundary or exterior of the first <see cref="IGeometry"/>.
 /// </param>
 /// <param name="column">
 /// The column of this <see cref="IntersectionMatrix" />,
 /// indicating the interior, boundary or exterior of the second <see cref="IGeometry"/>.
 /// </param>
 /// <returns>The dimension value at the given matrix position.</returns>
 public Dimension Get(Location row, Location column)
 {
     return _matrix[(int)row, (int)column];
 }
Example #25
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="loc"></param>
 /// <returns></returns>
 public  bool AllPositionsEqual(int geomIndex, Location loc)
 {
     return elt[geomIndex].AllPositionsEqual(loc);
 }
Example #26
0
 /// <summary>
 /// See methods Get(int, int) and Set(int, int, int value)
 /// </summary>         
 public Dimension this[Location row, Location column]
 {
     get
     {
         return Get(row, column);
     }
     set
     {
         Set(row, column, value);
     }
 }
Example #27
0
 /// <summary> 
 /// Construct a Label with a single location for both Geometries.
 /// Initialize the location for the Geometry index.
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="onLoc"></param>
 public Label(int geomIndex, Location onLoc)
 {
     elt[0] = new TopologyLocation(Location.Null);
     elt[1] = new TopologyLocation(Location.Null);
     elt[geomIndex].SetLocation(onLoc);
 }
Example #28
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="onLocation"></param>
 public void SetLabel(int argIndex, Location onLocation)
 {
     if (Label == null)
          Label = new Label(argIndex, onLocation);
     else Label.SetLocation(argIndex, onLocation);
 }
Example #29
0
 /// <summary>
 /// Construct a Label with On, Left and Right locations for both Geometries.
 /// Initialize the locations for the given Geometry index.
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="onLoc"></param>
 /// <param name="leftLoc"></param>
 /// <param name="rightLoc"></param>
 public Label(int geomIndex, Location onLoc, Location leftLoc, Location rightLoc)
 {
     elt[0] = new TopologyLocation(Location.Null, Location.Null, Location.Null);
     elt[1] = new TopologyLocation(Location.Null, Location.Null, Location.Null);
     elt[geomIndex].SetLocations(onLoc, leftLoc, rightLoc);
 }        
Example #30
0
        /// <summary>
        /// Tests whether a point with given <see cref="Location"/>s
        /// relative to two geometries is contained in 
        /// the result of overlaying the geometries using
        /// a given overlay operation.
        /// <para/>
        /// The method handles arguments of <see cref="Location.Null"/> correctly
        /// </summary>
        /// <param name="loc0">the code for the location in the first geometry </param>
        /// <param name="loc1">the code for the location in the second geometry</param>
        /// <param name="overlayOpCode">the code for the overlay operation to test</param>
        /// <returns><c>true</c> if the locations correspond to the overlayOpCode.</returns>
        public static bool IsResultOfOp(Location loc0, Location loc1, SpatialFunction overlayOpCode)
        {
            if (loc0 == Location.Boundary)
                loc0 = Location.Interior;
            if (loc1 == Location.Boundary)
                loc1 = Location.Interior;

            switch (overlayOpCode)
            {
                case SpatialFunction.Intersection:
                    return loc0 == Location.Interior && loc1 == Location.Interior;
                case SpatialFunction.Union:
                    return loc0 == Location.Interior || loc1 == Location.Interior;
                case SpatialFunction.Difference:
                    return loc0 == Location.Interior && loc1 != Location.Interior;
                case SpatialFunction.SymDifference:
                    return   (loc0 == Location.Interior &&  loc1 != Location.Interior)
                          || (loc0 != Location.Interior &&  loc1 == Location.Interior);
                default:
                    return false;
            }
        }