Skip to content

Commit

Permalink
Merge pull request #8 from geocrystal/fix/crystal-1.10
Browse files Browse the repository at this point in the history
fix for Crystal 1.10
  • Loading branch information
mamantoha authored Oct 20, 2023
2 parents 7033d92 + 76d2453 commit 2160ac5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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

0 comments on commit 2160ac5

Please sign in to comment.