/// <summary>
 /// Removes the common coordinate bits from a Geometry.
 /// The coordinates of the Geometry are changed.
 /// </summary>
 /// <param name="geom">The Geometry from which to remove the common coordinate bits.</param>
 /// <returns>The shifted Geometry.</returns>
 public virtual Geometry RemoveCommonBits(Geometry geom)
 {
     if (commonCoord.X == 0.0 && commonCoord.Y == 0.0)
         return geom;
     Coordinate invCoord = new Coordinate(commonCoord);
     invCoord.X = -invCoord.X;
     invCoord.Y = -invCoord.Y;
     Translater trans = new Translater(invCoord);            
     geom.Apply(trans);
     geom.GeometryChanged();
     return geom;
 }
예제 #2
0
       /// <summary>
       /// Allows each geometry to control any custom behavior that cannot be solved with MemberwiseClone.
       /// The Coordinates of the geometry are already duplicated.
       /// </summary>
       /// <param name="copy"></param>
       protected virtual void OnCopy(Geometry copy)
       {
 
       }
 /// <summary>
 /// Handles the duplication process for geometry collections
 /// </summary>
 /// <returns></returns>
 protected override void OnCopy(Geometry copy)
 {
     GeometryCollection gc = copy as GeometryCollection;
     if (gc == null) return;
     gc._geometries = new Geometry[_geometries.Length];
     for (int i = 0; i < _geometries.Length; i++)
         gc._geometries[i] = (Geometry) _geometries[i].Clone();
 }
예제 #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parentGeometry"></param>
 public IsValidOp(Geometry parentGeometry)
 {
     this.parentGeometry = parentGeometry;
 }
예제 #5
0
        /// <summary>
        /// Creates a copy of this Point with the same factory
        /// specifications and values.
        /// </summary>
        /// <returns></returns>
        protected override void  OnCopy(Geometry copy)
        {
 	         base.OnCopy(copy);
             Point p = copy as Point;
             if(p != null)
             {
                 p._coordinate = _coordinate.Copy();
             } 
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geom"></param>
 /// <param name="distanceTolerance"></param>
 /// <returns></returns>
 public static IGeometry Simplify(Geometry geom, double distanceTolerance)
 {
     DouglasPeuckerSimplifier tss = new DouglasPeuckerSimplifier(geom);
     tss.DistanceTolerance = distanceTolerance;
     return tss.GetResultGeometry();
 }
예제 #7
0
 /// <summary>
 /// Computes the buffer for a point for a given buffer distance
 /// and accuracy of approximation.
 /// </summary>
 /// <param name="g">The point to buffer.</param>
 /// <param name="distance">The buffer distance.</param>
 /// <param name="quadrantSegments">The number of segments used to approximate a quarter circle.</param>
 /// <returns>The buffer of the input point.</returns>
 public static IGeometry Buffer(Geometry g, double distance, int quadrantSegments)
 {
     BufferOp bufOp = new BufferOp(g);
     bufOp.QuadrantSegments = quadrantSegments;
     IGeometry geomBuf = bufOp.GetResultGeometry(distance);
     return geomBuf;
 }
예제 #8
0
 /// <summary>
 /// Sets corrent length for Byte Stream.
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 protected virtual int SetByteStreamLength(Geometry geometry)
 {
     if (geometry is Point)
         return SetByteStreamLength(geometry as Point);
     if (geometry is LineString)
         return SetByteStreamLength(geometry as LineString);
     if (geometry is Polygon)
         return SetByteStreamLength(geometry as Polygon);
     if (geometry is MultiPoint)
         return SetByteStreamLength(geometry as MultiPoint);
     if (geometry is MultiLineString)
         return SetByteStreamLength(geometry as MultiLineString);
     if (geometry is MultiPolygon)
         return SetByteStreamLength(geometry as MultiPolygon);
     if (geometry is GeometryCollection)
         return SetByteStreamLength(geometry as GeometryCollection);
     throw new ArgumentException("ShouldNeverReachHere");
 }
예제 #9
0
		/// <summary>
		/// Advances the IDataReader to the next record.
		/// </summary>
		/// <returns>true if there are more rows; otherwise, false.</returns>
		public bool Read()
		{
			bool moreDbfRecords = _dbfEnumerator.MoveNext();
			bool moreShpRecords = _shpEnumerator.MoveNext();

			if(!moreDbfRecords)
			{
				int a = 0;
				a++;
			}
			if(!moreShpRecords)
			{
				int b = 0;
				b++;
			}
			_moreRecords = moreDbfRecords && moreShpRecords;

			// get current shape 
			geometry = (Geometry)_shpEnumerator.Current;            

			// get current dbase record
			_columnValues = (ArrayList)_dbfEnumerator.Current;            
            
			return _moreRecords; // moreDbfRecords && moreShpRecords;
		}
 public static IGeometry Buffer(Geometry geom, double distance)
 {
     ApplicationException originalEx = null;
     try
     {
         Geometry result = (Geometry)geom.Buffer(distance);
         return result;
     }
     catch (ApplicationException ex)
     {
         originalEx = ex;
     }
     /*
      * If we are here, the original op encountered a precision problem
      * (or some other problem).  Retry the operation with
      * enhanced precision to see if it succeeds
      */
     try
     {
         CommonBitsOp cbo = new CommonBitsOp(true);
         IGeometry resultEP = cbo.Buffer(geom, distance);
         // check that result is a valid point after the reshift to orginal precision
         if (!resultEP.IsValid)
             throw originalEx;
         return resultEP;
     }
     catch (ApplicationException)
     {
         throw originalEx;
     }
 }
예제 #11
0
 /// <summary>
 /// Same as <c>write</c>, but with newlines and spaces to make the
 /// well-known text more readable.
 /// </summary>
 /// <param name="geometry">A <c>Geometry</c> to process</param>
 /// <param name="writer"></param>
 /// <returns>
 /// A Geometry Tagged Text string (see the OpenGIS Simple
 /// Features Specification), with newlines and spaces.
 /// </returns>
 public virtual void WriteFormatted(Geometry geometry, TextWriter writer)
 {
     WriteFormatted(geometry, true, writer);
 }
예제 #12
0
 /// <summary>
 /// Same as <c>write</c>, but with newlines and spaces to make the
 /// well-known text more readable.
 /// </summary>
 /// <param name="geometry">A <c>Geometry</c> to process</param>
 /// <returns>
 /// A "Geometry Tagged Text" string (see the OpenGIS Simple
 /// Features Specification), with newlines and spaces.
 /// </returns>
 public virtual string WriteFormatted(Geometry geometry)
 {
     TextWriter sw = new StringWriter();
     try 
     {
         WriteFormatted(geometry, true, sw);
     }
     catch (IOException) 
     {
         Assert.ShouldNeverReachHere();
     }
     return sw.ToString();
 }
예제 #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geometry"></param>
 /// <param name="attributes"></param>
 public NTSFeature(Geometry geometry, IAttributesTable attributes) : this()
 {
     this.geometry = geometry;
     this.attributes = attributes;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputGeom"></param>
 public DouglasPeuckerSimplifier(Geometry inputGeom)
 {
     _inputGeom = inputGeom;
 }
 /// <summary>
 /// Returns a list containing a Coordinate from each Polygon, LineString, and Point
 /// found inside the specified point. Thus, if the specified point is
 /// not a GeometryCollection, an empty list will be returned.
 /// </summary>
 public static IList GetCoordinates(Geometry geom)
 {
     IList pts = new ArrayList();
     geom.Apply(new ConnectedElementPointFilter(pts));
     return pts;
 }
예제 #16
0
 /// <summary>
 /// Adds a Geometry to be processed. May be called multiple times.
 /// Any dimension of Geometry may be added; the constituent linework will be
 /// extracted.
 /// </summary>
 /// <param name="geometry"></param>
 public virtual void Add(Geometry geometry)
 {            
     geometry.Apply(new AnonymousGeometryComponentFilterImpl(this));
 }
예제 #17
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="geom"></param>
 /// <returns></returns>
 private bool IsSimpleLinearGeometry(Geometry geom)
 {
     if (geom.IsEmpty) 
         return true;
     GeometryGraph graph = new GeometryGraph(0, geom);
     LineIntersector li = new RobustLineIntersector();
     SegmentIntersector si = graph.ComputeSelfNodes(li, true);
     // if no self-intersection, must be simple
     if (!si.HasIntersection) return true;
     if (si.HasProperIntersection) return false;
     if (HasNonEndpointIntersection(graph)) return false;
     if (HasClosedEndpointIntersection(graph)) return false;
     return true;
 }
예제 #18
0
 /// <summary>
 /// Computes the buffer of a point for a given buffer distance,
 /// using the given Cap Style for borders of the point.
 /// </summary>
 /// <param name="g">The point to buffer.</param>
 /// <param name="distance">The buffer distance.</param>        
 /// <param name="endCapStyle">Cap Style to use for compute buffer.</param>
 /// <returns> The buffer of the input point.</returns>
 public static IGeometry Buffer(Geometry g, double distance, BufferStyles endCapStyle)
 {
     BufferOp gBuf = new BufferOp(g);
     gBuf.EndCapStyle = endCapStyle;
     IGeometry geomBuf = gBuf.GetResultGeometry(distance);
     return geomBuf;
 }
예제 #19
0
        /// <summary>
        /// Returns a copy of this ILineString
        /// </summary>
        /// <returns>A Copy of this ILineString</returns>
        protected override void OnCopy(Geometry copy)
        {
 	        base.OnCopy(copy);
            LineString ls = copy as LineString;
            if (ls == null) return;
            ls.Coordinates = new List<Coordinate>();
            foreach (Coordinate coordinate in _points)
            {
                ls.Coordinates.Add(coordinate);
            }
        }
예제 #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual IGeometry ReadGeometryCollection(BinaryReader reader)
        {
            int numGeometries = reader.ReadInt32();
            IGeometry[] geometries = new Geometry[numGeometries];

            for (int i = 0; i < numGeometries; i++)
            {
                ReadByteOrder(reader);
                WkbGeometryTypes geometryType = (WkbGeometryTypes)reader.ReadInt32();
                switch (geometryType)
                {
                    case WkbGeometryTypes.Point:
                        geometries[i] = ReadPoint(reader);
                        break;
                    case WkbGeometryTypes.LineString:
                        geometries[i] = ReadLineString(reader);
                        break;
                    case WkbGeometryTypes.Polygon:
                        geometries[i] = ReadPolygon(reader);
                        break;
                    case WkbGeometryTypes.MultiPoint:
                        geometries[i] = ReadMultiPoint(reader);
                        break;
                    case WkbGeometryTypes.MultiLineString:
                        geometries[i] = ReadMultiLineString(reader);
                        break;
                    case WkbGeometryTypes.MultiPolygon:
                        geometries[i] = ReadMultiPolygon(reader);
                        break;
                    case WkbGeometryTypes.GeometryCollection:
                        geometries[i] = ReadGeometryCollection(reader);
                        break;
                    default:
                        throw new ArgumentException("Should never reach here!");
                }                
            }
            return Factory.CreateGeometryCollection(geometries);
        }
예제 #21
0
 /// <summary>
 /// Occurs during the copy process and ensures that the shell and holes are all duplicated and not direct references
 /// </summary>
 /// <param name="copy"></param>
 protected override void OnCopy(Geometry copy)
 {
     base.OnCopy(copy);
     Polygon poly = copy as Polygon;
     if (poly == null) return;
     poly.Shell = _shell.Copy();
     poly.Holes = new ILinearRing[_holes.Length];
     for (int i = 0; i < _holes.Length; i++)
         poly.Holes[i] = Holes[i].Copy();
 }