From 32b933f23113961efda625938d3bab919f6a32b0 Mon Sep 17 00:00:00 2001 From: Thomas Rasch Date: Mon, 29 Jul 2024 17:01:41 +0200 Subject: [PATCH] Added FeatureCollection.enumerateProperties() (#62) --- .../Algorithms/EnumerateProperties.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Sources/GISTools/Algorithms/EnumerateProperties.swift diff --git a/Sources/GISTools/Algorithms/EnumerateProperties.swift b/Sources/GISTools/Algorithms/EnumerateProperties.swift new file mode 100644 index 0000000..1020b3e --- /dev/null +++ b/Sources/GISTools/Algorithms/EnumerateProperties.swift @@ -0,0 +1,17 @@ +#if !os(Linux) +import CoreLocation +#endif +import Foundation + +extension FeatureCollection { + + /// Enumerate all properties in the FeatureCollection with feature index.. + /// + /// - Parameter callback: The callback function + public func enumerateProperties(_ callback: (_ featureIndex: Int, _ properties: [String: Sendable]) -> Void) { + for (featureIndex, feature) in features.enumerated() { + callback(featureIndex, feature.properties) + } + } + +}