コード例 #1
0
 /// <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;
 }
コード例 #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
 /// <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;
 }
コード例 #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;
 }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
        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));
        }
コード例 #7
0
ファイル: Depth.cs プロジェクト: ste10k41/nettopologysuite
        /// <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;
        }
コード例 #8
0
       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));
       }
コード例 #9
0
ファイル: Location.cs プロジェクト: sridhar19091986/sharpmapx
 /// <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);
 }
コード例 #10
0
       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);
       }
コード例 #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);
 }
コード例 #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);
 }
コード例 #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_location"></param>
 public  void SetAllLocationsIfNull(Location _location)
 {
     SetAllLocationsIfNull(0, _location);
     SetAllLocationsIfNull(1, _location);
 }
コード例 #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);
 }
コード例 #15
0
        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
        }
コード例 #16
0
 private static bool HasLocation(Location[] location, Location loc)
 {
     for (int i = 0; i < 3; i++)
     {
         if (location[i] == loc)
             return true;
     }
     return false;
 }
コード例 #17
0
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, string wkt)
        {
            IGeometry geom = reader.Read(wkt);
            Assert.AreEqual(expectedLoc, CGAlgorithms.LocatePointInRing(pt, geom.Coordinates));

        }
コード例 #18
0
ファイル: IntersectionMatrix.cs プロジェクト: leoliusg/GeoAPI
 /// <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;
 }
コード例 #19
0
        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;
        }
コード例 #20
0
ファイル: IntersectionMatrix.cs プロジェクト: leoliusg/GeoAPI
 /// <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;
 }
コード例 #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);
 }
コード例 #22
0
ファイル: IntersectionMatrix.cs プロジェクト: leoliusg/GeoAPI
 /// <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);
 }
コード例 #23
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geomIndex"></param>
 /// <param name="_location"></param>
 public  void SetAllLocationsIfNull(int geomIndex, Location _location)
 {
     elt[geomIndex].SetAllLocationsIfNull(_location);
 }
コード例 #24
0
ファイル: IntersectionMatrix.cs プロジェクト: leoliusg/GeoAPI
 /// <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];
 }
コード例 #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);
 }
コード例 #26
0
ファイル: IntersectionMatrix.cs プロジェクト: leoliusg/GeoAPI
 /// <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);
     }
 }
コード例 #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);
 }
コード例 #28
0
ファイル: Node.cs プロジェクト: leoliusg/NetTopologySuite
 /// <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);
 }
コード例 #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);
 }        
コード例 #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;
            }
        }