Skip to content

Commit

Permalink
fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sethdeckard committed Jul 26, 2016
1 parent b61f854 commit e50cc79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/gull/polygon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ def to_s
coordinates.map { |pair| pair.join(',') }.join(' ')
end

# Returns well-known text (WKT) formatted polygon
def to_wkt
# WKT pairs are (x, y), so put longitude first
pairs_wkt = coordinates.map { |pair| "#{pair.last} #{pair.first}" }.join(', ')
"POLYGON((#{pairs_wkt}))"
pairs = coordinates.map { |pair| "#{pair.last} #{pair.first}" }
.join(', ')
"POLYGON((#{pairs}))"
end

private
Expand Down
7 changes: 3 additions & 4 deletions spec/polygon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@
'34.64,-97.11 34.64,-97.14 34.62,-97.14 34.62,-97.2 34.6,-97.19 34.59,' \
'-97.17 34.57,-97.17 34.5,-97.3 34.51,-97.56 34.57,-97.56'

wkt_text = 'POLYGON((-97.56 34.57, -97.38 34.77, -97.17 34.75, -97.11 34.64, ' \
'-97.14 34.64, -97.14 34.62, -97.2 34.62, -97.19 34.6, -97.17 34.59, ' \
'-97.17 34.57, -97.3 34.5, -97.56 34.51, -97.56 34.57))'
wkt_text = 'POLYGON((-97.56 34.57, -97.38 34.77, -97.17 34.75,' \
' -97.11 34.64, -97.14 34.64, -97.14 34.62, -97.2 34.62, -97.19 34.6,' \
' -97.17 34.59, -97.17 34.57, -97.3 34.5, -97.56 34.51, -97.56 34.57))'

polygon = Gull::Polygon.new text
expect(polygon.to_wkt).to eq wkt_text
end
end

0 comments on commit e50cc79

Please sign in to comment.