diff --git a/Examples/Cassini/ContentView+Model.swift b/Examples/Cassini/ContentView+Model.swift index 7f4ab97..3db3851 100644 --- a/Examples/Cassini/ContentView+Model.swift +++ b/Examples/Cassini/ContentView+Model.swift @@ -25,8 +25,24 @@ extension ContentView { case naturalEarth case orthographic case azimuthal - + var id: String { rawValue } + + /// Whether the projection's output depends on the reference latitude. + var usesReferenceLatitude: Bool { + switch self { + case .orthographic, .azimuthal: return true + case .equirectangular, .cassini, .mercator, .gallPeters, .equalEarth, .naturalEarth: return false + } + } + + /// Whether the projection's output depends on the reference longitude. + var usesReferenceLongitude: Bool { + switch self { + case .cassini: return false + case .equirectangular, .mercator, .gallPeters, .equalEarth, .naturalEarth, .orthographic, .azimuthal: return true + } + } } struct Layer: Identifiable { diff --git a/Examples/Cassini/ContentView.swift b/Examples/Cassini/ContentView.swift index 527351a..28e5e8d 100644 --- a/Examples/Cassini/ContentView.swift +++ b/Examples/Cassini/ContentView.swift @@ -203,25 +203,27 @@ struct OptionsView: View { .frame(width: 100, alignment: .trailing) } .frame(minWidth: 200) - + TextField(value: $model.refLat, format: .number.precision(.fractionLength(1))) { EmptyView() } .frame(maxWidth: 55) } - + .disabled(!model.projectionType.usesReferenceLatitude) + HStack { Slider(value: $model.refLng, in: -180...180) { Text("Longitude") .frame(width: 100, alignment: .trailing) } .frame(minWidth: 200) - + TextField(value: $model.refLng, format: .number.precision(.fractionLength(1))) { EmptyView() } .frame(maxWidth: 55) } + .disabled(!model.projectionType.usesReferenceLongitude) } GroupBox("Edge Insets") {