summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-06-15 18:30:39 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-06-15 18:30:39 -0700
commitbd0bf294bf1e350b184e54a824430c911dd66b9b (patch)
treed7c643cf197a8263fb1880ce73d034da253efe4c /include
parente75e538ddbb1dad0baad02576df86f6b8eb1510f (diff)
downloadqtlocation-mapboxgl-bd0bf294bf1e350b184e54a824430c911dd66b9b.tar.gz
squash of #1655: shape annotations support for core & iOS
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/ios/MGLAnnotation.h2
-rw-r--r--include/mbgl/ios/MGLMapView.h29
-rw-r--r--include/mbgl/ios/MGLMultiPoint.h17
-rw-r--r--include/mbgl/ios/MGLOverlay.h31
-rw-r--r--include/mbgl/ios/MGLPointAnnotation.h12
-rw-r--r--include/mbgl/ios/MGLPolygon.h17
-rw-r--r--include/mbgl/ios/MGLPolyline.h17
-rw-r--r--include/mbgl/ios/MGLShape.h14
-rw-r--r--include/mbgl/ios/MGLTypes.h9
-rw-r--r--include/mbgl/ios/MapboxGL.h6
-rw-r--r--include/mbgl/map/map.hpp26
-rw-r--r--include/mbgl/style/style_properties.hpp114
-rw-r--r--include/mbgl/style/types.hpp210
-rw-r--r--include/mbgl/util/geo.hpp14
14 files changed, 509 insertions, 9 deletions
diff --git a/include/mbgl/ios/MGLAnnotation.h b/include/mbgl/ios/MGLAnnotation.h
index 0d45f15e44..70460f6492 100644
--- a/include/mbgl/ios/MGLAnnotation.h
+++ b/include/mbgl/ios/MGLAnnotation.h
@@ -4,7 +4,7 @@
NS_ASSUME_NONNULL_BEGIN
-/** The MGLAnnotation protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.
+/** The `MGLAnnotation` protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.
*
* An object that adopts this protocol must implement the `coordinate` property. The other methods of this protocol are optional. */
@protocol MGLAnnotation <NSObject>
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index 29cb682713..f59aa7269d 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -6,6 +6,9 @@
NS_ASSUME_NONNULL_BEGIN
@class MGLUserLocation;
+@class MGLPolyline;
+@class MGLPolygon;
+@class MGLShape;
@protocol MGLMapViewDelegate;
@protocol MGLAnnotation;
@@ -304,6 +307,30 @@ IB_DESIGNABLE
* @return The marker symbol to display for the specified annotation or `nil` if you want to display the default symbol. */
- (nullable NSString *)mapView:(MGLMapView *)mapView symbolNameForAnnotation:(id <MGLAnnotation>)annotation;
+/** Returns the alpha value to use when rendering a shape annotation. Defaults to `1.0`.
+* @param mapView The map view rendering the shape annotation.
+* @param annotation The annotation being rendered.
+* @return An alpha value between `0` and `1.0`. */
+- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation;
+
+/** Returns the stroke color to use when rendering a shape annotation. Defaults to black.
+* @param mapView The map view rendering the shape annotation.
+* @param annotation The annotation being rendered.
+* @return A color to use for the shape outline. */
+- (UIColor *)mapView:(MGLMapView *)mapView strokeColorForShapeAnnotation:(MGLShape *)annotation;
+
+/** Returns the fill color to use when rendering a polygon annotation. Defaults to blue.
+* @param mapView The map view rendering the polygon annotation.
+* @param annotation The annotation being rendered.
+* @return A color to use for the polygon interior. */
+- (UIColor *)mapView:(MGLMapView *)mapView fillColorForPolygonAnnotation:(MGLPolygon *)annotation;
+
+/** Returns the line width to use when rendering a polyline annotation. Defaults to `3.0`.
+* @param mapView The map view rendering the polygon annotation.
+* @param annotation The annotation being rendered.
+* @return A line width for the polyline. */
+- (CGFloat)mapView:(MGLMapView *)mapView lineWidthForPolylineAnnotation:(MGLPolyline *)annotation;
+
/** Returns a Boolean value indicating whether the annotation is able to display extra information in a callout bubble.
*
* If the value returned is `YES`, a standard callout bubble is shown when the user taps a selected annotation. The callout uses the title and subtitle text from the associated annotation object. If there is no title text, though, the annotation will not show a callout. The callout also displays any custom callout views returned by the delegate for the left and right callout accessory views.
@@ -371,6 +398,8 @@ IB_DESIGNABLE
#pragma mark - Tracking the User Location
+/** @name Tracking the User Location */
+
/** Tells the delegate that the map view will begin tracking the user’s location.
*
* This method is called when the value of the showsUserLocation property changes to `YES`.
diff --git a/include/mbgl/ios/MGLMultiPoint.h b/include/mbgl/ios/MGLMultiPoint.h
new file mode 100644
index 0000000000..8da956b539
--- /dev/null
+++ b/include/mbgl/ios/MGLMultiPoint.h
@@ -0,0 +1,17 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLShape.h"
+
+/** The `MGLMultiPoint` class is an abstract superclass used to define shapes composed of multiple points. You should not create instances of this class directly. Instead, you should create instances of the `MGLPolyline` or `MGLPolygon` classes. However, you can use the method and properties of this class to access information about the specific points associated with the line or polygon. */
+@interface MGLMultiPoint : MGLShape
+
+/** The number of points associated with the shape. (read-only) */
+@property (nonatomic, readonly) NSUInteger pointCount;
+
+/** Retrieves one or more coordinates associated with the shape.
+* @param coords On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data.
+* @param range The range of points you want. The `location` field indicates the first point you are requesting, with `0` being the first point, `1` being the second point, and so on. The `length` field indicates the number of points you want. The array in _`coords`_ must be large enough to accommodate the number of requested coordinates. */
+- (void)getCoordinates:(CLLocationCoordinate2D *)coords range:(NSRange)range;
+
+@end
diff --git a/include/mbgl/ios/MGLOverlay.h b/include/mbgl/ios/MGLOverlay.h
new file mode 100644
index 0000000000..686aefc2be
--- /dev/null
+++ b/include/mbgl/ios/MGLOverlay.h
@@ -0,0 +1,31 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLAnnotation.h"
+#import "MGLTypes.h"
+
+/** The `MGLOverlay` protocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. For example, overlays can take the form of common shapes such as rectangles and circles. They can also describe polygons and other complex shapes.
+*
+* You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. Mapbox GL defines several concrete classes that conform to this protocol and define standard shapes.
+*
+* Because overlays are also annotations, they have similar usage pattern to annotations. When added to a map view using the `addOverlay:` method, that view detects whenever the overlay’s defined region intersects the visible portion of the map. At that point, the map view asks its delegate to provide a special overlay view to draw the visual representation of the overlay. If you add an overlay to a map view as an annotation instead, it is treated as an annotation with a single point. */
+@protocol MGLOverlay <MGLAnnotation>
+
+/* The approximate center point of the overlay area. (required) (read-only)
+*
+* This point is typically set to the center point of the map’s bounding rectangle. It is used as the anchor point for any callouts displayed for the annotation. */
+@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
+
+/** The cooordinate rectangle that encompasses the overlay. (required) (read-only)
+*
+* This property contains the smallest rectangle that completely encompasses the overlay. Implementers of this protocol must set this area when implementing their overlay class, and after setting it, you must not change it. */
+@property (nonatomic, readonly) MGLCoordinateBounds overlayBounds;
+
+/** Returns a Boolean indicating whether the specified rectangle intersects the receiver’s shape.
+*
+* You can implement this method to provide more specific bounds checking for an overlay. If you do not implement it, the bounding rectangle is used to detect intersections.
+* @param overlayBounds The rectangle to intersect with the receiver’s area.
+* @return `YES` if any part of the map rectangle intersects the receiver’s shape or `NO` if it does not. */
+- (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds;
+
+@end
diff --git a/include/mbgl/ios/MGLPointAnnotation.h b/include/mbgl/ios/MGLPointAnnotation.h
new file mode 100644
index 0000000000..d3d1a8f0e9
--- /dev/null
+++ b/include/mbgl/ios/MGLPointAnnotation.h
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLShape.h"
+
+/** The `MGLPointAnnotation` class defines a concrete annotation object located at a specified point. You can use this class, rather than define your own, in situations where all you want to do is associate a point on the map with a title. */
+@interface MGLPointAnnotation : MGLShape
+
+/** The coordinate point of the annotation, specified as a latitude and longitude. */
+@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
+
+@end
diff --git a/include/mbgl/ios/MGLPolygon.h b/include/mbgl/ios/MGLPolygon.h
new file mode 100644
index 0000000000..bd6907dbe7
--- /dev/null
+++ b/include/mbgl/ios/MGLPolygon.h
@@ -0,0 +1,17 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLMultiPoint.h"
+#import "MGLOverlay.h"
+
+/** The `MGLPolygon` class represents a shape consisting of one or more points that define a closed polygon. The points are connected end-to-end in the order they are provided. The first and last points are connected to each other to create the closed shape. */
+@interface MGLPolygon : MGLMultiPoint <MGLOverlay>
+
+/** Creates and returns an `MGLPolygon` object from the specified set of coordinates.
+* @param coords The array of coordinates defining the shape. The data in this array is copied to the new object.
+* @param count The number of items in the _`coords`_ array.
+* @return A new polygon object. */
++ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords
+ count:(NSUInteger)count;
+
+@end
diff --git a/include/mbgl/ios/MGLPolyline.h b/include/mbgl/ios/MGLPolyline.h
new file mode 100644
index 0000000000..a49fae07c6
--- /dev/null
+++ b/include/mbgl/ios/MGLPolyline.h
@@ -0,0 +1,17 @@
+#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
+
+#import "MGLMultiPoint.h"
+#import "MGLOverlay.h"
+
+/** The `MGLPolyline` class represents a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. */
+@interface MGLPolyline : MGLMultiPoint <MGLOverlay>
+
+/** Creates and returns an `MGLPolygon` object from the specified set of coordinates.
+* @param coords The array of coordinates defining the shape. The data in this array is copied to the new object.
+* @param count The number of items in the _`coords`_ array.
+* @return A new polyline object. */
++ (instancetype)polylineWithCoordinates:(CLLocationCoordinate2D *)coords
+ count:(NSUInteger)count;
+
+@end
diff --git a/include/mbgl/ios/MGLShape.h b/include/mbgl/ios/MGLShape.h
new file mode 100644
index 0000000000..6693d2b302
--- /dev/null
+++ b/include/mbgl/ios/MGLShape.h
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLAnnotation.h"
+
+/** The `MGLShape` class is an abstract class that defines the basic properties for all shape-based annotation objects. This class must be subclassed and cannot be used as is. Subclasses are responsible for defining the geometry of the shape and providing an appropriate value for the coordinate property inherited from the `MGLAnnotation` protocol. */
+@interface MGLShape : NSObject <MGLAnnotation>
+
+/** The title of the shape annotation. The default value of this property is `nil`. */
+@property (nonatomic, copy) NSString *title;
+
+/** The subtitle of the shape annotation. The default value of this property is `nil`. */
+@property (nonatomic, copy) NSString *subtitle;
+
+@end
diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h
index 6b56b47add..3d3892610a 100644
--- a/include/mbgl/ios/MGLTypes.h
+++ b/include/mbgl/ios/MGLTypes.h
@@ -1,4 +1,5 @@
#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
#if !__has_feature(nullability)
#define NS_ASSUME_NONNULL_BEGIN
@@ -13,8 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
extern NSString * const MGLErrorDomain;
/** The mode used to track the user location on the map. */
-typedef NS_ENUM(NSUInteger, MGLUserTrackingMode)
-{
+typedef NS_ENUM(NSUInteger, MGLUserTrackingMode) {
/** The map does not follow the user location. */
MGLUserTrackingModeNone = 0,
/** The map follows the user location. */
@@ -23,4 +23,9 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingMode)
MGLUserTrackingModeFollowWithHeading
};
+typedef struct {
+ CLLocationCoordinate2D sw;
+ CLLocationCoordinate2D ne;
+} MGLCoordinateBounds;
+
NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MapboxGL.h b/include/mbgl/ios/MapboxGL.h
index a6d23d3280..d3b032b9c9 100644
--- a/include/mbgl/ios/MapboxGL.h
+++ b/include/mbgl/ios/MapboxGL.h
@@ -1,5 +1,11 @@
#import "MGLAccountManager.h"
#import "MGLAnnotation.h"
#import "MGLMapView.h"
+#import "MGLMultiPoint.h"
+#import "MGLOverlay.h"
+#import "MGLPointAnnotation.h"
+#import "MGLPolygon.h"
+#import "MGLPolyline.h"
+#import "MGLShape.h"
#import "MGLTypes.h"
#import "MGLUserLocation.h"
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 5535dbcc91..e7474005e4 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -4,6 +4,7 @@
#include <mbgl/util/chrono.hpp>
#include <mbgl/map/update.hpp>
#include <mbgl/map/mode.hpp>
+#include <mbgl/style/style_properties.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/vec.hpp>
@@ -13,6 +14,7 @@
#include <functional>
#include <vector>
#include <memory>
+#include <unordered_map>
namespace mbgl {
@@ -26,6 +28,16 @@ namespace util {
template <class T> class Thread;
}
+enum class AnnotationType : uint8_t {
+ Any = 0,
+ Point = 1 << 0,
+ Shape = 1 << 1,
+};
+
+using AnnotationIDs = std::vector<uint32_t>;
+using AnnotationSegment = std::vector<LatLng>;
+using AnnotationSegments = std::vector<AnnotationSegment>;
+
class Map : private util::noncopyable {
friend class View;
@@ -112,12 +124,16 @@ public:
void setDefaultPointAnnotationSymbol(const std::string&);
double getTopOffsetPixelsForAnnotationSymbol(const std::string&);
uint32_t addPointAnnotation(const LatLng&, const std::string& symbol);
- std::vector<uint32_t> addPointAnnotations(const std::vector<LatLng>&,
- const std::vector<std::string>& symbols);
+ AnnotationIDs addPointAnnotations(const AnnotationSegment&,
+ const std::vector<std::string>& symbols);
+ uint32_t addShapeAnnotation(const AnnotationSegments&,
+ const StyleProperties&);
+ AnnotationIDs addShapeAnnotations(const std::vector<AnnotationSegments>&,
+ const std::vector<StyleProperties>&);
void removeAnnotation(uint32_t);
- void removeAnnotations(const std::vector<uint32_t>&);
- std::vector<uint32_t> getAnnotationsInBounds(const LatLngBounds&);
- LatLngBounds getBoundsForAnnotations(const std::vector<uint32_t>&);
+ void removeAnnotations(const AnnotationIDs&);
+ AnnotationIDs getAnnotationsInBounds(const LatLngBounds&, const AnnotationType& = AnnotationType::Any);
+ LatLngBounds getBoundsForAnnotations(const AnnotationIDs&);
// Memory
void setSourceTileCacheSize(size_t);
diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp
new file mode 100644
index 0000000000..9ab528586f
--- /dev/null
+++ b/include/mbgl/style/style_properties.hpp
@@ -0,0 +1,114 @@
+#ifndef MBGL_STYLE_STYLE_PROPERTIES
+#define MBGL_STYLE_STYLE_PROPERTIES
+
+#include <mbgl/util/variant.hpp>
+#include <mbgl/style/types.hpp>
+
+#include <array>
+#include <string>
+#include <type_traits>
+#include <memory>
+#include <vector>
+
+namespace mbgl {
+
+struct FillProperties {
+ FillProperties() {}
+ bool antialias = true;
+ float opacity = 1.0f;
+ Color fill_color = {{ 0, 0, 0, 1 }};
+ Color stroke_color = {{ 0, 0, 0, -1 }};
+ std::array<float, 2> translate = {{ 0, 0 }};
+ TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
+ Faded<std::string> image;
+
+ inline bool isVisible() const {
+ return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0);
+ }
+};
+
+struct LineProperties {
+ inline LineProperties() {}
+ float opacity = 1.0f;
+ Color color = {{ 0, 0, 0, 1 }};
+ std::array<float, 2> translate = {{ 0, 0 }};
+ TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
+ float width = 1;
+ float gap_width = 0;
+ float blur = 0;
+ Faded<std::vector<float>> dash_array;
+ float dash_line_width = 1;
+ Faded<std::string> image;
+
+ inline bool isVisible() const {
+ return opacity > 0 && color[3] > 0 && width > 0;
+ }
+};
+
+struct SymbolProperties {
+ inline SymbolProperties() {}
+
+ struct {
+ float opacity = 1.0f;
+ float size = 1.0f;
+ Color color = {{ 0, 0, 0, 1 }};
+ Color halo_color = {{ 0, 0, 0, 0 }};
+ float halo_width = 0.0f;
+ float halo_blur = 0.0f;
+ std::array<float, 2> translate = {{ 0, 0 }};
+ TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
+ } icon;
+
+ struct {
+ float opacity = 1.0f;
+ float size = 16.0f;
+ Color color = {{ 0, 0, 0, 1 }};
+ Color halo_color = {{ 0, 0, 0, 0 }};
+ float halo_width = 0.0f;
+ float halo_blur = 0.0f;
+ std::array<float, 2> translate = {{ 0, 0 }};
+ TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
+ } text;
+
+ inline bool isVisible() const {
+ return (icon.opacity > 0 && (icon.color[3] > 0 || icon.halo_color[3] > 0) && icon.size > 0) ||
+ (text.opacity > 0 && (text.color[3] > 0 || text.halo_color[3] > 0) && text.size > 0);
+ }
+};
+
+struct RasterProperties {
+ inline RasterProperties() {}
+ float opacity = 1.0f;
+ float hue_rotate = 0.0f;
+ std::array<float, 2> brightness = {{ 0, 1 }};
+ float saturation = 0.0f;
+ float contrast = 0.0f;
+ float fade = 0.0f;
+
+ inline bool isVisible() const {
+ return opacity > 0;
+ }
+};
+
+struct BackgroundProperties {
+ inline BackgroundProperties() {}
+ float opacity = 1.0f;
+ Color color = {{ 0, 0, 0, 1 }};
+ Faded<std::string> image;
+};
+
+typedef mapbox::util::variant<
+ FillProperties,
+ LineProperties,
+ SymbolProperties,
+ RasterProperties,
+ BackgroundProperties,
+ std::false_type
+> StyleProperties;
+
+template <typename T>
+const T &defaultStyleProperties();
+
+}
+
+#endif
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
new file mode 100644
index 0000000000..f6ffcd6865
--- /dev/null
+++ b/include/mbgl/style/types.hpp
@@ -0,0 +1,210 @@
+#ifndef MBGL_STYLE_TYPES
+#define MBGL_STYLE_TYPES
+
+#include <mbgl/util/enum.hpp>
+
+#include <string>
+#include <array>
+
+namespace mbgl {
+
+// Stores a premultiplied color, with all four channels ranging from 0..1
+typedef std::array<float, 4> Color;
+
+
+template <typename T>
+struct Faded {
+ T from;
+ float fromScale;
+ T to;
+ float toScale;
+ float t;
+};
+
+// -------------------------------------------------------------------------------------------------
+
+enum class StyleLayerType : uint8_t {
+ Unknown,
+ Fill,
+ Line,
+ Symbol,
+ Raster,
+ Background
+};
+
+MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, {
+ { StyleLayerType::Unknown, "unknown" },
+ { StyleLayerType::Fill, "fill" },
+ { StyleLayerType::Line, "line" },
+ { StyleLayerType::Symbol, "symbol" },
+ { StyleLayerType::Raster, "raster" },
+ { StyleLayerType::Background, "background" },
+ { StyleLayerType(-1), "unknown" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class SourceType : uint8_t {
+ Vector,
+ Raster,
+ GeoJSON,
+ Video,
+ Annotations
+};
+
+MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, {
+ { SourceType::Vector, "vector" },
+ { SourceType::Raster, "raster" },
+ { SourceType::GeoJSON, "geojson" },
+ { SourceType::Video, "video" },
+ { SourceType::Annotations, "annotations" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class VisibilityType : bool {
+ Visible,
+ None,
+};
+
+MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
+ { VisibilityType::Visible, "visible" },
+ { VisibilityType::None, "none" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class CapType : uint8_t {
+ Round,
+ Butt,
+ Square,
+};
+
+MBGL_DEFINE_ENUM_CLASS(CapTypeClass, CapType, {
+ { CapType::Round, "round" },
+ { CapType::Butt, "butt" },
+ { CapType::Square, "square" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class JoinType : uint8_t {
+ Miter,
+ Bevel,
+ Round,
+ FlipBevel
+};
+
+MBGL_DEFINE_ENUM_CLASS(JoinTypeClass, JoinType, {
+ { JoinType::Miter, "miter" },
+ { JoinType::Bevel, "bevel" },
+ { JoinType::Round, "round" },
+ { JoinType::FlipBevel, "flipbevel" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TranslateAnchorType : bool {
+ Map,
+ Viewport
+};
+
+MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
+ { TranslateAnchorType::Map, "map" },
+ { TranslateAnchorType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class RotateAnchorType : bool {
+ Map,
+ Viewport,
+};
+
+MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
+ { RotateAnchorType::Map, "map" },
+ { RotateAnchorType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class PlacementType : bool {
+ Point,
+ Line,
+};
+
+MBGL_DEFINE_ENUM_CLASS(PlacementTypeClass, PlacementType, {
+ { PlacementType::Point, "point" },
+ { PlacementType::Line, "line" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class RotationAlignmentType : bool {
+ Map,
+ Viewport,
+};
+
+MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
+ { RotationAlignmentType::Map, "map" },
+ { RotationAlignmentType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextJustifyType : uint8_t {
+ Center,
+ Left,
+ Right
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
+ { TextJustifyType::Center, "center" },
+ { TextJustifyType::Left, "left" },
+ { TextJustifyType::Right, "right" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextAnchorType : uint8_t {
+ Center,
+ Left,
+ Right,
+ Top,
+ Bottom,
+ TopLeft,
+ TopRight,
+ BottomLeft,
+ BottomRight
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
+ { TextAnchorType::Center, "center" },
+ { TextAnchorType::Left, "left" },
+ { TextAnchorType::Right, "right" },
+ { TextAnchorType::Top, "top" },
+ { TextAnchorType::Bottom, "bottom" },
+ { TextAnchorType::TopLeft, "top-left" },
+ { TextAnchorType::TopRight, "top-right" },
+ { TextAnchorType::BottomLeft, "bottom-left" },
+ { TextAnchorType::BottomRight, "bottom-right" }
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextTransformType : uint8_t {
+ None,
+ Uppercase,
+ Lowercase,
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
+ { TextTransformType::None, "none" },
+ { TextTransformType::Uppercase, "uppercase" },
+ { TextTransformType::Lowercase, "lowercase" },
+});
+
+}
+
+#endif
+
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index ff13726803..1f073ded8f 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -41,12 +41,24 @@ struct LatLngBounds {
if (point.longitude > ne.longitude) ne.longitude = point.longitude;
}
- inline bool contains(const LatLng& point) {
+ inline void extend(const LatLngBounds& bounds) {
+ extend(bounds.sw);
+ extend(bounds.ne);
+ }
+
+ inline bool contains(const LatLng& point) const {
return (point.latitude >= sw.latitude &&
point.latitude <= ne.latitude &&
point.longitude >= sw.longitude &&
point.longitude <= ne.longitude);
}
+
+ inline bool intersects(const LatLngBounds area) const {
+ return (area.ne.latitude > sw.latitude &&
+ area.sw.latitude < ne.latitude &&
+ area.ne.longitude > sw.longitude &&
+ area.sw.longitude < ne.longitude);
+ }
};
}