示例#1
0
 protected Geometry(GeoJsonType type) : base(type)
 {
     if (!DerivedTypeToType.ContainsKey(type))
     {
         throw new ArgumentException($"The type {type} is not a valid geometry type.");
     }
 }
示例#2
0
 protected Geometry(GeoJsonType type, bool is3D, IEnumerable <double> boundingBox = null) : base(type, is3D, boundingBox)
 {
     if (!DerivedTypeToType.ContainsKey(type))
     {
         throw new ArgumentException($"The type {type} is not a valid geometry type.");
     }
 }
示例#3
0
 /// <summary>
 /// Gets the appropriate class type corresponding to the enum
 /// representing the type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public new static Type GetType(GeoJsonType type)
 {
     if (DerivedTypeToType.ContainsKey(type))
     {
         return(DerivedTypeToType[type]);
     }
     else
     {
         throw new ArgumentException($"The type {type} is not a valid geometry type.");
     }
 }
示例#4
0
        /// <summary>
        /// Base constructor that all derived classes must implement
        /// </summary>
        /// <param name="type">The type of the GeoJson object</param>
        protected GeoJson(GeoJsonType type, bool is3D, IEnumerable <double> boundingBox = null)
        {
            this.Type        = type;
            this.BoundingBox = boundingBox;
            this.Is3D        = is3D;

            if (this.BoundingBox != null)
            {
                int Length = boundingBox.Count();

                if (this.Is3D && Length != 6)
                {
                    throw new ArgumentOutOfRangeException("boundingBox", "The bounding box must contain 6 elements for a 3D GeoJSON object.");
                }
                else if (!this.Is3D && Length != 4)
                {
                    throw new ArgumentOutOfRangeException("boundingBox", "The bounding box must contain 4 elements for a 2D GeoJSON object.");
                }
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the specified <paramref name="type"/>.
 /// </summary>
 /// <param name="type">The type of the shape.</param>
 protected GeoJsonGeometry(GeoJsonType type) : base(type)
 {
 }
示例#6
0
 /// <summary>
 /// Gets the appropriate class type corresponding to the enum
 /// representing the type
 /// </summary>
 /// <param name="type">The GeoJson type of the </param>
 /// <returns>The .NET type that corresponds to the GeoJson type</returns>
 public static Type GetType(GeoJsonType type)
 {
     return(DerivedTypeToType[type]);
 }
示例#7
0
 public MyGeojson(GeoJsonType type, bool is3D, IEnumerable <double> boundingBox, string guid) : base(type, is3D, boundingBox = null)
 {
     this.guid = guid;
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the specified <paramref name="type"/>.
 /// </summary>
 /// <param name="type">The type of the object.</param>
 protected GeoJsonObject(GeoJsonType type)
 {
     Type = type;
 }
 /// <summary>
 /// Initializes a new instance based on the specified <paramref name="type"/> and <paramref name="json"/>.
 /// </summary>
 /// <param name="type">The type of the feature.</param>
 /// <param name="json">An instance of <see cref="JObject"/> representing the feature.</param>
 protected GeoJsonFeatureBase(GeoJsonType type, JObject json) : base(type)
 {
     Properties = json.GetObject <GeoJsonProperties>("properties");
 }
 /// <summary>
 /// Initializes a new instance with the specified <paramref name="type"/>.
 /// </summary>
 /// <param name="type">The type of the feature.</param>
 protected GeoJsonFeatureBase(GeoJsonType type) : base(type)
 {
     Properties = new GeoJsonProperties();
 }
示例#11
0
 /// <summary>
 /// Base constructor that all derived classes must implement
 /// </summary>
 /// <param name="type"></param>
 protected GeoJson(GeoJsonType type)
 {
     this.Type        = type;
     this.BoundingBox = null;
 }