<feed xmlns='http://www.w3.org/2005/Atom'>
<title>chouette-core/lib/tom_tom/matrix, branch master</title>
<subtitle>Chouette manage transport static data</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/fork/chouette-core/'/>
<entry>
<title>TomTom::Matrix: Serialize `BigDecimal` as float</title>
<updated>2018-03-27T14:46:18+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-27T13:24:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/fork/chouette-core/commit/?id=c17665c0cc064c8a14af812dedd645977d110388'/>
<id>c17665c0cc064c8a14af812dedd645977d110388</id>
<content type='text'>
Rails serialises `BigDecimal`s as JSON strings to prevent loss of
precision. The `latitude` and `longitude` columns in `StopArea` are
stored as `BigDecimal`s. The trouble is that TomTom's API requires the
latitude &amp; longitude values to be JSON floats, not strings.

Make a new JSON serialiser that converts the `BigDecimal` coordinates to
float to allow the values to be correctly interpreted by the API.

Refs #6222
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Rails serialises `BigDecimal`s as JSON strings to prevent loss of
precision. The `latitude` and `longitude` columns in `StopArea` are
stored as `BigDecimal`s. The trouble is that TomTom's API requires the
latitude &amp; longitude values to be JSON floats, not strings.

Make a new JSON serialiser that converts the `BigDecimal` coordinates to
float to allow the values to be correctly interpreted by the API.

Refs #6222
</pre>
</div>
</content>
</entry>
<entry>
<title>TomTom::Matrix#points_from_way_costs: Use array instead of set</title>
<updated>2018-03-27T14:46:18+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-26T13:52:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/fork/chouette-core/commit/?id=ebd46f068fbf11ea8793e9f7982b3a5291e21398'/>
<id>ebd46f068fbf11ea8793e9f7982b3a5291e21398</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>TomTom::Matrix#points_from_way_costs: Include stop IDs with points</title>
<updated>2018-03-27T14:46:18+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-23T16:01:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/fork/chouette-core/commit/?id=e2cbcdb4dc32db05e2c6d7a7bb57952e1da6dab3'/>
<id>e2cbcdb4dc32db05e2c6d7a7bb57952e1da6dab3</id>
<content type='text'>
We need to persist stop IDs in order to properly construct `WayCost`
objects from the costs returned from the TomTom matrix API.

In order to persist stop IDs, my idea here is to group together a point
and its corresponding ID into a bucket. When we later
`#extract_costs_to_way_costs!`, we'll be able to grab the correct ID for
a given coordinate to create a `WayCost` from it.

Here, we create a new `TomTom::Matrix::Point` class that encapsulates a
coordinate and an ID, and build a `Set` of those. I needed an `#eql?`
and `#hash` method on `Point` as described in the `Set` documentation
(https://ruby-doc.org/stdlib-1.9.3/libdoc/set/rdoc/Set.html) in order to
properly maintain a unique set.

Refs #6222
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We need to persist stop IDs in order to properly construct `WayCost`
objects from the costs returned from the TomTom matrix API.

In order to persist stop IDs, my idea here is to group together a point
and its corresponding ID into a bucket. When we later
`#extract_costs_to_way_costs!`, we'll be able to grab the correct ID for
a given coordinate to create a `WayCost` from it.

Here, we create a new `TomTom::Matrix::Point` class that encapsulates a
coordinate and an ID, and build a `Set` of those. I needed an `#eql?`
and `#hash` method on `Point` as described in the `Set` documentation
(https://ruby-doc.org/stdlib-1.9.3/libdoc/set/rdoc/Set.html) in order to
properly maintain a unique set.

Refs #6222
</pre>
</div>
</content>
</entry>
</feed>
