Skip to content

Add Hex Coordinates #1

Open
timskap wants to merge 5 commits intobdotdub:masterfrom
timskap:master
Open

Add Hex Coordinates #1
timskap wants to merge 5 commits intobdotdub:masterfrom
timskap:master

Conversation

@timskap
Copy link

@timskap timskap commented Mar 15, 2024

Example:


struct HashableCLLocationCoordinate2D: Hashable {
    let latitude: Double
    let longitude: Double
    
    init(_ coordinate: CLLocationCoordinate2D) {
        self.latitude = coordinate.latitude
        self.longitude = coordinate.longitude
    }
}

let resolution = 5
            let ringSize = 30
            let h3Index = H3Index(coordinate: H3Coordinate(lat: locationCoordinate.latitude, lon: locationCoordinate.longitude), resolution: Int32(resolution))
            let ringIndexes = h3Index.kRingIndices(ringK: Int32(ringSize))
            
            hexCoordinates = ringIndexes.map { index in
                let coordinates = index.boundary()
                return coordinates.map { coordinate in
                    HashableCLLocationCoordinate2D(CLLocationCoordinate2D(latitude: coordinate.lat, longitude: coordinate.lon))
                }
            }

@plz-review
Copy link

plz-review bot commented Mar 15, 2024

Plz Review!
Review this PR using plz

@timskap
Copy link
Author

timskap commented May 23, 2025

I fix an issue with stdrup in file. Should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants