Fix trailing whitespaces (#3205)
See https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#trailing-whitespace
This commit is contained in:
@@ -56,7 +56,7 @@ MapLibre welcomes participation and contributions from everyone. Please read [`C
|
||||
|
||||
* Added the `-[MLNOfflinePack setContext:completionHandler:]` method for replacing the data associated with an offline pack, such as a name. ([#288](https://github.com/mapbox/mapbox-gl-native-ios/pull/288))
|
||||
* Added the `MLNOfflineStorage.databasePath` and `MLNOfflineStorage.databaseURL` properties to obtain the path of the database that contains offline packs and the ambient cache. To customize this path, set the `MLNOfflineStorageDatabasePath` in Info.plist. ([#298](https://github.com/mapbox/mapbox-gl-native-ios/pull/298))
|
||||
* Fixed an error that occurred if your implementation of the `-[MLNOfflineStorageDelegate offlineStorage:URLForResourceOfKind:]` method returned a local file URL. ([mapbox/mapbox-gl-native#16428](https://github.com/mapbox/mapbox-gl-native/pull/16428))
|
||||
* Fixed an error that occurred if your implementation of the `-[MLNOfflineStorageDelegate offlineStorage:URLForResourceOfKind:]` method returned a local file URL. ([mapbox/mapbox-gl-native#16428](https://github.com/mapbox/mapbox-gl-native/pull/16428))
|
||||
|
||||
### Other changes
|
||||
|
||||
|
||||
@@ -159,9 +159,9 @@ NSString * const MLNLastMapDebugMaskDefaultsKey = @"MLNLastMapDebugMask";
|
||||
|
||||
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
|
||||
// geo:29.95,-90.066667,3000
|
||||
// geo:29.95,-90.066667?z=14
|
||||
// geo:29.95,-90.066667?z=14
|
||||
// mapboxgl://?center=29.95,-90.066667&zoom=14&bearing=45&pitch=30
|
||||
|
||||
|
||||
NSURLComponents *components = [NSURLComponents componentsWithString:[event paramDescriptorForKeyword:keyDirectObject].stringValue];
|
||||
BOOL isGLURL = [components.scheme isEqualToString:@"mapboxgl"];
|
||||
BOOL isGeoURL = [components.scheme isEqualToString:@"geo"];
|
||||
@@ -184,7 +184,7 @@ NSString * const MLNLastMapDebugMaskDefaultsKey = @"MLNLastMapDebugMask";
|
||||
params[parts[0]] = parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MLNMapCamera *camera = [MLNMapCamera camera];
|
||||
NSString *zoomLevelString = params[@"zoom"] ?: params[@"z"];
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<array>
|
||||
<string>geo</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>15256</string>
|
||||
|
||||
@@ -189,13 +189,13 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
panel.allowedFileTypes = @[@"public.json", @"json", @"geojson"];
|
||||
panel.allowsMultipleSelection = YES;
|
||||
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[panel beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse result) {
|
||||
if (result != NSModalResponseOK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (NSURL *url in panel.URLs) {
|
||||
[weakSelf importFromURL:url];
|
||||
}
|
||||
@@ -204,7 +204,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
|
||||
/**
|
||||
Adds the contents of the GeoJSON file at the given URL to the map.
|
||||
|
||||
|
||||
GeoJSON features are styled according to
|
||||
[simplestyle-spec](https://github.com/mapbox/simplestyle-spec/tree/master/1.1.0/).
|
||||
*/
|
||||
@@ -213,10 +213,10 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MLNShapeSource *source = [[MLNShapeSource alloc] initWithIdentifier:[NSUUID UUID].UUIDString URL:url options:nil];
|
||||
[self.mapView.style addSource:source];
|
||||
|
||||
|
||||
NSString *pointIdentifier = [NSString stringWithFormat:@"%@ marker", source.identifier];
|
||||
MLNSymbolStyleLayer *pointLayer = [[MLNSymbolStyleLayer alloc] initWithIdentifier:pointIdentifier source:source];
|
||||
pointLayer.iconImageName =
|
||||
@@ -227,14 +227,14 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
@"marker-color"];
|
||||
pointLayer.iconAllowsOverlap = [NSExpression expressionForConstantValue:@YES];
|
||||
[style addLayer:pointLayer];
|
||||
|
||||
|
||||
NSString *fillIdentifier = [NSString stringWithFormat:@"%@ fill", source.identifier];
|
||||
MLNFillStyleLayer *fillLayer = [[MLNFillStyleLayer alloc] initWithIdentifier:fillIdentifier source:source];
|
||||
fillLayer.predicate = [NSPredicate predicateWithFormat:@"fill != nil OR %K != nil", @"fill-opacity"];
|
||||
fillLayer.fillColor = [NSExpression expressionWithFormat:@"CAST(mgl_coalesce({fill, '#555555'}), 'NSColor')"];
|
||||
fillLayer.fillOpacity = [NSExpression expressionWithFormat:@"mgl_coalesce({%K, 0.5})", @"fill-opacity"];
|
||||
[style addLayer:fillLayer];
|
||||
|
||||
|
||||
NSString *lineIdentifier = [NSString stringWithFormat:@"%@ stroke", source.identifier];
|
||||
MLNLineStyleLayer *lineLayer = [[MLNLineStyleLayer alloc] initWithIdentifier:lineIdentifier source:source];
|
||||
lineLayer.lineColor = [NSExpression expressionWithFormat:@"CAST(mgl_coalesce({stroke, '#555555'}), 'NSColor')"];
|
||||
@@ -247,10 +247,10 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
|
||||
- (IBAction)takeSnapshot:(id)sender {
|
||||
MLNMapCamera *camera = self.mapView.camera;
|
||||
|
||||
|
||||
MLNMapSnapshotOptions *options = [[MLNMapSnapshotOptions alloc] initWithStyleURL:self.mapView.styleURL camera:camera size:self.mapView.bounds.size];
|
||||
options.zoomLevel = self.mapView.zoomLevel;
|
||||
|
||||
|
||||
// Create and start the snapshotter
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
_snapshotter = [[MLNMapSnapshotter alloc] initWithOptions:options];
|
||||
@@ -268,12 +268,12 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
NSSavePanel *panel = [NSSavePanel savePanel];
|
||||
panel.nameFieldStringValue = [strongSelf.mapView.styleURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:@"png"];
|
||||
panel.allowedFileTypes = [@[(NSString *)kUTTypePNG] arrayByAddingObjectsFromArray:[NSBitmapImageRep imageUnfilteredTypes]];
|
||||
|
||||
|
||||
[panel beginSheetModalForWindow:strongSelf.window completionHandler:^(NSInteger result) {
|
||||
if (result == NSModalResponseOK) {
|
||||
// Write the contents in the new format.
|
||||
NSURL *fileURL = panel.URL;
|
||||
|
||||
|
||||
NSBitmapImageRep *bitmapRep;
|
||||
for (NSImageRep *imageRep in snapshot.image.representations) {
|
||||
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) {
|
||||
@@ -281,11 +281,11 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
break; // stop on first bitmap rep we find
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!bitmapRep) {
|
||||
bitmapRep = [NSBitmapImageRep imageRepWithData:snapshot.image.TIFFRepresentation];
|
||||
}
|
||||
|
||||
|
||||
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileURL.pathExtension, NULL /* inConformingToUTI */);
|
||||
NSBitmapImageFileType fileType = NSTIFFFileType;
|
||||
if (UTTypeConformsTo(uti, kUTTypePNG)) {
|
||||
@@ -299,7 +299,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
} else if (UTTypeConformsTo(uti, kUTTypeBMP)) {
|
||||
fileType = NSBitmapImageFileTypeBMP;
|
||||
}
|
||||
|
||||
|
||||
NSData *imageData = [bitmapRep representationUsingType:fileType properties:@{}];
|
||||
[imageData writeToURL:fileURL atomically:NO];
|
||||
}
|
||||
@@ -757,7 +757,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
|
||||
MLNRasterStyleLayer * imageLayer = [[MLNRasterStyleLayer alloc] initWithIdentifier:@"animated-radar-layer" source:imageSource];
|
||||
[self.mapView.style addLayer:imageLayer];
|
||||
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval:1.0
|
||||
target:self
|
||||
selector:@selector(updateAnimatedImageSource:)
|
||||
@@ -769,7 +769,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
- (void)updateAnimatedImageSource:(NSTimer *)timer {
|
||||
static int radarSuffix = 0;
|
||||
MLNImageSource *imageSource = (MLNImageSource *)timer.userInfo;
|
||||
|
||||
|
||||
MLNImage *image = [[NSBundle bundleForClass:[self class]] imageForResource:[NSString stringWithFormat:@"southeast_%d", radarSuffix++]];
|
||||
[imageSource setValue:image forKey:@"image"];
|
||||
|
||||
@@ -860,19 +860,19 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
// Works only with Mapbox tileserver
|
||||
if (![[MLNSettings tileServerOptions].uriSchemeAlias isEqualToString:@"mapbox"])
|
||||
return;
|
||||
|
||||
|
||||
// Find all the identifiers of Mapbox Terrain sources used in the style.
|
||||
NSMutableSet *terrainSourceIdentifiers = [NSMutableSet set];
|
||||
for (MLNVectorTileSource *source in self.mapView.style.sources) {
|
||||
if (![source isKindOfClass:[MLNVectorTileSource class]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (source.mapboxTerrain) {
|
||||
[terrainSourceIdentifiers addObject:source.identifier];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find and remove all the style layers using those sources.
|
||||
NSUInteger hillshadeIndex = NSNotFound;
|
||||
NSEnumerator *layerEnumerator = self.mapView.style.layers.objectEnumerator;
|
||||
@@ -881,23 +881,23 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
if (![layer isKindOfClass:[MLNVectorStyleLayer class]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ([terrainSourceIdentifiers containsObject:layer.sourceIdentifier]
|
||||
&& [layer.sourceLayerIdentifier isEqualToString:@"hillshade"]) {
|
||||
hillshadeIndex = i;
|
||||
[self.mapView.style removeLayer:layer];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hillshadeIndex == NSNotFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Add terrain-RGB source.
|
||||
NSURL *terrainRGBURL = [NSURL URLWithString:@"maptiler://sources/terrain-rgb"];
|
||||
MLNRasterDEMSource *terrainRGBSource = [[MLNRasterDEMSource alloc] initWithIdentifier:@"terrain" configurationURL:terrainRGBURL];
|
||||
[self.mapView.style addSource:terrainRGBSource];
|
||||
|
||||
|
||||
// Insert a hillshade layer where the Mapbox Terrain–based layers were.
|
||||
MLNHillshadeStyleLayer *hillshadeLayer = [[MLNHillshadeStyleLayer alloc] initWithIdentifier:@"hillshade" source:terrainRGBSource];
|
||||
[self.mapView.style insertLayer:hillshadeLayer atIndex:hillshadeIndex];
|
||||
@@ -914,18 +914,18 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
self.maximumOfflinePackZoomLevelFormatter.minimum = @(floor(self.mapView.minimumZoomLevel));
|
||||
self.minimumOfflinePackZoomLevelFormatter.maximum = @(ceil(self.mapView.maximumZoomLevel));
|
||||
self.maximumOfflinePackZoomLevelFormatter.maximum = @(ceil(self.mapView.maximumZoomLevel));
|
||||
|
||||
|
||||
id ideographicFontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MLNIdeographicFontFamilyName"];
|
||||
self.includesIdeographicGlyphsBox.state = ([ideographicFontFamilyName isKindOfClass:[NSNumber class]] && ![ideographicFontFamilyName boolValue]) ? NSOffState : NSOnState;
|
||||
[self.addOfflinePackWindow makeFirstResponder:self.offlinePackNameField];
|
||||
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[self.window beginSheet:self.addOfflinePackWindow completionHandler:^(NSModalResponse returnCode) {
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (!strongSelf || returnCode != NSModalResponseOK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
id <MLNOfflineRegion> region =
|
||||
[[MLNTilePyramidOfflineRegion alloc] initWithStyleURL:strongSelf.mapView.styleURL
|
||||
bounds:strongSelf.mapView.visibleCoordinateBounds
|
||||
@@ -979,7 +979,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
@10.0: [NSColor yellowColor],
|
||||
@20.0: [NSColor blackColor],
|
||||
}];
|
||||
|
||||
|
||||
if ([waterLayer respondsToSelector:@selector(fillColor)]) {
|
||||
[waterLayer setValue:colorExpression forKey:@"fillColor"];
|
||||
} else if ([waterLayer respondsToSelector:@selector(lineColor)]) {
|
||||
@@ -1001,7 +1001,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
if (streetsSource) {
|
||||
NSImage *image = [NSImage imageNamed:NSImageNameIChatTheaterTemplate];
|
||||
[self.mapView.style setImage:image forName:NSImageNameIChatTheaterTemplate];
|
||||
|
||||
|
||||
MLNSymbolStyleLayer *theaterLayer = [[MLNSymbolStyleLayer alloc] initWithIdentifier:@"theaters" source:streetsSource];
|
||||
theaterLayer.sourceLayerIdentifier = @"poi_label";
|
||||
theaterLayer.predicate = [NSPredicate predicateWithFormat:@"maki == 'theatre'"];
|
||||
@@ -1013,10 +1013,10 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
@20.0: [NSColor blackColor],
|
||||
}];
|
||||
[self.mapView.style addLayer:theaterLayer];
|
||||
|
||||
|
||||
NSImage *ohio = [NSImage imageNamed:@"ohio"];
|
||||
[self.mapView.style setImage:ohio forName:@"ohio"];
|
||||
|
||||
|
||||
MLNSymbolStyleLayer *ohioLayer = [[MLNSymbolStyleLayer alloc] initWithIdentifier:@"ohio" source:streetsSource];
|
||||
ohioLayer.sourceLayerIdentifier = @"road";
|
||||
ohioLayer.predicate = [NSPredicate predicateWithFormat:@"shield = 'circle-white' and iso_3166_2 = 'US-OH'"];
|
||||
@@ -1042,7 +1042,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
|
||||
MLNRasterStyleLayer * imageLayer = [[MLNRasterStyleLayer alloc] initWithIdentifier:@"radar-layer" source:imageSource];
|
||||
[self.mapView.style addLayer:imageLayer];
|
||||
|
||||
|
||||
MLNCircleStyleLayer *ucLayer = [[MLNCircleStyleLayer alloc] initWithIdentifier:@"uc" source:streetsSource];
|
||||
ucLayer.sourceLayerIdentifier = @"poi_label";
|
||||
ucLayer.predicate = [NSPredicate predicateWithFormat:@"$geometryType = 'Point'"];
|
||||
@@ -1077,7 +1077,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
for (id <MLNFeature> feature in features) {
|
||||
if (!title) {
|
||||
title = [feature attributeForKey:@"title"] ?: [feature attributeForKey:@"name_en"] ?: [feature attributeForKey:@"name"];
|
||||
|
||||
|
||||
// simplestyle-spec defines a “description” attribute in HTML format.
|
||||
NSString *featureDescription = [feature attributeForKey:@"description"];
|
||||
if (featureDescription) {
|
||||
@@ -1086,7 +1086,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
NSData *data = [featureDescription dataUsingEncoding:NSUTF8StringEncoding];
|
||||
description = [[NSAttributedString alloc] initWithHTML:data options:@{} documentAttributes:nil].string;
|
||||
}
|
||||
|
||||
|
||||
if (title) {
|
||||
break;
|
||||
}
|
||||
@@ -1443,7 +1443,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
|
||||
- (void)mapSnapshotter:(MLNMapSnapshotter *)snapshotter didFinishLoadingStyle:(MLNStyle *)style {
|
||||
[style localizeLabelsIntoLocale:_isLocalizingLabels ? nil : [NSLocale localeWithLocaleIdentifier:@"mul"]];
|
||||
|
||||
|
||||
// Layers hidden in the sidebar should be hidden in the snapshot too.
|
||||
NSMutableArray<NSString *> *hiddenLayerIdentifiers = [NSMutableArray array];
|
||||
for (MLNStyleLayer *layer in self.mapView.style.layers) {
|
||||
@@ -1451,7 +1451,7 @@ NSArray<id <MLNAnnotation>> *MBXFlattenedShapes(NSArray<id <MLNAnnotation>> *sha
|
||||
[hiddenLayerIdentifiers addObject:layer.identifier];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSSet <NSString *> *hiddenLayerIdentifierSet = [NSSet setWithArray:hiddenLayerIdentifiers];
|
||||
for (MLNStyleLayer *layer in style.layers) {
|
||||
if ([hiddenLayerIdentifierSet containsObject:layer.identifier]) {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
if ([layer isKindOfClass:[MLNHillshadeStyleLayer class]]) {
|
||||
return [NSImage imageNamed:@"hillshade"];
|
||||
}
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ MLNMapViewMetalImpl::MLNMapViewMetalImpl(MLNMapView* nativeView_)
|
||||
: MLNMapViewImpl(nativeView_),
|
||||
mbgl::mtl::RendererBackend(mbgl::gfx::ContextMode::Unique),
|
||||
mbgl::gfx::Renderable({ 0, 0 }, std::make_unique<MLNMapViewMetalRenderableResource>(*this)) {
|
||||
|
||||
|
||||
auto& resource = getResource<MLNMapViewMetalRenderableResource>();
|
||||
if (resource.mtlView) {
|
||||
return;
|
||||
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
auto apiKey = [[MLNSettings sharedSettings] apiKey];
|
||||
if (apiKey) {
|
||||
resourceOptions.withApiKey([apiKey UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions, clientOptions);
|
||||
|
||||
@@ -962,7 +962,7 @@ public:
|
||||
if (!_mbglMap) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(mapViewDidBecomeIdle:)]) {
|
||||
[self.delegate mapViewDidBecomeIdle:self];
|
||||
}
|
||||
@@ -996,7 +996,7 @@ public:
|
||||
if ([self.delegate respondsToSelector:@selector(mapView:shouldRemoveStyleImage:)]) {
|
||||
return [self.delegate mapView:self shouldRemoveStyleImage:imageName];
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1046,7 @@ public:
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
[self willChangeValueForKey:@"centerCoordinate"];
|
||||
_mbglMap->easeTo(mbgl::CameraOptions()
|
||||
.withCenter(MLNLatLngFromLocationCoordinate2D(centerCoordinate))
|
||||
@@ -1246,7 +1246,7 @@ public:
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if ([self.camera isEqualToMapCamera:camera]) {
|
||||
if (completion) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@@ -1295,7 +1295,7 @@ public:
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if ([self.camera isEqualToMapCamera:camera]) {
|
||||
if (completion) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@@ -1362,7 +1362,7 @@ public:
|
||||
if (animated) {
|
||||
animationOptions.duration = MLNDurationFromTimeInterval(MLNAnimationDuration);
|
||||
}
|
||||
|
||||
|
||||
MLNMapCamera *camera = [self cameraForCameraOptions:cameraOptions];
|
||||
if ([self.camera isEqualToMapCamera:camera]) {
|
||||
completion();
|
||||
@@ -1396,11 +1396,11 @@ public:
|
||||
{
|
||||
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
|
||||
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
|
||||
|
||||
|
||||
MLNMapCamera *currentCamera = self.camera;
|
||||
CGFloat pitch = camera.pitch < 0 ? currentCamera.pitch : camera.pitch;
|
||||
CLLocationDirection direction = camera.heading < 0 ? currentCamera.heading : camera.heading;
|
||||
|
||||
|
||||
mbgl::CameraOptions cameraOptions = _mbglMap->cameraForLatLngBounds(MLNLatLngBoundsFromCoordinateBounds(bounds), padding, direction, pitch);
|
||||
return [self cameraForCameraOptions:cameraOptions];
|
||||
}
|
||||
@@ -1408,13 +1408,13 @@ public:
|
||||
- (MLNMapCamera *)camera:(MLNMapCamera *)camera fittingShape:(MLNShape *)shape edgePadding:(NSEdgeInsets)insets {
|
||||
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
|
||||
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
|
||||
|
||||
|
||||
MLNMapCamera *currentCamera = self.camera;
|
||||
CGFloat pitch = camera.pitch < 0 ? currentCamera.pitch : camera.pitch;
|
||||
CLLocationDirection direction = camera.heading < 0 ? currentCamera.heading : camera.heading;
|
||||
|
||||
|
||||
mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction, pitch);
|
||||
|
||||
|
||||
return [self cameraForCameraOptions: cameraOptions];
|
||||
}
|
||||
|
||||
@@ -1569,7 +1569,7 @@ public:
|
||||
_mbglMap->jumpTo(mbgl::CameraOptions().withPitch(_pitchAtBeginningOfGesture + delta.y / 5).withAnchor(center));
|
||||
didChangeCamera = YES;
|
||||
}
|
||||
|
||||
|
||||
if (didChangeCamera
|
||||
&& [self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)]
|
||||
&& ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) {
|
||||
@@ -1696,13 +1696,13 @@ public:
|
||||
_directionAtBeginningOfGesture = self.direction;
|
||||
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
|
||||
MLNMapCamera *oldCamera = self.camera;
|
||||
|
||||
|
||||
NSPoint rotationPoint = [gestureRecognizer locationInView:self];
|
||||
mbgl::ScreenCoordinate anchor(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
|
||||
_mbglMap->jumpTo(mbgl::CameraOptions()
|
||||
.withBearing(_directionAtBeginningOfGesture + gestureRecognizer.rotationInDegrees)
|
||||
.withAnchor(anchor));
|
||||
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)]
|
||||
&& ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) {
|
||||
self.camera = oldCamera;
|
||||
@@ -1813,12 +1813,12 @@ public:
|
||||
case '-':
|
||||
[self moveToEndOfParagraph:nil];
|
||||
break;
|
||||
|
||||
|
||||
case '+':
|
||||
case '=':
|
||||
[self moveToBeginningOfParagraph:nil];
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
[super insertText:insertString];
|
||||
break;
|
||||
@@ -1928,11 +1928,11 @@ public:
|
||||
|
||||
std::vector<MLNAnnotationTag> annotationTags = [self annotationTagsInRect:rect];
|
||||
std::vector<MLNAnnotationTag> shapeAnnotationTags = [self shapeAnnotationTagsInRect:rect];
|
||||
|
||||
|
||||
if (shapeAnnotationTags.size()) {
|
||||
annotationTags.insert(annotationTags.end(), shapeAnnotationTags.begin(), shapeAnnotationTags.end());
|
||||
}
|
||||
|
||||
|
||||
if (annotationTags.size())
|
||||
{
|
||||
NSMutableArray *annotations = [NSMutableArray arrayWithCapacity:annotationTags.size()];
|
||||
@@ -2193,7 +2193,7 @@ public:
|
||||
-MLNAnnotationImagePaddingForHitTest);
|
||||
std::vector<MLNAnnotationTag> nearbyAnnotations = [self annotationTagsInRect:queryRect];
|
||||
std::vector<MLNAnnotationTag> nearbyShapeAnnotations = [self shapeAnnotationTagsInRect:queryRect];
|
||||
|
||||
|
||||
if (nearbyShapeAnnotations.size()) {
|
||||
nearbyAnnotations.insert(nearbyAnnotations.end(), nearbyShapeAnnotations.begin(), nearbyShapeAnnotations.end());
|
||||
}
|
||||
@@ -2203,7 +2203,7 @@ public:
|
||||
NSRect hitRect = NSInsetRect({ point, NSZeroSize },
|
||||
-MLNAnnotationImagePaddingForHitTest,
|
||||
-MLNAnnotationImagePaddingForHitTest);
|
||||
|
||||
|
||||
// Filter out any annotation whose image is unselectable or for which
|
||||
// hit testing fails.
|
||||
auto end = std::remove_if(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MLNAnnotationTag annotationTag) {
|
||||
@@ -2212,7 +2212,7 @@ public:
|
||||
if (!annotation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if ([annotation isKindOfClass:[MLNMultiPoint class]])
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(mapView:shapeAnnotationIsEnabled:)]) {
|
||||
@@ -2221,12 +2221,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MLNAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
|
||||
if (!annotationImage.selectable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Filter out the annotation if the fattened finger didn’t land on a
|
||||
// translucent or opaque pixel in the image.
|
||||
NSRect annotationRect = [self frameOfImage:annotationImage.image
|
||||
@@ -2252,7 +2252,7 @@ public:
|
||||
coordinateB.longitude - currentCoordinate.longitude);
|
||||
return deltaA < deltaB;
|
||||
});
|
||||
|
||||
|
||||
if (nearbyAnnotations == _annotationsNearbyLastClick) {
|
||||
// The last time we persisted a set of annotations, we had the same
|
||||
// set of annotations as we do now. Cycle through them.
|
||||
@@ -2315,7 +2315,7 @@ public:
|
||||
_selectedAnnotationTag == MLNAnnotationTagNotFound) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
MLNAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(_selectedAnnotationTag);
|
||||
return annotationContext.annotation;
|
||||
}
|
||||
@@ -2402,7 +2402,7 @@ public:
|
||||
&& !self.calloutForSelectedAnnotation.shown
|
||||
&& [self.delegate respondsToSelector:@selector(mapView:annotationCanShowCallout:)]
|
||||
&& [self.delegate mapView:self annotationCanShowCallout:annotation]);
|
||||
|
||||
|
||||
if (NSIsEmptyRect(NSIntersectionRect(positioningRect, self.bounds))) {
|
||||
if (!moveIntoView && !NSEqualPoints(gesturePoint, NSZeroPoint)) {
|
||||
positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height);
|
||||
@@ -2449,7 +2449,7 @@ public:
|
||||
|
||||
// Add padding around the positioning rect (in essence an inset from the edge of the viewport
|
||||
NSRect expandedPositioningRect = positioningRect;
|
||||
|
||||
|
||||
if (shouldShowCallout) {
|
||||
// If we have a callout, expand this rect to include a buffer
|
||||
expandedPositioningRect = edgeInsetsInsetRect(positioningRect, MLNMapViewOffscreenAnnotationPadding);
|
||||
@@ -2461,29 +2461,29 @@ public:
|
||||
|
||||
// Any one of these cases should trigger a move onscreen
|
||||
CGFloat minX = CGRectGetMinX(expandedPositioningRect);
|
||||
|
||||
|
||||
if (minX < CGRectGetMinX(bounds)) {
|
||||
constrainedRect.origin.x = minX;
|
||||
moveIntoView = YES;
|
||||
}
|
||||
else {
|
||||
CGFloat maxX = CGRectGetMaxX(expandedPositioningRect);
|
||||
|
||||
|
||||
if (maxX > CGRectGetMaxX(bounds)) {
|
||||
constrainedRect.origin.x = maxX - CGRectGetWidth(constrainedRect);
|
||||
moveIntoView = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CGFloat minY = CGRectGetMinY(expandedPositioningRect);
|
||||
|
||||
|
||||
if (minY < CGRectGetMinY(bounds)) {
|
||||
constrainedRect.origin.y = minY;
|
||||
moveIntoView = YES;
|
||||
}
|
||||
else {
|
||||
CGFloat maxY = CGRectGetMaxY(expandedPositioningRect);
|
||||
|
||||
|
||||
if (maxY > CGRectGetMaxY(bounds)) {
|
||||
constrainedRect.origin.y = maxY - CGRectGetHeight(constrainedRect);
|
||||
moveIntoView = YES;
|
||||
@@ -2584,9 +2584,9 @@ public:
|
||||
CLLocationCoordinate2D origin = annotation.coordinate;
|
||||
CGPoint originPoint = [self convertCoordinate:origin toPointToView:self];
|
||||
return CGRectMake(originPoint.x, originPoint.y, MLNAnnotationImagePaddingForHitTest, MLNAnnotationImagePaddingForHitTest);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
NSImage *image = [self imageOfAnnotationWithTag:annotationTag].image;
|
||||
if (!image) {
|
||||
image = [self dequeueReusableAnnotationImageWithIdentifier:MLNDefaultStyleMarkerSymbolName].image;
|
||||
@@ -2858,12 +2858,12 @@ public:
|
||||
}];
|
||||
optionalLayerIDs = layerIDs;
|
||||
}
|
||||
|
||||
|
||||
std::optional<mbgl::style::Filter> optionalFilter;
|
||||
if (predicate) {
|
||||
optionalFilter = predicate.mgl_filter;
|
||||
}
|
||||
|
||||
|
||||
std::vector<mbgl::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(screenCoordinate, { optionalLayerIDs, optionalFilter });
|
||||
return MLNFeaturesFromMBGLFeatures(features);
|
||||
}
|
||||
@@ -2895,12 +2895,12 @@ public:
|
||||
}];
|
||||
optionalLayerIDs = layerIDs;
|
||||
}
|
||||
|
||||
|
||||
std::optional<mbgl::style::Filter> optionalFilter;
|
||||
if (predicate) {
|
||||
optionalFilter = predicate.mgl_filter;
|
||||
}
|
||||
|
||||
|
||||
std::vector<mbgl::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(screenBox, { optionalLayerIDs, optionalFilter });
|
||||
return MLNFeaturesFromMBGLFeatures(features);
|
||||
}
|
||||
@@ -2977,19 +2977,19 @@ public:
|
||||
auto southeast = bounds.southeast();
|
||||
|
||||
auto center = [self convertPoint:{ NSMidX(view.bounds), NSMidY(view.bounds) } toLatLngFromView:view];
|
||||
|
||||
|
||||
// Extend bounds to account for the antimeridian
|
||||
northwest.unwrapForShortestPath(center);
|
||||
northeast.unwrapForShortestPath(center);
|
||||
southwest.unwrapForShortestPath(center);
|
||||
southeast.unwrapForShortestPath(center);
|
||||
|
||||
|
||||
auto correctedLatLngBounds = mbgl::LatLngBounds::empty();
|
||||
correctedLatLngBounds.extend(northwest);
|
||||
correctedLatLngBounds.extend(northeast);
|
||||
correctedLatLngBounds.extend(southwest);
|
||||
correctedLatLngBounds.extend(southeast);
|
||||
|
||||
|
||||
NSRect rect = { [self convertLatLng:correctedLatLngBounds.southwest() toPointToView:view], CGSizeZero };
|
||||
rect = MLNExtendRect(rect, [self convertLatLng:correctedLatLngBounds.northeast() toPointToView:view]);
|
||||
return rect;
|
||||
@@ -3007,7 +3007,7 @@ public:
|
||||
auto bottomRight = [self convertPoint:{ NSMaxX(rect), NSMinY(rect) } toLatLngFromView:view];
|
||||
auto topRight = [self convertPoint:{ NSMaxX(rect), NSMaxY(rect) } toLatLngFromView:view];
|
||||
auto topLeft = [self convertPoint:{ NSMinX(rect), NSMaxY(rect) } toLatLngFromView:view];
|
||||
|
||||
|
||||
// If the bounds straddles the antimeridian, unwrap it so that one side
|
||||
// extends beyond ±180° longitude.
|
||||
auto center = [self convertPoint:{ NSMidX(rect), NSMidY(rect) } toLatLngFromView:view];
|
||||
@@ -3015,7 +3015,7 @@ public:
|
||||
bottomRight.unwrapForShortestPath(center);
|
||||
topRight.unwrapForShortestPath(center);
|
||||
topLeft.unwrapForShortestPath(center);
|
||||
|
||||
|
||||
bounds.extend(bottomLeft);
|
||||
bounds.extend(bottomRight);
|
||||
bounds.extend(topRight);
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
return [NSColor colorWithRed:color.r green:color.g blue:color.b alpha:color.a];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mbgl::Color provides premultiplied color components, so we have to convert color
|
||||
// components to non-premultiplied values to return a valid NSColor object.
|
||||
float red = static_cast<float>((color.r / color.a));
|
||||
@@ -75,7 +75,7 @@
|
||||
if (NSColor *color = [self mgl_colorWithRGBComponents:components]) {
|
||||
return [NSExpression expressionForConstantValue:color];
|
||||
}
|
||||
|
||||
|
||||
NSExpression *color = [NSExpression expressionForConstantValue:[NSColor class]];
|
||||
NSExpression *alpha = [NSExpression expressionForConstantValue:@1.0];
|
||||
return [NSExpression expressionForFunction:color
|
||||
@@ -87,7 +87,7 @@
|
||||
if (NSColor *color = [self mgl_colorWithRGBComponents:components]) {
|
||||
return [NSExpression expressionForConstantValue:color];
|
||||
}
|
||||
|
||||
|
||||
NSExpression *color = [NSExpression expressionForConstantValue:[NSColor class]];
|
||||
return [NSExpression expressionForFunction:color
|
||||
selectorName:@"colorWithRed:green:blue:alpha:"
|
||||
@@ -106,23 +106,23 @@
|
||||
if (componentExpression.expressionType != NSConstantValueExpressionType) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
NSNumber *component = (NSNumber *)componentExpression.constantValue;
|
||||
if (![component isKindOfClass:[NSNumber class]]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
components.push_back(component.doubleValue / 255.0);
|
||||
}
|
||||
|
||||
|
||||
if (components.size() < 4) {
|
||||
components.push_back(1.0);
|
||||
} else {
|
||||
// Alpha
|
||||
components.back() *= 255.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// macOS 10.12 Sierra and below uses calibrated RGB by default.
|
||||
if ([NSColor redColor].colorSpaceName == NSCalibratedRGBColorSpace) {
|
||||
return [NSColor colorWithCalibratedRed:components[0]
|
||||
|
||||
@@ -51,7 +51,7 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
|
||||
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
|
||||
mbgl::PremultipliedImage cPremultipliedImage = self.mgl_premultipliedImage;
|
||||
auto imageWidth = cPremultipliedImage.size.width;
|
||||
|
||||
|
||||
float scale = static_cast<float>(imageWidth) / self.size.width;
|
||||
mbgl::style::ImageStretches stretchX, stretchY;
|
||||
if (self.resizingMode == NSImageResizingModeStretch) {
|
||||
@@ -62,7 +62,7 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
|
||||
self.capInsets.top * scale, (self.size.height - self.capInsets.bottom) * scale,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
std::optional<mbgl::style::ImageContent> imageContent;
|
||||
if (!MLNEdgeInsetsIsZero(self.capInsets)) {
|
||||
imageContent = (mbgl::style::ImageContent){
|
||||
@@ -72,7 +72,7 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
|
||||
.bottom = static_cast<float>((self.size.height - self.capInsets.bottom) * scale),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return std::make_unique<mbgl::style::Image>([identifier UTF8String],
|
||||
std::move(cPremultipliedImage),
|
||||
scale,
|
||||
|
||||
Reference in New Issue
Block a user