Merge remote-tracking branch 'origin/master' into new-labelling
Conflicts: src/mbgl/map/source.cpp src/mbgl/map/source.hpp src/mbgl/map/tile_data.cpp src/mbgl/map/tile_parser.cpp src/mbgl/map/vector_tile_data.cpp src/mbgl/renderer/painter.cpp src/mbgl/renderer/symbol_bucket.cpp src/mbgl/text/glyph.hpp src/mbgl/text/glyph_store.cpp src/mbgl/text/placement.cpp test/suite
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
/** Certain Mapbox plans require the collection of user metrics. If you aren't using a preference switch in an existing or new `Settings.bundle` in your application, set this value to `YES` to indicate that you are providing a metrics opt-out for users within your app's interface directly.
|
||||
* @param showsOptOut Whether your application's interface provides a user opt-out preference. The default value is `NO`, meaning a `Settings.bundle` is expected for providing a user opt-out preference. */
|
||||
+ (void)setMapboxMetricsEnabledSettingShownInApp:(BOOL)showsOptOut;
|
||||
+ (void)setMapboxMetricsEnabledSettingShownInApp:(BOOL)showsOptOut __attribute__((unavailable("Set MGLMapboxMetricsEnabledSettingShownInApp in Info.plist.")));
|
||||
|
||||
/** Whether in-app user metrics opt-out is configured. If set to the default value of `NO`, a user opt-out preference is expected in a `Settings.bundle` that shows in the application's section within the system Settings app. */
|
||||
+ (BOOL)mapboxMetricsEnabledSettingShownInApp;
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
// inspectables declared in MGLMapView.h are always sorted before those in
|
||||
// MGLMapView+IBAdditions.h, due to ASCII sort order.
|
||||
|
||||
@property (nonatomic) IBInspectable NSString *accessToken;
|
||||
@property (nonatomic) IBInspectable NSString *mapID;
|
||||
@property (nonatomic) IBInspectable NSString *styleID;
|
||||
|
||||
// Convenience properties related to the initial viewport. These properties
|
||||
// are not meant to be used outside of Interface Builder. latitude and longitude
|
||||
|
||||
@@ -20,30 +20,25 @@ IB_DESIGNABLE
|
||||
|
||||
/** @name Initializing a Map View */
|
||||
|
||||
/** Initialize a map view with the default style, given frame, and access token set in MapboxGL singleton.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
/** Initializes and returns a newly allocated map view with the specified frame and the default style.
|
||||
* @param frame The frame for the view, measured in points.
|
||||
* @return An initialized map view. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame;
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken __attribute__((unavailable("Use -initWithFrame:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:].")));
|
||||
|
||||
/** Initialize a map view with the default style and a given frame and access token.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @param accessToken A Mapbox API access token.
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken;
|
||||
|
||||
/** Initialize a map view with a given frame, access token, and style URL.
|
||||
* @param frame The frame with which to initialize the map view.
|
||||
* @param accessToken A Mapbox API access token.
|
||||
* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`).
|
||||
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL;
|
||||
/** Initializes and returns a newly allocated map view with the specified frame and style URL.
|
||||
* @param frame The frame for the view, measured in points.
|
||||
* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`).
|
||||
* @return An initialized map view. */
|
||||
- (instancetype)initWithFrame:(CGRect)frame styleURL:(NSURL *)styleURL;
|
||||
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL __attribute__((unavailable("Use -initWithFrame:styleURL:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:].")));
|
||||
|
||||
#pragma mark - Authorizing Access
|
||||
|
||||
/** @name Authorizing Access */
|
||||
|
||||
/** Mapbox API access token for the map view. */
|
||||
@property (nonatomic) NSString *accessToken;
|
||||
@property (nonatomic) NSString *accessToken __attribute__((unavailable("Use +[MGLAccountManager accessToken] and +[MGLAccountManager setAccessToken:].")));
|
||||
|
||||
#pragma mark - Managing Constraints
|
||||
|
||||
@@ -162,12 +157,13 @@ IB_DESIGNABLE
|
||||
|
||||
/** @name Styling the Map */
|
||||
|
||||
/** Mapbox map ID of the style currently displayed in the receiver, or `nil` if the style does not have a map ID.
|
||||
/** Mapbox ID of the style currently displayed in the receiver, or `nil` if the style does not have an ID.
|
||||
*
|
||||
* The style may lack a map ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases.
|
||||
* The style may lack an ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases.
|
||||
*
|
||||
* To display the default style, set this property to `nil`. */
|
||||
@property (nonatomic) NSString *mapID;
|
||||
@property (nonatomic) NSString *styleID;
|
||||
@property (nonatomic) NSString *mapID __attribute__((unavailable("Use styleID.")));
|
||||
|
||||
/** Returns the URLs to the styles bundled with the library. */
|
||||
- (NSArray *)bundledStyleURLs;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
// Register a callback that will get called (on the render thread) when all resources have
|
||||
// been loaded and a complete render occurs.
|
||||
using StillImageCallback = std::function<void(std::unique_ptr<const StillImage>)>;
|
||||
using StillImageCallback = std::function<void(std::exception_ptr, std::unique_ptr<const StillImage>)>;
|
||||
void renderStill(StillImageCallback callback);
|
||||
|
||||
// Triggers a synchronous or asynchronous render.
|
||||
@@ -99,10 +99,6 @@ public:
|
||||
uint16_t getWidth() const;
|
||||
uint16_t getHeight() const;
|
||||
|
||||
// API
|
||||
void setAccessToken(const std::string &token);
|
||||
std::string getAccessToken() const;
|
||||
|
||||
// Projection
|
||||
void getWorldBoundsMeters(ProjectedMeters &sw, ProjectedMeters &ne) const;
|
||||
void getWorldBoundsLatLng(LatLng &sw, LatLng &ne) const;
|
||||
|
||||
@@ -28,24 +28,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
#import <sys/socket.h>
|
||||
#import <netinet/in.h>
|
||||
#import <netinet6/in6.h>
|
||||
#import <arpa/inet.h>
|
||||
#import <ifaddrs.h>
|
||||
#import <netdb.h>
|
||||
|
||||
/**
|
||||
* Does ARC support GCD objects?
|
||||
* It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
|
||||
*
|
||||
* @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
|
||||
**/
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
||||
#else
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
|
||||
@@ -65,28 +47,29 @@ typedef NS_ENUM(NSInteger, NetworkStatus) {
|
||||
ReachableViaWWAN = 1
|
||||
};
|
||||
|
||||
@class Reachability;
|
||||
@class MGLReachability;
|
||||
|
||||
typedef void (^NetworkReachable)(Reachability * reachability);
|
||||
typedef void (^NetworkUnreachable)(Reachability * reachability);
|
||||
typedef void (^NetworkReachable)(MGLReachability * reachability);
|
||||
typedef void (^NetworkUnreachable)(MGLReachability * reachability);
|
||||
|
||||
@interface Reachability : NSObject
|
||||
|
||||
@interface MGLReachability : NSObject
|
||||
|
||||
@property (nonatomic, copy) NetworkReachable reachableBlock;
|
||||
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
|
||||
|
||||
|
||||
@property (nonatomic, assign) BOOL reachableOnWWAN;
|
||||
|
||||
+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
|
||||
|
||||
+(instancetype)reachabilityWithHostname:(NSString*)hostname;
|
||||
// This is identical to the function above, but is here to maintain
|
||||
//compatibility with Apples original code. (see .m)
|
||||
+(Reachability*)reachabilityWithHostName:(NSString*)hostname;
|
||||
+(Reachability*)reachabilityForInternetConnection;
|
||||
+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
|
||||
+(Reachability*)reachabilityForLocalWiFi;
|
||||
+(instancetype)reachabilityWithHostName:(NSString*)hostname;
|
||||
+(instancetype)reachabilityForInternetConnection;
|
||||
+(instancetype)reachabilityWithAddress:(void *)hostAddress;
|
||||
+(instancetype)reachabilityForLocalWiFi;
|
||||
|
||||
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
|
||||
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
|
||||
|
||||
-(BOOL)startNotifier;
|
||||
-(void)stopNotifier;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef MBGL_UTIL_IMAGE_READER_HPP
|
||||
#define MBGL_UTIL_IMAGE_READER_HPP
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl { namespace util {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ enum class Event : uint8_t {
|
||||
ParseStyle,
|
||||
ParseTile,
|
||||
Render,
|
||||
ResourceLoader,
|
||||
Database,
|
||||
HttpRequest,
|
||||
Sprite,
|
||||
@@ -46,6 +47,7 @@ MBGL_DEFINE_ENUM_CLASS(EventClass, Event, {
|
||||
{ Event::ParseStyle, "ParseStyle" },
|
||||
{ Event::ParseTile, "ParseTile" },
|
||||
{ Event::Render, "Render" },
|
||||
{ Event::ResourceLoader, "ResourceLoader" },
|
||||
{ Event::Database, "Database" },
|
||||
{ Event::HttpRequest, "HttpRequest" },
|
||||
{ Event::Sprite, "Sprite" },
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <mbgl/platform/event.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -15,6 +15,9 @@ public:
|
||||
DefaultFileSource(FileCache *cache, const std::string &root = "");
|
||||
~DefaultFileSource() override;
|
||||
|
||||
void setAccessToken(const std::string& t) { accessToken = t; }
|
||||
std::string getAccessToken() const { return accessToken; }
|
||||
|
||||
// FileSource API
|
||||
Request* request(const Resource&, uv_loop_t*, Callback) override;
|
||||
void cancel(Request*) override;
|
||||
@@ -23,6 +26,7 @@ public:
|
||||
class Impl;
|
||||
private:
|
||||
const std::unique_ptr<util::Thread<Impl>> thread;
|
||||
std::string accessToken;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "resource.hpp"
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -9,10 +9,12 @@ namespace mbgl {
|
||||
struct Resource {
|
||||
enum Kind : uint8_t {
|
||||
Unknown = 0,
|
||||
Tile = 1,
|
||||
Glyphs = 2,
|
||||
Image = 3,
|
||||
JSON = 4,
|
||||
Style,
|
||||
Source,
|
||||
Tile,
|
||||
Glyphs,
|
||||
JSON,
|
||||
Image
|
||||
};
|
||||
|
||||
const Kind kind;
|
||||
|
||||
@@ -11,6 +11,11 @@ struct Exception : std::runtime_error {
|
||||
inline Exception(const std::string &msg) : std::runtime_error(msg) {}
|
||||
};
|
||||
|
||||
struct GlyphRangeLoadingException : Exception {
|
||||
inline GlyphRangeLoadingException(const char *msg) : Exception(msg) {}
|
||||
inline GlyphRangeLoadingException(const std::string &msg) : Exception(msg) {}
|
||||
};
|
||||
|
||||
struct MisuseException : Exception {
|
||||
inline MisuseException(const char *msg) : Exception(msg) {}
|
||||
inline MisuseException(const std::string &msg) : Exception(msg) {}
|
||||
@@ -21,6 +26,21 @@ struct ShaderException : Exception {
|
||||
inline ShaderException(const std::string &msg) : Exception(msg) {}
|
||||
};
|
||||
|
||||
struct SourceLoadingException : Exception {
|
||||
inline SourceLoadingException(const char *msg) : Exception(msg) {}
|
||||
inline SourceLoadingException(const std::string &msg) : Exception(msg) {}
|
||||
};
|
||||
|
||||
struct SpriteLoadingException : Exception {
|
||||
inline SpriteLoadingException(const char *msg) : Exception(msg) {}
|
||||
inline SpriteLoadingException(const std::string &msg) : Exception(msg) {}
|
||||
};
|
||||
|
||||
struct TileLoadingException : Exception {
|
||||
inline TileLoadingException(const char *msg) : Exception(msg) {}
|
||||
inline TileLoadingException(const std::string &msg) : Exception(msg) {}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
30
include/mbgl/util/exclusive.hpp
Normal file
30
include/mbgl/util/exclusive.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef MBGL_UTIL_EXCLUSIVE
|
||||
#define MBGL_UTIL_EXCLUSIVE
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
template <class T>
|
||||
class exclusive {
|
||||
public:
|
||||
inline exclusive(T* val, std::unique_ptr<std::lock_guard<std::mutex>> mtx) : ptr(val), lock(std::move(mtx)) {}
|
||||
|
||||
inline T* operator->() { return ptr; }
|
||||
inline const T* operator->() const { return ptr; }
|
||||
inline T* operator*() { return ptr; }
|
||||
inline const T* operator*() const { return ptr; }
|
||||
|
||||
private:
|
||||
T *ptr;
|
||||
std::unique_ptr<std::lock_guard<std::mutex>> lock;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace util
|
||||
} // end namespace mbgl
|
||||
|
||||
#endif
|
||||
@@ -8,29 +8,6 @@
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
// C++14 backfill based on http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
|
||||
|
||||
namespace detail {
|
||||
template<class T> struct unique_type { typedef ::std::unique_ptr<T> single; };
|
||||
template<class T> struct unique_type<T[]> { typedef ::std::unique_ptr<T[]> unknown_bound; };
|
||||
template<class T, size_t size> struct unique_type<T[size]> { typedef void known_bound; };
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::single make_unique(Args&&... args) {
|
||||
return ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename detail::unique_type<T>::unknown_bound make_unique(size_t size) {
|
||||
return ::std::unique_ptr<T>(new typename ::std::remove_extent<T>::type[size]());
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::known_bound make_unique(Args&&...) = delete;
|
||||
|
||||
|
||||
|
||||
template <typename Container, typename ForwardIterator, typename Predicate>
|
||||
void erase_if(Container &container, ForwardIterator it, const ForwardIterator end, Predicate pred) {
|
||||
while (it != end) {
|
||||
|
||||
Reference in New Issue
Block a user