GeoJsonObject.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 MongoDB.Bson;
  16. using MongoDB.Bson.Serialization.Attributes;
  17. using MongoDB.Driver.GeoJsonObjectModel.Serializers;
  18. namespace MongoDB.Driver.GeoJsonObjectModel
  19. {
  20. /// <summary>
  21. /// Represents a GeoJson object (see subclasses).
  22. /// </summary>
  23. /// <typeparam name="TCoordinates">The type of the coordinates.</typeparam>
  24. [BsonSerializer(typeof(GeoJsonObjectSerializer<>))]
  25. public abstract class GeoJsonObject<TCoordinates> where TCoordinates : GeoJsonCoordinates
  26. {
  27. // private fields
  28. private GeoJsonBoundingBox<TCoordinates> _boundingBox;
  29. private GeoJsonCoordinateReferenceSystem _coordinateReferenceSystem;
  30. private BsonDocument _extraMembers;
  31. // constructor
  32. /// <summary>
  33. /// Initializes a new instance of the <see cref="GeoJsonObject{TCoordinates}"/> class.
  34. /// </summary>
  35. /// <param name="args">The additional args.</param>
  36. protected GeoJsonObject(GeoJsonObjectArgs<TCoordinates> args)
  37. {
  38. if (args != null)
  39. {
  40. _boundingBox = args.BoundingBox;
  41. _coordinateReferenceSystem = args.CoordinateReferenceSystem;
  42. _extraMembers = args.ExtraMembers;
  43. }
  44. }
  45. // public properties
  46. /// <summary>
  47. /// Gets the bounding box.
  48. /// </summary>
  49. public GeoJsonBoundingBox<TCoordinates> BoundingBox
  50. {
  51. get { return _boundingBox; }
  52. }
  53. /// <summary>
  54. /// Gets the coordinate reference system.
  55. /// </summary>
  56. public GeoJsonCoordinateReferenceSystem CoordinateReferenceSystem
  57. {
  58. get { return _coordinateReferenceSystem; }
  59. }
  60. /// <summary>
  61. /// Gets the extra members.
  62. /// </summary>
  63. public BsonDocument ExtraMembers
  64. {
  65. get { return _extraMembers; }
  66. }
  67. /// <summary>
  68. /// Gets the type of the GeoJson object.
  69. /// </summary>
  70. public abstract GeoJsonObjectType Type { get; }
  71. }
  72. }