Skip to content

Commit 0775cbd

Browse files
committed
Merge branch 'v.next' into Caleb/New-ApplyDictionaryRendererToGraphicsOverlay
2 parents 9cc5839 + 9e66d3e commit 0775cbd

File tree

5 files changed

+192
-0
lines changed

5 files changed

+192
-0
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@
227227
D7044B972BE18D8D000F2C43 /* EditWithBranchVersioningView.Views.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7044B952BE18D73000F2C43 /* EditWithBranchVersioningView.Views.swift */; };
228228
D704AA5A2AB22C1A00A3BB63 /* GroupLayersTogetherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */; };
229229
D704AA5B2AB22D8400A3BB63 /* GroupLayersTogetherView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */; };
230+
D705390A2CD0122D00F63F4A /* mil2525d.stylx in Resources */ = {isa = PBXBuildFile; fileRef = D70539032CD0122D00F63F4A /* mil2525d.stylx */; settings = {ASSET_TAGS = (ApplyDictionaryRendererToFeatureLayer, ); }; };
231+
D70539102CD012BB00F63F4A /* militaryoverlay.geodatabase in Resources */ = {isa = PBXBuildFile; fileRef = D705390F2CD0127700F63F4A /* militaryoverlay.geodatabase */; settings = {ASSET_TAGS = (ApplyDictionaryRendererToFeatureLayer, ); }; };
230232
D7054AE92ACCCB6C007235BA /* Animate3DGraphicView.SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7054AE82ACCCB6C007235BA /* Animate3DGraphicView.SettingsView.swift */; };
231233
D7054AEA2ACCCC34007235BA /* Animate3DGraphicView.SettingsView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7054AE82ACCCB6C007235BA /* Animate3DGraphicView.SettingsView.swift */; };
232234
D7058B102B59E44B000A888A /* StylePointWithSceneSymbolView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7058B0D2B59E44B000A888A /* StylePointWithSceneSymbolView.swift */; };
@@ -481,6 +483,8 @@
481483
D7EF5D752A26A03A00FEBDE5 /* ShowCoordinatesInMultipleFormatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7EF5D742A26A03A00FEBDE5 /* ShowCoordinatesInMultipleFormatsView.swift */; };
482484
D7EF5D762A26A1EE00FEBDE5 /* ShowCoordinatesInMultipleFormatsView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7EF5D742A26A03A00FEBDE5 /* ShowCoordinatesInMultipleFormatsView.swift */; };
483485
D7F2784C2A1D76F5002E4567 /* AddWMSLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7E557672A1D768800B9FB09 /* AddWMSLayerView.swift */; };
486+
D7F2A02F2CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7F2A0292CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift */; };
487+
D7F2A0302CD00F400008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7F2A0292CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift */; };
484488
D7F850042B7C427A00680D7C /* ValidateUtilityNetworkTopologyView.Views.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7C97B552B75C10C0097CDA1 /* ValidateUtilityNetworkTopologyView.Views.swift */; };
485489
D7F8C0392B60564D0072BFA7 /* AddFeaturesWithContingentValuesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7F8C0362B60564D0072BFA7 /* AddFeaturesWithContingentValuesView.swift */; };
486490
D7F8C03B2B6056790072BFA7 /* AddFeaturesWithContingentValuesView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7F8C0362B60564D0072BFA7 /* AddFeaturesWithContingentValuesView.swift */; };
@@ -576,6 +580,7 @@
576580
dstSubfolderSpec = 7;
577581
files = (
578582
D70789952CD1611E000DF215 /* ApplyDictionaryRendererToGraphicsOverlayView.swift in Copy Source Code Files */,
583+
D7F2A0302CD00F400008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift in Copy Source Code Files */,
579584
D75E5EF42CC04A0C00252595 /* EditFeaturesUsingFeatureFormsView.swift in Copy Source Code Files */,
580585
D7201D072CC6D3D3004BDB7D /* AddVectorTiledLayerFromCustomStyleView.swift in Copy Source Code Files */,
581586
D75E5EE92CC0342700252595 /* ListContentsOfKMLFileView.swift in Copy Source Code Files */,
@@ -926,6 +931,8 @@
926931
D701D72B2A37C7F7006FF0C8 /* bradley_low_3ds */ = {isa = PBXFileReference; lastKnownFileType = folder; path = bradley_low_3ds; sourceTree = "<group>"; };
927932
D7044B952BE18D73000F2C43 /* EditWithBranchVersioningView.Views.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditWithBranchVersioningView.Views.swift; sourceTree = "<group>"; };
928933
D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupLayersTogetherView.swift; sourceTree = "<group>"; };
934+
D70539032CD0122D00F63F4A /* mil2525d.stylx */ = {isa = PBXFileReference; lastKnownFileType = file; path = mil2525d.stylx; sourceTree = "<group>"; };
935+
D705390F2CD0127700F63F4A /* militaryoverlay.geodatabase */ = {isa = PBXFileReference; lastKnownFileType = folder; path = militaryoverlay.geodatabase; sourceTree = "<group>"; };
929936
D7054AE82ACCCB6C007235BA /* Animate3DGraphicView.SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animate3DGraphicView.SettingsView.swift; sourceTree = "<group>"; };
930937
D7058B0D2B59E44B000A888A /* StylePointWithSceneSymbolView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StylePointWithSceneSymbolView.swift; sourceTree = "<group>"; };
931938
D7058FB02ACB423C00A40F14 /* Animate3DGraphicView.Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animate3DGraphicView.Model.swift; sourceTree = "<group>"; };
@@ -1068,6 +1075,7 @@
10681075
D7EAF3592A1C023800D822C4 /* SetMinAndMaxScaleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetMinAndMaxScaleView.swift; sourceTree = "<group>"; };
10691076
D7ECF5972AB8BE63003FB2BE /* RenderMultilayerSymbolsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RenderMultilayerSymbolsView.swift; sourceTree = "<group>"; };
10701077
D7EF5D742A26A03A00FEBDE5 /* ShowCoordinatesInMultipleFormatsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowCoordinatesInMultipleFormatsView.swift; sourceTree = "<group>"; };
1078+
D7F2A0292CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplyDictionaryRendererToFeatureLayerView.swift; sourceTree = "<group>"; };
10711079
D7F8C0362B60564D0072BFA7 /* AddFeaturesWithContingentValuesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFeaturesWithContingentValuesView.swift; sourceTree = "<group>"; };
10721080
D7F8C03D2B605AF60072BFA7 /* ContingentValuesBirdNests.geodatabase */ = {isa = PBXFileReference; lastKnownFileType = file; path = ContingentValuesBirdNests.geodatabase; sourceTree = "<group>"; };
10731081
D7F8C0402B605E720072BFA7 /* FillmoreTopographicMap.vtpk */ = {isa = PBXFileReference; lastKnownFileType = file; path = FillmoreTopographicMap.vtpk; sourceTree = "<group>"; };
@@ -1245,6 +1253,7 @@
12451253
D7C16D172AC5F6C100689E89 /* Animate 3D graphic */,
12461254
D77570BC2A29427200F490CD /* Animate images with image overlay */,
12471255
D70789912CD160FD000DF215 /* Apply dictionary renderer to graphics overlay */,
1256+
D7F2A02C2CD00F1C0008D981 /* Apply dictionary renderer to feature layer */,
12481257
955AFAC52C10FD74009C8FE5 /* Apply mosaic rule to rasters */,
12491258
004A2BA12BED456500C297CE /* Apply scheduled updates to preplanned map area */,
12501259
D75362CC2A1E862B00D83028 /* Apply unique value renderer */,
@@ -1503,11 +1512,13 @@
15031512
792222DB2A81AA5D00619FFE /* a8a942c228af4fac96baa78ad60f511f */,
15041513
D7464F202ACE0910007FEE88 /* b5f977c78ec74b3a8857ca86d1d9b318 */,
15051514
D7F8C03F2B605E720072BFA7 /* b5106355f1634b8996e634c04b6a930a */,
1515+
D70539042CD0122D00F63F4A /* c78b149a1d52414682c86a5feeb13d30 */,
15061516
00D4EF8128638BF100B9CC30 /* cb1b20748a9f4d128dad8a87244e3e37 */,
15071517
4D126D7629CA3B3F00CFB7A7 /* d5bad9f4fee9483791e405880fb466da */,
15081518
D77572AC2A295DC100F490CD /* d1453556d91e46dea191c20c398b82cd */,
15091519
D75E5EEB2CC0466900252595 /* da301cb122874d5497f8a8f6c81eb36e */,
15101520
D7E7D0862AEB3C36003AAD02 /* df193653ed39449195af0c9725701dca */,
1521+
D70539082CD0122D00F63F4A /* e0d41b4b409a49a5a7ba11939d8535dc */,
15111522
F111CCC2288B63DB00205358 /* e1f3a7254cb845b09450f54937c16061 */,
15121523
D7C5233F2BED9BBF00E8221A /* e4a398afe9a945f3b0f4dca1e4faccb5 */,
15131524
D7F8C03C2B605AF60072BFA7 /* e12b54ea799f4606a2712157cf9f6e41 */,
@@ -2012,6 +2023,22 @@
20122023
path = "Group layers together";
20132024
sourceTree = "<group>";
20142025
};
2026+
D70539042CD0122D00F63F4A /* c78b149a1d52414682c86a5feeb13d30 */ = {
2027+
isa = PBXGroup;
2028+
children = (
2029+
D70539032CD0122D00F63F4A /* mil2525d.stylx */,
2030+
);
2031+
path = c78b149a1d52414682c86a5feeb13d30;
2032+
sourceTree = "<group>";
2033+
};
2034+
D70539082CD0122D00F63F4A /* e0d41b4b409a49a5a7ba11939d8535dc */ = {
2035+
isa = PBXGroup;
2036+
children = (
2037+
D705390F2CD0127700F63F4A /* militaryoverlay.geodatabase */,
2038+
);
2039+
path = e0d41b4b409a49a5a7ba11939d8535dc;
2040+
sourceTree = "<group>";
2041+
};
20152042
D7058B0B2B59E44B000A888A /* Style point with scene symbol */ = {
20162043
isa = PBXGroup;
20172044
children = (
@@ -2905,6 +2932,14 @@
29052932
path = "Show coordinates in multiple formats";
29062933
sourceTree = "<group>";
29072934
};
2935+
D7F2A02C2CD00F1C0008D981 /* Apply dictionary renderer to feature layer */ = {
2936+
isa = PBXGroup;
2937+
children = (
2938+
D7F2A0292CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift */,
2939+
);
2940+
path = "Apply dictionary renderer to feature layer";
2941+
sourceTree = "<group>";
2942+
};
29082943
D7F8C0342B60564D0072BFA7 /* Add features with contingent values */ = {
29092944
isa = PBXGroup;
29102945
children = (
@@ -3180,6 +3215,7 @@
31803215
Animate3DGraphic,
31813216
AnimateImagesWithImageOverlay,
31823217
ApplyDictionaryRendererToGraphicsOverlay,
3218+
ApplyDictionaryRendererToFeatureLayer,
31833219
ApplyScheduledUpdatesToPreplannedMapArea,
31843220
AugmentRealityToShowTabletopScene,
31853221
ChangeCameraController,
@@ -3261,6 +3297,7 @@
32613297
D707899B2CD16324000DF215 /* Mil2525DMessages.xml in Resources */,
32623298
D74C8C022ABA6202007C76B8 /* emoji-mobile.stylx in Resources */,
32633299
D7CE9FA32AE2F595008F7A5F /* san-diego-eagle-locator in Resources */,
3300+
D70539102CD012BB00F63F4A /* militaryoverlay.geodatabase in Resources */,
32643301
D76000B72AF19FCA00B3084D /* SanFrancisco.mmpk in Resources */,
32653302
D762AF652BF6A96100ECE3C7 /* loudoun_anno.geodatabase in Resources */,
32663303
792222DD2A81AA5D00619FFE /* AIS_MarineCadastre_SelectedVessels_CustomDataSource.jsonl in Resources */,
@@ -3278,6 +3315,7 @@
32783315
798C2DA72AFC505600EE7E97 /* PrivacyInfo.xcprivacy in Resources */,
32793316
D7E7D09A2AEB3C47003AAD02 /* san_diego_offline_routing in Resources */,
32803317
F111CCC4288B641900205358 /* Yellowstone.mmpk in Resources */,
3318+
D705390A2CD0122D00F63F4A /* mil2525d.stylx in Resources */,
32813319
D77572AE2A295DDE00F490CD /* PacificSouthWest2 in Resources */,
32823320
D75E5EEC2CC0466900252595 /* esri_test_data.kmz in Resources */,
32833321
10D321932BDB187400B39B1B /* naperville_imagery.tpkx in Resources */,
@@ -3490,6 +3528,7 @@
34903528
1C42E04729D2396B004FC4BE /* ShowPopupView.swift in Sources */,
34913529
79302F872A1ED71B0002336A /* CreateAndSaveKMLView.Views.swift in Sources */,
34923530
D73FC0FD2AD4A18D0067A19B /* CreateMobileGeodatabaseView.swift in Sources */,
3531+
D7F2A02F2CD00F1C0008D981 /* ApplyDictionaryRendererToFeatureLayerView.swift in Sources */,
34933532
1C19B4F12A578E46001D2506 /* CreateLoadReportView.Views.swift in Sources */,
34943533
E066DD3B2860CA08004D3D5B /* ShowResultOfSpatialRelationshipsView.swift in Sources */,
34953534
7573E81E29D6134C00BEED9C /* TraceUtilityNetworkView.Views.swift in Sources */,
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright 2024 Esri
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import ArcGIS
16+
import SwiftUI
17+
18+
struct ApplyDictionaryRendererToFeatureLayerView: View {
19+
/// A map with a topographic basemap.
20+
@State private var map = Map(basemapStyle: .arcGISTopographic)
21+
22+
/// The viewpoint for zooming the map view to the feature layers.
23+
@State private var viewpoint: Viewpoint?
24+
25+
/// The error shown in the error alert.
26+
@State private var error: Error?
27+
28+
var body: some View {
29+
MapView(map: map, viewpoint: viewpoint)
30+
.task {
31+
do {
32+
// Creates the feature layers and adds them to the map when the sample opens.
33+
let featureLayers = try await makeMIL2525DFeatureLayers()
34+
map.addOperationalLayers(featureLayers)
35+
36+
// Zooms the viewpoint to the feature layers using their extents.
37+
let layerExtents = featureLayers.compactMap(\.fullExtent)
38+
if let combinedExtents = GeometryEngine.combineExtents(of: layerExtents) {
39+
viewpoint = Viewpoint(boundingGeometry: combinedExtents)
40+
}
41+
} catch {
42+
self.error = error
43+
}
44+
}
45+
.errorAlert(presentingError: $error)
46+
}
47+
48+
/// Creates a list of feature layers with mil2525d symbols.
49+
/// - Returns: A list of new `FeatureLayer` objects.
50+
private func makeMIL2525DFeatureLayers() async throws -> [FeatureLayer] {
51+
// Creates and loads a geodatabase from a local file.
52+
let geodatabase = Geodatabase(fileURL: .militaryOverlayGeodatabase)
53+
try await geodatabase.load()
54+
55+
// Creates and loads a mil2525d dictionary symbol style from a local file.
56+
let mil2525dDictionarySymbolStyle = DictionarySymbolStyle(url: .mil2525dStyleFile)
57+
try await mil2525dDictionarySymbolStyle.load()
58+
59+
// Creates feature layers from the geodatabase's feature tables.
60+
let featureLayers = geodatabase.featureTables.map { featureTable in
61+
let featureLayer = FeatureLayer(featureTable: featureTable)
62+
63+
// Sets the layer's renderer to display the features using mil2525d symbols.
64+
featureLayer.renderer = DictionaryRenderer(
65+
dictionarySymbolStyle: mil2525dDictionarySymbolStyle
66+
)
67+
featureLayer.minScale = 1000000
68+
return featureLayer
69+
}
70+
await featureLayers.load()
71+
72+
return featureLayers
73+
}
74+
}
75+
76+
private extension URL {
77+
/// The URL to the local "Joint Military Symbology MIL-STD-2525D" mobile style file.
78+
static var mil2525dStyleFile: URL {
79+
Bundle.main.url(forResource: "mil2525d", withExtension: "stylx")!
80+
}
81+
82+
/// The URL to the local "Military Overlay" geodatabase file.
83+
static var militaryOverlayGeodatabase: URL {
84+
Bundle.main.url(
85+
forResource: "militaryoverlay",
86+
withExtension: "geodatabase",
87+
subdirectory: "militaryoverlay.geodatabase"
88+
)!
89+
}
90+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Apply dictionary renderer to feature layer
2+
3+
Convert features into graphics to show them with mil2525d symbols.
4+
5+
![Image of Apply dictionary renderer to feature layer sample](apply-dictionary-renderer-to-feature-layer.png)
6+
7+
## Use case
8+
9+
A dictionary renderer uses a style file and a rule engine to display advanced symbology. This is useful for displaying features using precise military symbology.
10+
11+
## How to use the sample
12+
13+
Pan and zoom around the map. Observe the displayed military symbology on the map.
14+
15+
## How it works
16+
17+
1. Create and load a `Geodatabase` using a local ".geodatabase" file.
18+
2. Create and load a `DictionarySymbolStyle` using a style file.
19+
3. Create a `FeatureLayer` for each of the geodatabase's `featureTables`.
20+
4. Create a `DictionaryRenderer` using the dictionary symbol style and assign it to the feature layer's `renderer`.
21+
5. Add the feature layers to the map using `addOperationalLayers(_:)`.
22+
6. Load the feature layers and create a new `Envelope` from a union of the extents of all layers.
23+
7. Use the envelope to create a viewpoint and pass it to the map view.
24+
25+
## Relevant API
26+
27+
* DictionaryRenderer
28+
* DictionarySymbolStyle
29+
30+
## Offline data
31+
32+
This sample uses the [Joint Military Symbology MIL-STD-2525D style file](https://www.arcgis.com/home/item.html?id=e34835bf5ec5430da7cf16bb8c0b075c) and the [Military Overlay geodatabase](https://www.arcgis.com/home/item.html?id=e0d41b4b409a49a5a7ba11939d8535dc). Both are downloaded from ArcGIS Online automatically.
33+
34+
## Tags
35+
36+
military, symbol
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"category": "Visualization",
3+
"description": "Convert features into graphics to show them with mil2525d symbols.",
4+
"ignore": false,
5+
"images": [
6+
"apply-dictionary-renderer-to-feature-layer.png"
7+
],
8+
"keywords": [
9+
"military",
10+
"symbol",
11+
"DictionaryRenderer",
12+
"DictionarySymbolStyle"
13+
],
14+
"offline_data": [
15+
"c78b149a1d52414682c86a5feeb13d30",
16+
"e0d41b4b409a49a5a7ba11939d8535dc"
17+
],
18+
"redirect_from": [],
19+
"relevant_apis": [
20+
"DictionaryRenderer",
21+
"DictionarySymbolStyle"
22+
],
23+
"snippets": [
24+
"ApplyDictionaryRendererToFeatureLayerView.swift"
25+
],
26+
"title": "Apply dictionary renderer to feature layer"
27+
}
241 KB
Loading

0 commit comments

Comments
 (0)