Ejemplo n.º 1
0
        /// <summary>
        /// Applies the flip filter.
        /// </summary>
        /// <remarks>
        /// The following calculation is performed on the Y coordinate.
        /// <code>
        /// coord.Y = (_max - coord.Y) + _min;
        /// </code>
        /// </remarks>
        /// <param name="geometry">The geometry object to apply the filter to.</param>
        public void Filter(Geometry geometry)
        {
            /*if (geometry is Polygon)
             * {
             *      Polygon polygon = (Polygon)geometry;
             *      Filter(polygon.Shell);
             *      foreach(LinearRing linearring in polygon.Holes)
             *      {
             *              Filter(linearring);
             *      }
             * }
             * else*/if (geometry is LinearRing || geometry is LineString || geometry is Point)
            {
                Coordinates coords = geometry.GetCoordinates();
                for (int i = 0; i < coords.Count; i++)
                {
                    coords[i].Y = (_max - coords[i].Y) + _min;
                }
            }

            /*else if (geometry is GeometryCollection)
             * {
             *      Filter(geometry);
             * }
             * else
             * {
             *      throw new NotSupportedException(geometry.GetType().Name);
             * }
             * geometry.GeometryChanged();*/
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Applies the flip filter.
		/// </summary>
		/// <remarks>
		/// The following calculation is performed on the Y coordinate.
		/// <code>
		/// coord.Y = (_max - coord.Y) + _min;
		/// </code>
		/// </remarks>
		/// <param name="geometry">The geometry object to apply the filter to.</param>
		public void Filter(Geometry geometry)
		{
			/*if (geometry is Polygon)
			{
				Polygon polygon = (Polygon)geometry;
				Filter(polygon.Shell);
				foreach(LinearRing linearring in polygon.Holes)
				{
					Filter(linearring);
				}
			}
			else*/ if (geometry is LinearRing || geometry is LineString || geometry is Point)
			{
				Coordinates coords = geometry.GetCoordinates();
				for (int i=0; i < coords.Count; i++)
				{
					coords[i].Y = (_max - coords[i].Y) + _min;
				}
			}
			/*else if (geometry is GeometryCollection)
			{
				Filter(geometry);
			}
			else
			{
				throw new NotSupportedException(geometry.GetType().Name);
			}
			geometry.GeometryChanged();*/
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Applies the projection to the coordinates.
        /// </summary>
        /// <param name="geometry">The geometry object to apply the filter to.</param>
        public void Filter(Geometry geometry)
        {
            /*if (geometry is Polygon)
             * {
             *      Polygon polygon = (Polygon)geometry;
             *      Filter(polygon.Shell);
             *      foreach(LinearRing linearring in polygon.Holes)
             *      {
             *              Filter(linearring);
             *      }
             * }*/
            if (geometry is LinearRing || geometry is LineString || geometry is Point)
            {
                int           sourceSRID = int.Parse(_coordinateTransform.SourceCS.AuthorityCode);
                int           targetSRID = int.Parse(_coordinateTransform.TargetCS.AuthorityCode);
                MapProjection projection = (MapProjection)_coordinateTransform.MathTransform;

                Coordinates projectedCoordinates = new Coordinates();
                double      x = 0.0;
                double      y = 0.0;
                Coordinate  coordinate;
                for (int i = 0; i < geometry.GetCoordinates().Count; i++)
                {
                    coordinate = geometry.GetCoordinates()[i];
                    if (geometry.GetSRID() == sourceSRID)
                    {
                        projection.MetersToDegrees(coordinate.X, coordinate.Y, out x, out y);
                    }
                    else if (geometry.GetSRID() == targetSRID)
                    {
                        projection.DegreesToMeters(coordinate.X, coordinate.Y, out x, out y);
                    }
                    coordinate.X = x;
                    coordinate.Y = y;
                }
            }

            /*else
             * {
             *      throw new NotSupportedException(geometry.GetType().Name);
             * }*/
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Applies the projection to the coordinates.
		/// </summary>
		/// <param name="geometry">The geometry object to apply the filter to.</param>
		public void Filter(Geometry geometry)
		{
			/*if (geometry is Polygon)
			{
				Polygon polygon = (Polygon)geometry;
				Filter(polygon.Shell);
				foreach(LinearRing linearring in polygon.Holes)
				{
					Filter(linearring);
				}
			}*/
			if (geometry is LinearRing || geometry is LineString || geometry is Point)
			{	
				int sourceSRID = int.Parse(_coordinateTransform.SourceCS.AuthorityCode);
				int targetSRID = int.Parse(_coordinateTransform.TargetCS.AuthorityCode);
				MapProjection projection = (MapProjection)_coordinateTransform.MathTransform;

				Coordinates projectedCoordinates = new Coordinates();
				double x=0.0;
				double y=0.0;
				Coordinate coordinate;
				for(int i=0; i < geometry.GetCoordinates().Count; i++)
				{
					coordinate = geometry.GetCoordinates()[i];
					if (geometry.GetSRID() == sourceSRID)
					{
						projection.MetersToDegrees(coordinate.X, coordinate.Y, out x, out y);	
					}
					else if (geometry.GetSRID() == targetSRID)
					{
					
						projection.DegreesToMeters(coordinate.X, coordinate.Y, out x, out y);
					}
					coordinate.X = x;
					coordinate.Y = y;
				}
			}
			/*else
			{
				throw new NotSupportedException(geometry.GetType().Name);
			}*/
		}
Ejemplo n.º 5
0
        ///<summary>
        /// Returns whether this Geometry is greater than, equal to, or less than another Geometry having
        /// the same class.
        ///</summary>
        ///<param name="obj">A Geometry having the same class as this Geometry.</param>
        ///<returns>Returns a positive number, 0, or a negative number, depending on whether this object is
        /// greater than, equal to, or less than obj.</returns>
        public override int CompareToSameClass(object obj)
        {
            // create new array of coordinates to sort.
            ArrayList theseElements = new ArrayList();

            theseElements.AddRange(GetCoordinates());
            theseElements.Sort();

            // get other's elements in arraylist and sort.
            Geometry  other         = obj as Geometry;
            ArrayList otherElements = new ArrayList();

            otherElements.AddRange(other.GetCoordinates());
            otherElements.Sort();

            return(Compare(theseElements, otherElements));
        }         // public override int CompareToSameClass(object obj)
Ejemplo n.º 6
0
        ///<summary>
        /// Returns whether this Geometry is greater than, equal to, or less than another Geometry having
        /// the same class.
        ///</summary>
        ///<param name="obj">A Geometry having the same class as this Geometry.</param>
        ///<returns>Returns a positive number, 0, or a negative number, depending on whether this object is
        /// greater than, equal to, or less than obj.</returns>
        public override int CompareToSameClass(object obj)
        {
            Geometry other = obj as Geometry;

            return(Compare(this.GetCoordinates(), other.GetCoordinates()));
        }