-
Notifications
You must be signed in to change notification settings - Fork 12
[New] Apply blend renderer to hillshade #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b8b7dcf
Update project.pbxproj
des12437 e6c6174
Add new sample
des12437 2734b67
Update project.pbxproj
des12437 584d0bc
Merge branch 'v.next' into destiny/Apply-blend-renderer-to-hillshade
des12437 ec243c7
Update README.metadata.json
des12437 62d43d4
Update README.metadata.json
des12437 db58efa
Update README.md
des12437 37536e7
Update README.md
des12437 0f8254c
Update offline data section
des12437 9afb926
Update README.metadata.json
des12437 8b053e4
Update README.md
des12437 0591457
Remove view model
des12437 77d644f
Address PR feedback
des12437 26d4543
Merge branch 'v.next' into destiny/Apply-blend-renderer-to-hillshade
des12437 8fa033d
Update project.pbxproj
des12437 9bfcf3b
Move struct
des12437 d48cba2
Address PR feedback
des12437 0e38a14
Set color ramp on elevation basemap
des12437 5605ac5
Merge branch 'v.next' into destiny/Apply-blend-renderer-to-hillshade
des12437 af67925
Update ApplyBlendRendererToHillshadeView.swift
des12437 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...d/Samples/Apply blend renderer to hillshade/ApplyBlendRendererToHillshadeView.Model.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright 2025 Esri | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import ArcGIS | ||
| import SwiftUI | ||
|
|
||
| extension ApplyBlendRendererToHillshadeView { | ||
| /// The view model for the sample. | ||
| class Model: ObservableObject { | ||
| /// A map with a Shasta raster layer. | ||
| @Published var map: Map = { | ||
| let raster = Raster(fileURL: .shasta) | ||
| let rasterLayer = RasterLayer(raster: raster) | ||
| return Map(basemap: Basemap(baseLayer: rasterLayer)) | ||
| }() | ||
|
|
||
| /// The raster layer. | ||
| private var rasterLayer: RasterLayer { | ||
| map.basemap?.baseLayers[0] as! RasterLayer | ||
| } | ||
|
|
||
| /// The elevation raster. | ||
| private let elevationRaster: Raster = { | ||
| Raster(fileURL: .shastaElevation) | ||
| }() | ||
|
|
||
| /// The blend renderer altitude. | ||
| @Published var altitude = 0.0 | ||
|
|
||
| /// The blend renderer azimuth. | ||
| @Published var azimuth = 0.0 | ||
|
|
||
| /// The blend renderer slope type. | ||
| @Published var slopeType: HillshadeRenderer.SlopeType? | ||
|
|
||
| /// The blend renderer color ramp preset. | ||
| @Published var colorRampPreset: ColorRamp.Preset? | ||
|
|
||
| /// The color ramp for the blend renderer. | ||
| private var colorRamp: ColorRamp? { | ||
| if let colorRampPreset { | ||
| ColorRamp(preset: colorRampPreset, size: 800) | ||
| } else { | ||
| .none | ||
| } | ||
| } | ||
|
|
||
| /// Applies the settings to the blend renderer on the raster layer. | ||
| func applyRendererSettings() { | ||
| let blendRenderer = BlendRenderer( | ||
| elevationRaster: elevationRaster, | ||
| outputMinValues: [], | ||
| outputMaxValues: [], | ||
| sourceMinValues: [], | ||
| sourceMaxValues: [], | ||
| noDataValues: [], | ||
| gammas: [], | ||
| colorRamp: colorRamp, | ||
| altitude: altitude, | ||
| azimuth: azimuth, | ||
| slopeType: slopeType | ||
| ) | ||
|
|
||
| // Apply blend renderer to raster layer. | ||
| rasterLayer.renderer = blendRenderer | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension URL { | ||
| /// The URL to the Shasta data. | ||
| static var shasta: URL { | ||
| Bundle.main.url(forResource: "Shasta", withExtension: "tif", subdirectory: "raster-file/raster-file")! | ||
| } | ||
|
|
||
| /// The URL to the Shasta elevation data. | ||
| static var shastaElevation: URL { | ||
| Bundle.main.url(forResource: "Shasta_Elevation", withExtension: "tif", subdirectory: "Shasta_Elevation")! | ||
| } | ||
| } | ||
83 changes: 83 additions & 0 deletions
83
...es/Apply blend renderer to hillshade/ApplyBlendRendererToHillshadeView.SettingsView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Copyright 2025 Esri | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import ArcGIS | ||
| import SwiftUI | ||
|
|
||
| extension ApplyBlendRendererToHillshadeView { | ||
| struct SettingsView: View { | ||
| /// The action to dismiss the view. | ||
| @Environment(\.dismiss) private var dismiss | ||
|
|
||
| /// The view model for the sample. | ||
| @ObservedObject var model: ApplyBlendRendererToHillshadeView.Model | ||
|
|
||
| var body: some View { | ||
| NavigationStack { | ||
| Form { | ||
| Picker("Slope Type", selection: $model.slopeType) { | ||
| Text("Degree").tag(HillshadeRenderer.SlopeType.degree) | ||
| Text("Percent Rise").tag(HillshadeRenderer.SlopeType.percentRise) | ||
| Text("Scaled").tag(HillshadeRenderer.SlopeType.scaled) | ||
| } | ||
|
|
||
| Picker("Color Ramp Preset", selection: $model.colorRampPreset) { | ||
| Text("DEM Light").tag(ColorRamp.Preset.demLight) | ||
| Text("Screen Display").tag(ColorRamp.Preset.demScreen) | ||
| Text("Elevation").tag(ColorRamp.Preset.elevation) | ||
| } | ||
des12437 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| VStack { | ||
| LabeledContent( | ||
| "Altitude", | ||
| value: model.altitude, | ||
| format: .number | ||
des12437 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| Slider(value: $model.altitude, in: 0...360, step: 1.0) { | ||
| Text("Altitude") | ||
| } minimumValueLabel: { | ||
| Text("0") | ||
| } maximumValueLabel: { | ||
| Text("360") | ||
| } | ||
| } | ||
|
|
||
| VStack { | ||
| LabeledContent( | ||
| "Azimuth", | ||
| value: model.azimuth, | ||
| format: .number | ||
des12437 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| Slider(value: $model.azimuth, in: 0...360, step: 1.0) { | ||
| Text("Azimuth") | ||
| } minimumValueLabel: { | ||
| Text("0") | ||
| } maximumValueLabel: { | ||
| Text("360") | ||
| } | ||
| } | ||
| } | ||
| .navigationTitle("Renderer Settings") | ||
| .navigationBarTitleDisplayMode(.inline) | ||
| .toolbar { | ||
| ToolbarItem(placement: .confirmationAction) { | ||
| Button("Done") { | ||
| dismiss() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.