1 #include <mbgl/style/conversion/coordinate.hpp>
2 
3 namespace mbgl {
4 namespace style {
5 namespace conversion {
6 
operator ()(const Convertible & value,Error & error) const7 optional<LatLng> Converter<LatLng>::operator() (const Convertible& value, Error& error) const {
8     if (!isArray(value) || arrayLength(value) < 2 ) {
9         error = { "coordinate array must contain numeric longitude and latitude values" };
10         return {};
11     }
12     //Style spec uses GeoJSON convention for specifying coordinates
13     optional<double> latitude = toDouble(arrayMember(value, 1));
14     optional<double> longitude = toDouble(arrayMember(value, 0));
15 
16     if (!latitude || !longitude) {
17         error = { "coordinate array must contain numeric longitude and latitude values" };
18         return {};
19     }
20     if (*latitude < -90 || *latitude > 90 ){
21         error = { "coordinate latitude must be between -90 and 90" };
22         return {};
23     }
24     return LatLng(*latitude, *longitude);
25 }
26 
27 } // namespace conversion
28 } // namespace style
29 } // namespace mbgl
30