Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Dec 4, 2023
1 parent 09ef507 commit 199a6b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Sources/GISTools/Algorithms/FrechetDistance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ extension LineString {
/// Fréchet distance between to geometries.
///
/// - Parameters:
/// - from: The other geometry of equal type
/// - distanceFunction: The algorithm to use for distance calculations
/// - segmentLength: Adds coordinates to the lines for improved matching (in meters)
/// - from: The other geometry of equal type.
/// - distanceFunction: The algorithm to use for distance calculations.
/// - segmentLength: Adds coordinates to the lines for improved matching (in meters).
///
/// - Returns: The frechet distance between the to geometries
/// - Returns: The frechet distance between the two geometries.
public func frechetDistance(
from other: LineString,
distanceFunction: FrechetDistanceFunction = .haversine,
Expand Down
12 changes: 11 additions & 1 deletion Sources/GISTools/Algorithms/LineChunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension LineString {
return LineString()
}

return LineString(chunked(segmentLength: segmentLength).lineSegments) ?? LineString()
return LineString(chunked(segmentLength: segmentLength).lineSegments) ?? self
}

}
Expand All @@ -56,6 +56,16 @@ extension MultiLineString {
MultiLineString(lineStrings.flatMap({ $0.chunked(segmentLength: segmentLength).lineStrings })) ?? self
}

/// Divides a *MultiLineString* into evenly spaced segments of a specified length.
/// If the line is shorter than the segment length then the original line is returned.
///
/// - Parameter segmentLength: How long to make each segment, in meters
public func evenlyDivided(segmentLength: CLLocationDistance) -> MultiLineString {
MultiLineString(lineStrings.map({
LineString($0.chunked(segmentLength: segmentLength).lineSegments) ?? $0
})) ?? self
}

}

extension Feature {
Expand Down

0 comments on commit 199a6b0

Please sign in to comment.