GeoJsonPolygon.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright 2010-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using MongoDB.Bson.Serialization.Attributes;
  17. using MongoDB.Driver.GeoJsonObjectModel.Serializers;
  18. namespace MongoDB.Driver.GeoJsonObjectModel
  19. {
  20. /// <summary>
  21. /// Represents a GeoJson Polygon object.
  22. /// </summary>
  23. /// <typeparam name="TCoordinates">The type of the coordinates.</typeparam>
  24. [BsonSerializer(typeof(GeoJsonPolygonSerializer<>))]
  25. public class GeoJsonPolygon<TCoordinates> : GeoJsonGeometry<TCoordinates> where TCoordinates : GeoJsonCoordinates
  26. {
  27. // private fields
  28. private GeoJsonPolygonCoordinates<TCoordinates> _coordinates;
  29. // constructors
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="GeoJsonPolygon{TCoordinates}"/> class.
  32. /// </summary>
  33. /// <param name="coordinates">The coordinates.</param>
  34. public GeoJsonPolygon(GeoJsonPolygonCoordinates<TCoordinates> coordinates)
  35. : this(null, coordinates)
  36. {
  37. }
  38. /// <summary>
  39. /// Initializes a new instance of the <see cref="GeoJsonPolygon{TCoordinates}"/> class.
  40. /// </summary>
  41. /// <param name="args">The additional args.</param>
  42. /// <param name="coordinates">The coordinates.</param>
  43. public GeoJsonPolygon(GeoJsonObjectArgs<TCoordinates> args, GeoJsonPolygonCoordinates<TCoordinates> coordinates)
  44. : base(args)
  45. {
  46. if (coordinates == null)
  47. {
  48. throw new ArgumentNullException("coordinates");
  49. }
  50. _coordinates = coordinates;
  51. }
  52. // public properties
  53. /// <summary>
  54. /// Gets the coordinates.
  55. /// </summary>
  56. public GeoJsonPolygonCoordinates<TCoordinates> Coordinates
  57. {
  58. get { return _coordinates; }
  59. }
  60. /// <summary>
  61. /// Gets the type of the GeoJson object.
  62. /// </summary>
  63. public override GeoJsonObjectType Type
  64. {
  65. get { return GeoJsonObjectType.Polygon; }
  66. }
  67. }
  68. }