Skip to content
Open
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 lib/geo_ruby/gpx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def as_line_string
# If the GPX isn't closed, a line from the first
# to the last point will be created to close it.
def as_polygon
GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : @points.push(@points[0].clone)])
GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])
end

# Return GPX Envelope
Expand Down
5 changes: 5 additions & 0 deletions spec/geo_ruby/gpx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
expect(@gpxfile[0].y).to be_within(0.0001).of(48.731813)
end

it 'should point last record to last waypoint' do
expect(@gpxfile[-1].x).to be_within(0.0001).of(9.09436)
expect(@gpxfile[-1].y).to be_within(0.0001).of(48.731805)
end

it 'should read Z and M' do
expect(@gpxfile[0].z).to eql(468.0)
expect(@gpxfile[0].m).to eql('2008-09-07T17:36:57Z')
Expand Down