Skip to content

Commit

Permalink
Shortcut for centroid if the object has only one coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Sep 9, 2024
1 parent a8118bc commit 96aeecd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/GISTools/Algorithms/Center.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ extension GeoJson {
public var centroid: Point? {
let allCoordinates = self.allCoordinates

guard !allCoordinates.isEmpty else { return nil }
guard allCoordinates.isNotEmpty else { return nil }

if allCoordinates.count == 1 {
return Point(allCoordinates[0])
}

var sumLongitude: Double = 0.0
var sumLatitude: Double = 0.0
Expand Down

0 comments on commit 96aeecd

Please sign in to comment.