Skip to content

Commit fe00e12

Browse files
CalebRasphilium
andauthored
Apply suggestions from code review
Co-authored-by: Philip Ridgeway <[email protected]>
1 parent 770e65b commit fe00e12

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

Shared/Samples/Snap geometry edits with utility network rules/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ A field worker can create new features in a utility network by editing and snapp
1212

1313
To edit a geometry, tap a feature on the map to select it and press the edit button to start the geometry editor.
1414

15-
Tap the "Snap Sources" button to view and enable/disable the snap sources. To interactively snap a vertex to a feature or graphic, ensure that snapping is enabled for the relevant snap source, then drag a vertex to nearby an existing feature or graphic. If the existing feature or graphic has valid utility network connectivity rules for the asset type that is being created or edited, the edit position will be adjusted to coincide with (or snap to) edges and vertices of its geometry. Tap to place the vertex at the snapped location. Snapping will not occur when `SnapRuleBehavior.rulesPreventSnapping` even when the source is enabled.
15+
Tap the "Snap Sources" button to view and enable/disable the snap sources. To interactively snap a vertex to a feature or graphic, ensure that snapping is enabled for the relevant snap source, then drag a vertex to nearby an existing feature or graphic. If the existing feature or graphic has valid utility network connectivity rules for the asset type that is being created or edited, the edit position will be adjusted to coincide with (or snap to) edges and vertices of its geometry. Tap to place the vertex at the snapped location. Snapping will not occur when `SnapRuleBehavior.rulesPreventSnapping` is `true`, even when the source is enabled.
1616

17-
To discard changes and stop the geometry editor, press the cancel button. To save your edits, press the save button.
17+
To discard changes and stop the geometry editor, press the Cancel (X) button. To save your edits, press the Save (✔️) button.
1818

1919
## How it works
2020

Shared/Samples/Snap geometry edits with utility network rules/SnapGeometryEditsWithUtilityNetworkRulesView.Model.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ extension SnapGeometryEditsWithUtilityNetworkRulesView {
123123
"Excess Flow Valve",
124124
"Controllable Tee"
125125
]
126-
for sublayer in lineLayer.subtypeSublayers + deviceLayer.subtypeSublayers {
127-
if !visibleSublayerNames.contains(sublayer.name) {
128-
sublayer.isVisible = false
129-
}
126+
let sublayers = lineLayer.subtypeSublayers + deviceLayer.subtypeSublayers
127+
for sublayer in sublayers where !visibleSublayerNames.contains(sublayer.name) {
128+
sublayer.isVisible = false
130129
}
131130
}
132131

@@ -187,16 +186,18 @@ extension SnapGeometryEditsWithUtilityNetworkRulesView {
187186
}
188187

189188
// Hides the selected feature on the layer.
190-
let featureTable = selectedFeature.table as? ArcGISFeatureTable
191-
let featureLayer = featureTable?.layer as? FeatureLayer
192-
featureLayer?.setVisible(false, for: selectedFeature)
193-
194-
// Gets the selected feature's symbol and uses it to set the tool's style.
195-
let symbol = featureTable?.layerInfo?.drawingInfo?.renderer?.symbol(for: selectedFeature)
196-
vertexTool.style.vertexSymbol = symbol
197-
vertexTool.style.feedbackVertexSymbol = symbol
198-
vertexTool.style.selectedVertexSymbol = symbol
199-
vertexTool.style.vertexTextSymbol = nil
189+
if let featureTable = selectedFeature.table as? ArcGISFeatureTable {
190+
if let featureLayer = featureTable.layer as? FeatureLayer {
191+
featureLayer.setVisible(false, for: selectedFeature)
192+
}
193+
194+
// Gets the selected feature's symbol and uses it to set the tool's style.
195+
let symbol = featureTable.layerInfo?.drawingInfo?.renderer?.symbol(for: selectedFeature)
196+
vertexTool.style.vertexSymbol = symbol
197+
vertexTool.style.feedbackVertexSymbol = symbol
198+
vertexTool.style.selectedVertexSymbol = symbol
199+
vertexTool.style.vertexTextSymbol = nil
200+
}
200201

201202
geometryEditor.tool = vertexTool
202203
geometryEditor.start(withInitial: geometry)
@@ -234,7 +235,7 @@ extension SnapGeometryEditsWithUtilityNetworkRulesView {
234235
_ settings: [SnapSourceSettings]
235236
) -> [SnapSourceSettings] {
236237
let sourceNames: Set<String> = [.distributionPipe, .graphics, .pipelineLine, .servicePipe]
237-
return settings.reduce(into: [SnapSourceSettings]()) { result, setting in
238+
return settings.reduce(into: []) { result, setting in
238239
guard sourceNames.contains(setting.source.name) else {
239240
return
240241
}

Shared/Samples/Snap geometry edits with utility network rules/SnapGeometryEditsWithUtilityNetworkRulesView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ extension SnapSource {
252252
}
253253
}
254254

255-
extension SnapRuleBehavior? {
255+
extension Optional<SnapRuleBehavior> {
256256
fileprivate static var allCases: [Self] {
257-
return [nil, .rulesLimitSnapping, .rulesPreventSnapping]
257+
return [.none, .rulesLimitSnapping, .rulesPreventSnapping]
258258
}
259259

260260
/// The human-readable label for the snap rule behavior.

0 commit comments

Comments
 (0)