diff options
| author | Teddy Wing | 2018-03-26 15:52:43 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-03-27 16:46:18 +0200 |
| commit | ebd46f068fbf11ea8793e9f7982b3a5291e21398 (patch) | |
| tree | 2d2fa975fb936b130f0df7e5ba735cbb51280ceb /spec | |
| parent | ddfc41f75cb52f02511e2acd6429270bc9c0ab19 (diff) | |
| download | chouette-core-ebd46f068fbf11ea8793e9f7982b3a5291e21398.tar.bz2 | |
TomTom::Matrix#points_from_way_costs: Use array instead of set
Using a set ended up not working out. I needed to be able to index into
the list in `#extract_costs_to_way_costs!`, and sets aren't indexable.
This is because they're supposed to be unordered, though modern Ruby
implements `Set` with `Hash` under the hood, which is ordered in Ruby.
I like the idea of having a data structure that automatically eliminates
duplicates, but it wasn't meant to be, because for the extraction to
`WayCost`s, I need an ordered list. Rather than create a new
`OrderedSet` type, I just went the simple route and used an Array,
eliminating the duplicates manually because I know when duplicates are
supposed to occur due to the nature of the data set.
Remove the `#eql?` and `#hash` methods from `TomTom::Matrix::Point`.
Because we're not longer using `Set`, these methods don't need to be
implemented.
Refs #6222
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/tom_tom/matrix_spec.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/spec/lib/tom_tom/matrix_spec.rb b/spec/lib/tom_tom/matrix_spec.rb index e67e539b7..b63ebc70b 100644 --- a/spec/lib/tom_tom/matrix_spec.rb +++ b/spec/lib/tom_tom/matrix_spec.rb @@ -18,7 +18,7 @@ RSpec.describe TomTom::Matrix do expect( matrix.points_from_way_costs(way_costs) - ).to eq(Set.new([ + ).to eq([ TomTom::Matrix::Point.new( Geokit::LatLng.new(48.85086, 2.36143), '44' @@ -31,13 +31,13 @@ RSpec.describe TomTom::Matrix do Geokit::LatLng.new(52.50867, 13.42879), '88' ) - ])) + ]) end end describe "#points_as_params" do it "transforms a set of LatLng points into a hash for use by TomTom Matrix" do - points = Set.new([ + points = [ TomTom::Matrix::Point.new( Geokit::LatLng.new(48.85086, 2.36143), '44' @@ -50,7 +50,7 @@ RSpec.describe TomTom::Matrix do Geokit::LatLng.new(52.50867, 13.42879), '88' ) - ]) + ] expect( matrix.points_as_params(points) |
