コード例 #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
ファイル: Geometry.cs プロジェクト: networkfusion/GeoJSON
 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
ファイル: MyGeojson.cs プロジェクト: dojerz/TestGJsonLib
 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;
 }
コード例 #9
0
 /// <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");
 }
コード例 #10
0
 /// <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;
 }