Skip to content

Commit

Permalink
Merge pull request #4 from beaorn/polygon-fill-fix
Browse files Browse the repository at this point in the history
Polygon fill fix for holes
  • Loading branch information
brycejohnston authored Sep 25, 2018
2 parents 0e5fc3d + b9df43e commit 1a2222c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/geojson2image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,18 @@ def draw(json, properties = nil)
end
end

border_points = []
json['coordinates'].each do |linestrings|
border_points = []
if linestrings[0] != linestrings[linestrings.count - 1]
linestrings << linestrings[0]
end

linestrings.each do |point|
new_point = transform_point(point)
border_points << "#{new_point[0]},#{new_point[1]}"
end

points = ChunkyPNG::Vector.multiple_from_string(border_points.join(", "))
@png.polygon(points, tmp_stroke, tmp_fill)
end
points = ChunkyPNG::Vector.multiple_from_string(border_points.join(", "))
@png.polygon(points, tmp_stroke, tmp_fill)

when 'MultiPolygon'
json['coordinates'].each do |polygon|
Expand Down
2 changes: 1 addition & 1 deletion lib/geojson2image/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Geojson2image
VERSION = "0.2.1"
VERSION = "0.2.2"
end

0 comments on commit 1a2222c

Please sign in to comment.