Beispiel #1
0
 public override int GetHashCode(SpatialEqualityOptions options)
 {
     unchecked
     {
         return ((Coordinate1 != null ? Coordinate1.GetHashCode(options) : 0) * 397) ^ (Coordinate2 != null ? Coordinate2.GetHashCode(options) : 0);
     }
 }
Beispiel #2
0
        public override bool Equals(object obj, SpatialEqualityOptions options)
        {
            var other = obj as Coordinate;

            if (ReferenceEquals(null, other))
                return false;

            var other2 = other as CoordinateZ;
            if (ReferenceEquals(null, other2))
                return false;

            if (options.UseElevation && !Elevation.Equals(other2.Elevation))
                return false;

            if (Latitude.Equals(other.Latitude))
            {
                if (options.PoleCoordiantesAreEqual && Latitude.Equals(90d) || Latitude.Equals(-90d))
                    return true;

                if (Longitude.Equals(other.Longitude))
                    return true;

                if (options.AntiMeridianCoordinatesAreEqual)
                {
                    if (Longitude.Equals(180) && other.Longitude.Equals(-180) ||
                        Longitude.Equals(-180) && other.Longitude.Equals(180))
                        return true;
                }
            }

            return false;
        }
Beispiel #3
0
        public override int GetHashCode(SpatialEqualityOptions options)
        {
            unchecked
            {
                var latitude  = Latitude;
                var longitude = Longitude;

                if (options.PoleCoordiantesAreEqual && (Latitude.Equals(90) || Latitude.Equals(-90)))
                {
                    longitude = 0;
                }
                else if (options.AntiMeridianCoordinatesAreEqual && Longitude.Equals(-180))
                {
                    longitude = 180;
                }

                var hashCode = latitude.GetHashCode();
                hashCode = (hashCode * 397) ^ longitude.GetHashCode();
                if (options.UseElevation)
                {
                    hashCode = (hashCode * 397) ^ Measure.GetHashCode();
                }
                return(hashCode);
            }
        }
Beispiel #4
0
 public override int GetHashCode(SpatialEqualityOptions options)
 {
     unchecked
     {
         return(((Coordinate1 != null ? Coordinate1.GetHashCode(options) : 0) * 397) ^ (Coordinate2 != null ? Coordinate2.GetHashCode(options) : 0));
     }
 }
Beispiel #5
0
 public GeoContext(Spheroid spheroid)
 {
     Spheroid               = spheroid;
     GeodeticCalculator     = new SpheroidCalculator(spheroid);
     GeomagnetismCalculator = new GeomagnetismCalculator(spheroid);
     EqualityOptions        = new SpatialEqualityOptions();
     LongitudeWrapping      = false;
 }
Beispiel #6
0
 public GeoContext(Spheroid spheroid)
 {
     Spheroid = spheroid;
     GeodeticCalculator = new SpheroidCalculator(spheroid);
     GeomagnetismCalculator = new GeomagnetismCalculator(spheroid);
     EqualityOptions = new SpatialEqualityOptions();
     LongitudeWrapping = false;
 }
Beispiel #7
0
        public override bool Equals(object obj, SpatialEqualityOptions options)
        {
            var other = obj as Coordinate;

            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            var other2 = other as CoordinateZM;

            if (ReferenceEquals(null, other2))
            {
                return(false);
            }

            if (options.UseElevation && !Elevation.Equals(other2.Elevation))
            {
                return(false);
            }

            if (options.UseM && !Measure.Equals(other2.Measure))
            {
                return(false);
            }

            if (Latitude.Equals(other.Latitude))
            {
                if (options.PoleCoordiantesAreEqual && Latitude.Equals(90d) || Latitude.Equals(-90d))
                {
                    return(true);
                }

                if (Longitude.Equals(other.Longitude))
                {
                    return(true);
                }

                if (options.AntiMeridianCoordinatesAreEqual)
                {
                    if (Longitude.Equals(180) && other.Longitude.Equals(-180) ||
                        Longitude.Equals(-180) && other.Longitude.Equals(180))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #8
0
        public override int GetHashCode(SpatialEqualityOptions options)
        {
            unchecked
            {
                var latitude = Latitude;
                var longitude = Longitude;

                if (options.PoleCoordiantesAreEqual && (Latitude.Equals(90) || Latitude.Equals(-90)))
                    longitude = 0;
                else if (options.AntiMeridianCoordinatesAreEqual && Longitude.Equals(-180))
                    longitude = 180;

                var hashCode = latitude.GetHashCode();
                hashCode = (hashCode * 397) ^ longitude.GetHashCode();
                if (options.UseElevation)
                    hashCode = (hashCode * 397) ^ Elevation.GetHashCode();
                return hashCode;
            }
        }
Beispiel #9
0
        public override bool Equals(object obj, SpatialEqualityOptions options)
        {
            var other = obj as Coordinate;

            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (other.Is3D || other.IsMeasured)
            {
                return(false);
            }

            if (Latitude.Equals(other.Latitude))
            {
                if (options.PoleCoordiantesAreEqual && Latitude.Equals(90d) || Latitude.Equals(-90d))
                {
                    return(true);
                }

                if (Longitude.Equals(other.Longitude))
                {
                    return(true);
                }

                if (options.AntiMeridianCoordinatesAreEqual)
                {
                    if (Longitude.Equals(180) && other.Longitude.Equals(-180) ||
                        Longitude.Equals(-180) && other.Longitude.Equals(180))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #10
0
 public override bool Equals(object obj, SpatialEqualityOptions options)
 {
     var other = obj as LineSegment;
     return !ReferenceEquals(null, other) && Equals(Coordinate1, other.Coordinate1, options) && Equals(Coordinate2, other.Coordinate2, options);
 }
Beispiel #11
0
 public GeoContext()
 {
     GeodeticCalculator = SpheroidCalculator.Wgs84();
     EqualityOptions = new SpatialEqualityOptions();
     LongitudeWrapping = false;
 }
Beispiel #12
0
        public override bool Equals(object obj, SpatialEqualityOptions options)
        {
            var other = obj as LineSegment;

            return(!ReferenceEquals(null, other) && Equals(Coordinate1, other.Coordinate1, options) && Equals(Coordinate2, other.Coordinate2, options));
        }
Beispiel #13
0
        public override bool Equals(object obj, SpatialEqualityOptions options)
        {
            var other = obj as Coordinate;

            if (ReferenceEquals(null, other))
                return false;

            if (other.Is3D || other.IsMeasured)
                return false;

            if (Latitude.Equals(other.Latitude))
            {
                if (options.PoleCoordiantesAreEqual && Latitude.Equals(90d) || Latitude.Equals(-90d))
                    return true;

                if (Longitude.Equals(other.Longitude))
                    return true;

                if (options.AntiMeridianCoordinatesAreEqual)
                {
                    if (Longitude.Equals(180) && other.Longitude.Equals(-180) ||
                        Longitude.Equals(-180) && other.Longitude.Equals(180))
                        return true;
                }
            }

            return false;
        }
Beispiel #14
0
 public GeoContext()
 {
     GeodeticCalculator = SpheroidCalculator.Wgs84();
     EqualityOptions    = new SpatialEqualityOptions();
     LongitudeWrapping  = false;
 }