tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Exif / ExifGPSLocation.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef __TIZEN_EXIF_EXIF_GPS_LOCATION_H_
19 #define __TIZEN_EXIF_EXIF_GPS_LOCATION_H_
20
21 #include <string>
22
23 #include <SimpleCoordinates.h>
24
25 #include "ExifUtil.h"
26
27 namespace DeviceAPI {
28 namespace Exif {
29
30 enum GPSLocationDirectionLongitude {
31     GPS_LOCATION_WEST,
32     GPS_LOCATION_EAST
33 };
34
35 enum GPSLocationDirectionLatitude {
36     GPS_LOCATION_NORTH,
37     GPS_LOCATION_SOUTH
38 };
39
40 enum ExifGPSLocationAttributes {
41     EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE = 0,
42     EXIF_GPS_LOCATION_ATTRIBUTE_LONGITUDE_REF,
43     EXIF_GPS_LOCATION_ATTRIBUTE_LATITUDE,
44     EXIF_GPS_LOCATION_ATTRIBUTE_LATITUDE_REF,
45     EXIF_GPS_LOCATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES
46 };
47
48 /**
49  * This class represents Global Coordinate System using
50  * three Rational numbers (as stored in Exif)
51  */
52 struct GCSPosition
53 {
54     GCSPosition();
55     GCSPosition(Rational degrees, Rational minutes, Rational seconds);
56
57     /**
58      * Create GCSPosition from degrees represented as double value
59      */
60     static GCSPosition createFromDouble(double value);
61
62     /**
63      * Verify that all components are valid Rational numbers and
64      * each component is within valid range. Sum of degrees,
65      * minutes and seconds should not be bigger then 180.0
66      */
67     bool isValid() const;
68
69     /**
70      * Return position in degrees
71      */
72     double toDouble() const;
73
74     /**
75      * Return vector of three rationals: dgrees, minutes, seconds
76      */
77     Rationals toRationalsVector() const;
78
79     /**
80      * Return string for debugging purposes
81      */
82     std::string toDebugString() const;
83
84     Rational degrees;
85     Rational minutes;
86     Rational seconds;
87 };
88
89 class ExifGPSLocation
90 {
91 public:
92     ExifGPSLocation();
93
94     void setLongitude(const GCSPosition& longitude);
95     const GCSPosition& getLongitude() const;
96
97     void setLongitudeRef(GPSLocationDirectionLongitude ref);
98     GPSLocationDirectionLongitude getLongitudeRef() const;
99
100     void setLatitude(const GCSPosition& latitude);
101     const GCSPosition& getLatitude() const;
102
103     void setLatitudeRef(GPSLocationDirectionLatitude ref);
104     GPSLocationDirectionLatitude getLatitudeRef() const;
105
106     bool isSet(ExifGPSLocationAttributes attribute) const;
107     void unset(ExifGPSLocationAttributes attribute);
108     void unsetAll();
109
110     /**
111      * Returns true only if all components are set.
112      */
113     bool isComplete() const;
114
115     /**
116      * Returns true only if all components are set and valid.
117      */
118     bool isValid() const;
119
120     /**
121      * Returns null pointer if any information is missing or incorrect
122      */
123     Tizen::SimpleCoordinatesPtr getSimpleCoordinates() const;
124
125     /**
126      * Return true if scoords has been set
127      */
128     bool set(Tizen::SimpleCoordinatesPtr scoords);
129
130 private:
131
132     double getLongitudeValue() const;
133     double getLatitudeValue() const;
134
135     GCSPosition m_longitude;
136     GPSLocationDirectionLongitude m_longitude_ref;
137
138     GCSPosition m_latitude;
139     GPSLocationDirectionLatitude m_latitude_ref;
140
141     bool m_is_set[EXIF_GPS_LOCATION_ATTRIBUTE_NUMBER_OF_ATTRIBUTES];
142 };
143
144 } // Exif
145 } // DeviceAPI
146
147 #endif // __TIZEN_EXIF_EXIF_GPS_LOCATION_H_