1 // Copyright 2008, Google Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 //  1. Redistributions of source code must retain the above copyright notice,
7 //     this list of conditions and the following disclaimer.
8 //  2. Redistributions in binary form must reproduce the above copyright notice,
9 //     this list of conditions and the following disclaimer in the documentation
10 //     and/or other materials provided with the distribution.
11 //  3. Neither the name of Google Inc. nor the names of its contributors may be
12 //     used to endorse or promote products derived from this software without
13 //     specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef KML_DOM_ABSTRACTLATLONBOX_H__
27 #define KML_DOM_ABSTRACTLATLONBOX_H__
28 
29 #include "kml/dom/kml22.h"
30 #include "kml/dom/object.h"
31 
32 namespace kmldom {
33 
34 class Element;
35 class Serializer;
36 
37 // OGC KML 2.2 Standard: 9.14 kml:AbstractLatLonAltBox
38 // OGC KML 2.2 XSD: <complexType name="AbstractLatLonBoxType" abstract="true">
39 class AbstractLatLonBox : public Object {
40  public:
41   virtual ~AbstractLatLonBox();
Type()42   virtual KmlDomType Type() const { return Type_AbstractLatLonBox; }
IsA(KmlDomType type)43   virtual bool IsA(KmlDomType type) const {
44     return type == Type_AbstractLatLonBox || Object::IsA(type);
45   }
46 
47   // <north>
get_north()48   double get_north() const {
49     return north_;
50   }
has_north()51   bool has_north() const {
52     return has_north_;
53   }
set_north(double north)54   void set_north(double north) {
55     north_ = north;
56     has_north_ = true;
57   }
clear_north()58   void clear_north() {
59     north_ = 180.0;
60     has_north_ = false;
61   }
62 
63   // <south>
get_south()64   double get_south() const {
65     return south_;
66   }
has_south()67   bool has_south() const {
68     return has_south_;
69   }
set_south(double south)70   void set_south(double south) {
71     south_ = south;
72     has_south_ = true;
73   }
clear_south()74   void clear_south() {
75     south_ = -180.0;
76     has_south_ = false;
77   }
78 
79   // <east>
get_east()80   double get_east() const {
81     return east_;
82   }
has_east()83   bool has_east() const {
84     return has_east_;
85   }
set_east(double south)86   void set_east(double south) {
87     east_ = south;
88     has_east_ = true;
89   }
clear_east()90   void clear_east() {
91     east_ = 180.0;
92     has_east_ = false;
93   }
94 
95   // <west>
get_west()96   double get_west() const {
97     return west_;
98   }
has_west()99   bool has_west() const {
100     return has_west_;
101   }
set_west(double south)102   void set_west(double south) {
103     west_ = south;
104     has_west_ = true;
105   }
clear_west()106   void clear_west() {
107     west_ = -180.0;
108     has_west_ = false;
109   }
110 
111  protected:
112   // Abstract element.  Access for derived types only.
113   AbstractLatLonBox();
114   virtual void AddElement(const ElementPtr& element);
115   virtual void Serialize(Serializer& serializer) const;
116 
117  private:
118   double north_;
119   bool has_north_;
120   double south_;
121   bool has_south_;
122   double east_;
123   bool has_east_;
124   double west_;
125   bool has_west_;
126   LIBKML_DISALLOW_EVIL_CONSTRUCTORS(AbstractLatLonBox);
127 };
128 
129 }  // end namespace kmldom
130 
131 #endif  // KML_DOM_ABSTRACTLATLONBOX_H__
132