Landmark.swift 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. See LICENSE folder for this sample’s licensing information.
  3. Abstract:
  4. The model for an individual landmark.
  5. */
  6. import SwiftUI
  7. import CoreLocation
  8. struct Landmark: Hashable, Codable {
  9. var id: Int
  10. var name: String
  11. fileprivate var imageName: String
  12. fileprivate var coordinates: Coordinates
  13. var state: String
  14. var park: String
  15. var category: Category
  16. var locationCoordinate: CLLocationCoordinate2D {
  17. CLLocationCoordinate2D(
  18. latitude: coordinates.latitude,
  19. longitude: coordinates.longitude)
  20. }
  21. enum Category: String, CaseIterable, Codable, Hashable {
  22. case featured = "Featured"
  23. case lakes = "Lakes"
  24. case rivers = "Rivers"
  25. }
  26. }
  27. extension Landmark {
  28. var image: Image {
  29. ImageStore.shared.image(name: imageName)
  30. }
  31. }
  32. struct Coordinates: Hashable, Codable {
  33. var latitude: Double
  34. var longitude: Double
  35. }