diff options
Diffstat (limited to 'platform/macos/app')
7 files changed, 273 insertions, 23 deletions
diff --git a/platform/macos/app/Assets.xcassets/Layers/background.imageset/Contents.json b/platform/macos/app/Assets.xcassets/Layers/background.imageset/Contents.json index 3d2c878879..7473a40333 100644 --- a/platform/macos/app/Assets.xcassets/Layers/background.imageset/Contents.json +++ b/platform/macos/app/Assets.xcassets/Layers/background.imageset/Contents.json @@ -2,7 +2,8 @@ "images" : [ { "idiom" : "universal", - "filename" : "background.pdf" + "filename" : "background.pdf", + "language-direction" : "left-to-right" } ], "info" : { diff --git a/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/Contents.json b/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/Contents.json new file mode 100644 index 0000000000..f9922cad46 --- /dev/null +++ b/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "hillshade.pdf", + "language-direction" : "left-to-right" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +}
\ No newline at end of file diff --git a/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/hillshade.pdf b/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/hillshade.pdf new file mode 100644 index 0000000000..bf409e708c --- /dev/null +++ b/platform/macos/app/Assets.xcassets/Layers/hillshade.imageset/hillshade.pdf @@ -0,0 +1,70 @@ +%PDF-1.5 +% +3 0 obj +<< /Length 4 0 R + /Filter /FlateDecode +>> +stream +xeNA +@sv} xŃ(Vo"L0# jXˆ6w:!,P㒒hK灴aU18|=
_?ݜ{YXS2یݮ*5/ﺠ>ݪ, +endstream +endobj +4 0 obj + 145 +endobj +2 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + /a1 << /CA 0.156863 /ca 0.156863 >> + >> +>> +endobj +5 0 obj +<< /Type /Page + /Parent 1 0 R + /MediaBox [ 0 0 12 12 ] + /Contents 3 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 2 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 5 0 R ] + /Count 1 +>> +endobj +6 0 obj +<< /Creator (cairo 1.14.8 (http://cairographics.org)) + /Producer (cairo 1.14.8 (http://cairographics.org)) +>> +endobj +7 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 8 +0000000000 65535 f +0000000585 00000 n +0000000259 00000 n +0000000015 00000 n +0000000237 00000 n +0000000373 00000 n +0000000650 00000 n +0000000777 00000 n +trailer +<< /Size 8 + /Root 7 0 R + /Info 6 0 R +>> +startxref +829 +%%EOF diff --git a/platform/macos/app/Base.lproj/MainMenu.xib b/platform/macos/app/Base.lproj/MainMenu.xib index d014676caa..72e9c5a189 100644 --- a/platform/macos/app/Base.lproj/MainMenu.xib +++ b/platform/macos/app/Base.lproj/MainMenu.xib @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16E195" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/> + <deployment identifier="macosx"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -554,6 +555,21 @@ <action selector="drawAnimatedAnnotation:" target="-1" id="CYM-WB-s97"/> </connections> </menuItem> + <menuItem title="Show All Annnotations" keyEquivalent="A" id="yMj-uM-8SN"> + <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/> + <connections> + <action selector="showAllAnnotations:" target="-1" id="ahr-OR-Em2"/> + </connections> + </menuItem> + <menuItem title="Remove All Annotations" id="6rC-68-vk0"> + <string key="keyEquivalent" base64-UTF8="YES"> +CA +</string> + <connections> + <action selector="removeAllAnnotations:" target="-1" id="6v3-0E-LsR"/> + </connections> + </menuItem> + <menuItem isSeparatorItem="YES" id="cbI-Nd-MAp"/> <menuItem title="Add Lime Green Layer" id="UWY-vl-t2m"> <modifierMask key="keyEquivalentModifierMask"/> <connections> @@ -565,25 +581,17 @@ <connections> <action selector="addAnimatedImageSource:" target="-1" id="TuN-Pa-hTG"/> </connections> - </menuItem> + </menuItem> <menuItem title="Add Graticule" id="Msk-p2-Lwt"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="insertGraticuleLayer:" target="-1" id="LE5-lz-kx4"/> </connections> </menuItem> - <menuItem title="Show All Annnotations" keyEquivalent="A" id="yMj-uM-8SN"> - <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/> - <connections> - <action selector="showAllAnnotations:" target="-1" id="ahr-OR-Em2"/> - </connections> - </menuItem> - <menuItem title="Remove All Annotations" id="6rC-68-vk0"> - <string key="keyEquivalent" base64-UTF8="YES"> - CA - </string> + <menuItem title="Enhance Terrain" id="2ZT-uE-kUR"> + <modifierMask key="keyEquivalentModifierMask"/> <connections> - <action selector="removeAllAnnotations:" target="-1" id="6v3-0E-LsR"/> + <action selector="enhanceTerrain:" target="-1" id="TXX-Yv-ZY1"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="wQq-Mx-QY0"/> @@ -666,7 +674,7 @@ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="109" y="131" width="350" height="84"/> - <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> + <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/> <view key="contentView" id="eA4-n3-qPe"> <rect key="frame" x="0.0" y="0.0" width="350" height="84"/> <autoresizingMask key="autoresizingMask"/> @@ -742,7 +750,7 @@ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" utility="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="830" y="430" width="400" height="300"/> - <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> + <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/> <view key="contentView" id="8ha-hw-zOD"> <rect key="frame" x="0.0" y="0.0" width="400" height="300"/> <autoresizingMask key="autoresizingMask"/> @@ -751,7 +759,7 @@ <rect key="frame" x="-1" y="20" width="402" height="281"/> <clipView key="contentView" id="J9U-Yx-o2S"> <rect key="frame" x="1" y="0.0" width="400" height="280"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" autosaveColumns="NO" headerView="MAZ-Iq-hBi" id="Ato-Vu-HYT"> <rect key="frame" x="0.0" y="0.0" width="423" height="257"/> @@ -772,7 +780,7 @@ <binding destination="dWe-R6-sRz" name="value" keyPath="arrangedObjects.stateImage" id="2wd-1J-TZt"/> </connections> </tableColumn> - <tableColumn editable="NO" width="116" minWidth="40" maxWidth="1000" id="2hD-LN-h0L"> + <tableColumn identifier="" editable="NO" width="116" minWidth="40" maxWidth="1000" id="2hD-LN-h0L"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Name"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> @@ -792,7 +800,7 @@ </binding> </connections> </tableColumn> - <tableColumn editable="NO" width="50" minWidth="40" maxWidth="1000" id="pkI-c7-xoD"> + <tableColumn identifier="" editable="NO" width="50" minWidth="40" maxWidth="1000" id="pkI-c7-xoD"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Downloaded Resources"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> @@ -826,7 +834,7 @@ <binding destination="dWe-R6-sRz" name="value" keyPath="arrangedObjects.countOfResourcesExpected" id="mh2-k0-vvB"/> </connections> </tableColumn> - <tableColumn editable="NO" width="50" minWidth="40" maxWidth="1000" id="kCO-Cd-bQt"> + <tableColumn identifier="" editable="NO" width="50" minWidth="40" maxWidth="1000" id="kCO-Cd-bQt"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Downloaded Tiles"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> @@ -847,7 +855,7 @@ </binding> </connections> </tableColumn> - <tableColumn editable="NO" width="60" minWidth="10" maxWidth="3.4028234663852886e+38" id="WO5-Ci-HgG"> + <tableColumn identifier="" editable="NO" width="60" minWidth="10" maxWidth="3.4028234663852886e+38" id="WO5-Ci-HgG"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Downloaded Tiles Size"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 94b0cffcdc..602ed1aa41 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -50,6 +50,25 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio return flattenedShapes; } +@interface MGLVectorSource (MBXAdditions) + +@property (nonatomic, readonly, getter=isMapboxTerrain) BOOL mapboxTerrain; + +@end + +@implementation MGLVectorSource (MBXAdditions) + +- (BOOL)isMapboxTerrain { + NSURL *url = self.configurationURL; + if (![url.scheme isEqualToString:@"mapbox"]) { + return NO; + } + NSArray *identifiers = [url.host componentsSeparatedByString:@","]; + return [identifiers containsObject:@"mapbox.mapbox-terrain-v2"] || [identifiers containsObject:@"mapbox.mapbox-terrain-v1"]; +} + +@end + @interface MapDocument () <NSWindowDelegate, NSSharingServicePickerDelegate, NSMenuDelegate, NSSplitViewDelegate, MGLMapViewDelegate, MGLComputedShapeSourceDataSource> @property (weak) IBOutlet NSArrayController *styleLayersArrayController; @@ -739,6 +758,49 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.mapView.style removeSource:source]; } +- (IBAction)enhanceTerrain:(id)sender { + // Find all the identifiers of Mapbox Terrain sources used in the style. + NSMutableSet *terrainSourceIdentifiers = [NSMutableSet set]; + for (MGLVectorSource *source in self.mapView.style.sources) { + if (![source isKindOfClass:[MGLVectorSource 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; + MGLVectorStyleLayer *layer; + for (NSUInteger i = 0; (layer = layerEnumerator.nextObject); i++) { + if (![layer isKindOfClass:[MGLVectorStyleLayer class]]) { + continue; + } + + if ([terrainSourceIdentifiers containsObject:layer.sourceIdentifier] + && [layer.sourceLayerIdentifier isEqualToString:@"hillshade"]) { + hillshadeIndex = i; + [self.mapView.style removeLayer:layer]; + } + } + + if (hillshadeIndex == NSNotFound) { + return; + } + + // Add a Mapbox Terrain-RGB source. + NSURL *terrainRGBURL = [NSURL URLWithString:@"mapbox://mapbox.terrain-rgb"]; + MGLRasterDEMSource *terrainRGBSource = [[MGLRasterDEMSource alloc] initWithIdentifier:@"terrain" configurationURL:terrainRGBURL]; + [self.mapView.style addSource:terrainRGBSource]; + + // Insert a hillshade layer where the Mapbox Terrain–based layers were. + MGLHillshadeStyleLayer *hillshadeLayer = [[MGLHillshadeStyleLayer alloc] initWithIdentifier:@"hillshade" source:terrainRGBSource]; + [self.mapView.style insertLayer:hillshadeLayer atIndex:hillshadeIndex]; +} + #pragma mark Offline packs - (IBAction)addOfflinePack:(id)sender { @@ -1058,6 +1120,9 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (menuItem.action == @selector(showAllAnnotations:) || menuItem.action == @selector(removeAllAnnotations:)) { return self.mapView.annotations.count > 0; } + if (menuItem.action == @selector(enhanceTerrain:)) { + return YES; + } if (menuItem.action == @selector(startWorldTour:)) { return !_isTouringWorld; } diff --git a/platform/macos/app/StyleLayerIconTransformer.m b/platform/macos/app/StyleLayerIconTransformer.m index ff2b964b87..50fe06a2c6 100644 --- a/platform/macos/app/StyleLayerIconTransformer.m +++ b/platform/macos/app/StyleLayerIconTransformer.m @@ -31,7 +31,10 @@ if ([layer isKindOfClass:[MGLSymbolStyleLayer class]]) { return [NSImage imageNamed:@"symbol"]; } - + if ([layer isKindOfClass:[MGLHillshadeStyleLayer class]]) { + return [NSImage imageNamed:@"hillshade"]; + } + return nil; } diff --git a/platform/macos/app/resources/hillshade.svg b/platform/macos/app/resources/hillshade.svg new file mode 100644 index 0000000000..d3f0d72999 --- /dev/null +++ b/platform/macos/app/resources/hillshade.svg @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg4148" + version="1.1" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + sodipodi:docname="hillshade.svg" + inkscape:export-filename="/Users/mxn/Desktop/symbol.png" + inkscape:export-xdpi="90.000244" + inkscape:export-ydpi="90.000244"> + <defs + id="defs4150" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="23.25" + inkscape:cx="6.2795699" + inkscape:cy="11.122067" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + units="px" + inkscape:window-width="1280" + inkscape:window-height="755" + inkscape:window-x="0" + inkscape:window-y="1" + inkscape:window-maximized="1" + inkscape:snap-bbox="true" /> + <metadata + id="metadata4153"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <path + sodipodi:type="star" + style="opacity:1;fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path839" + sodipodi:sides="3" + sodipodi:cx="12.189357" + sodipodi:cy="1045.3247" + sodipodi:r1="12.575057" + sodipodi:r2="6.2875285" + sodipodi:arg1="0.52359878" + sodipodi:arg2="1.5707963" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 23.079676,1051.6122 -21.7806381,0 10.8903191,-18.8625 z" + inkscape:transform-center-y="-2.1749516" + transform="matrix(0.6563034,0,0,0.75784422,8.3706122e-5,254.83559)" /> + <path + transform="matrix(0.6563034,0,0,0.75784422,8.3706122e-5,254.83559)" + style="opacity:1;fill:#000000;fill-opacity:0.15686275;fill-rule:evenodd;stroke:none;stroke-width:1.50017999;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:transform-center-y="-2.1749516" + d="m 23.079676,1051.6122 h -7.842948 l -3.047371,-18.8625 z" + id="path841" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + </g> +</svg> |