Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for Crystal 1.10 #8

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019-2022 Anton Maminov
Copyright (c) 2019-2023 Anton Maminov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
github: geocrystal/haversine
convex_hull:
github: geocrystal/convex_hull
version: ">= 0.6.0"
geohash:
github: geocrystal/geohash

Expand Down
9 changes: 7 additions & 2 deletions src/geo/coord.cr
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,17 @@ module Geo
# pos.strfcoord('%latd %latm %0.5lats') # => "0 1 59.99880"
# pos.strfcoord('%latd %latm %lats') # => "0 2 0"
# ```
def strfcoord(formatstr)
def strfcoord(formatstr) : String
h = full_hash

DIRECTIVES.reduce(formatstr) do |memo, (from, to)|
memo.gsub(from) do
to = to.call($~) if to.is_a?(Proc)
to =
if to.is_a?(Proc) && from.is_a?(Regex) && (match_data = memo.match(from))
to.call(match_data)
else
to.as(String)
end

res = to % h

Expand Down
2 changes: 1 addition & 1 deletion src/geo/polygon.cr
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module Geo
private def make_convex_hull(coords : Array(Geo::Coord))
points = @coords.map { |coord| {coord.lat, coord.lng} }
convex_hull = ConvexHull::GrahamScan.new(points)
hull = convex_hull.convex_hull
hull = convex_hull.to_a

hull.map { |point| Geo::Coord.new(point.x.as(Float32 | Float64), point.y.as(Float32 | Float64)) }
end
Expand Down
Loading