Example #1
0
        /// <summary>
        /// Determines whether the specified <see cref="GeoJSONObject" />, is equal to this instance.
        /// </summary>
        /// <param name="other">The <see cref="GeoJSONObject" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="GeoJSONObject" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        protected virtual bool Equals(GeoJSONObject other)
        {
            if (Type != other.Type)
            {
                return(false);
            }

            if (!Equals(CRS, other.CRS))
            {
                return(false);
            }

            if (BoundingBoxes == null && other.BoundingBoxes == null)
            {
                return(true);
            }

            if ((BoundingBoxes != null && other.BoundingBoxes == null) ||
                (BoundingBoxes == null && other.BoundingBoxes != null))
            {
                return(false);
            }

            return(BoundingBoxes.SequenceEqual(other.BoundingBoxes, DoubleComparer));
        }
 private void AssertIsEqualToGeoJsonFile(GeoJSONObject geoJsonObject, string fileName, Type expectedType)
 {
     var serialized = JsonConvert.SerializeObject(geoJsonObject);
     Debug.WriteLine(serialized);
     var json = JsonConvert.SerializeObject(GetObjectFromJson(fileName, expectedType));
     serialized.ShouldBe(json);
 }
Example #3
0
 /// <summary>
 /// Translate a GEOJSONObject to the corresponding SqlGeography. Please note that without any additional configuration,
 /// a FeatureCollection will turn into a GeometryCollection and the geometry of each feature will be added to that collection.
 /// </summary>
 public static SqlGeography Translate(GeoJSONObject geoJsonObject)
 {
     AssertValidity();
     var visitor = new GeoJsonToSqlGeographyObjectWalker();
     var walker = new GeoJsonObjectWalker(geoJsonObject);
     walker.CarryOut(visitor);
     return visitor.ConstructedGeography;
 }
Example #4
0
        /// <summary>
        /// Determines whether the specified <see cref="GeoJSONObject" />, is equal to this instance.
        /// </summary>
        /// <param name="other">The <see cref="GeoJSONObject" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="GeoJSONObject" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        protected virtual bool Equals(GeoJSONObject other)
        {
            if (Type != other.Type)
            {
                return false;
            }

            if (!Equals(CRS, other.CRS))
            {
                return false;
            }

            if (BoundingBoxes == null && other.BoundingBoxes == null)
            {
                return true;
            }

            if ((BoundingBoxes != null && other.BoundingBoxes == null) ||
                (BoundingBoxes == null && other.BoundingBoxes != null))
            {
                return false;
            }

            return BoundingBoxes.SequenceEqual(other.BoundingBoxes, DoubleComparer);
        }