From f7b0f745dc67c3c5bd75a4e0a05f940089989cbb Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Fri, 2 Oct 2015 13:56:01 -0400 Subject: [PATCH 1/6] cosmetic updates for locate service changes --- app/models/stop.rb | 2 +- .../conflate_stops_with_osm_worker_spec.rb | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/models/stop.rb b/app/models/stop.rb index 557a39f8a..8202109d6 100644 --- a/app/models/stop.rb +++ b/app/models/stop.rb @@ -213,7 +213,7 @@ def self.conflate_with_osm(stops) end tyr_locate_response = TyrService.locate(locations: locations) group.each_with_index do |stop, index| - way_id = tyr_locate_response[index][:ways][0][:way_id] + way_id = tyr_locate_response[index][:edges][0][:way_id] stop_tags = stop.tags.try(:clone) || {} stop_tags[:osm_way_id] = way_id stop.update(tags: stop_tags) diff --git a/spec/workers/conflate_stops_with_osm_worker_spec.rb b/spec/workers/conflate_stops_with_osm_worker_spec.rb index 932fb0b51..c25bbd9e4 100644 --- a/spec/workers/conflate_stops_with_osm_worker_spec.rb +++ b/spec/workers/conflate_stops_with_osm_worker_spec.rb @@ -11,20 +11,44 @@ { input_lon: -122.413601, input_lat: 37.775692, - ways: [{ - correlated_lon: -122.413601, - way_id: 8917801, - correlated_lat: 37.775692 - }] + node: nil, + edges: [ + { + correlated_lon: -122.413601, + way_id: 8917801, + correlated_lat: 37.775692, + side_of_street: "right", + percent_along: .63 + }, + { + correlated_lon: -122.413601, + way_id: 8917801, + correlated_lat: 37.775692, + side_of_street: "left", + percent_along: .37 + } + ] }, { input_lon: -122.396431, input_lat: 37.793152, - ways: [{ - correlated_lon: -122.413601, - way_id: 8917802, - correlated_lat: 37.775692 - }] + node: nil, + edges: [ + { + correlated_lon: -122.413601, + way_id: 8917802, + correlated_lat: 37.775692 + side_of_street: "right", + percent_along: .82 + }, + { + correlated_lon: -122.413601, + way_id: 8917802, + correlated_lat: 37.775692 + side_of_street: "left", + percent_along: .18 + } + ] } ]) worker = ConflateStopsWithOsmWorker.new From 953bec430e265cdd557a2ead028d257c1c4a6333 Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Fri, 2 Oct 2015 14:01:45 -0400 Subject: [PATCH 2/6] lint --- .../conflate_stops_with_osm_worker_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/workers/conflate_stops_with_osm_worker_spec.rb b/spec/workers/conflate_stops_with_osm_worker_spec.rb index c25bbd9e4..f07aa7de1 100644 --- a/spec/workers/conflate_stops_with_osm_worker_spec.rb +++ b/spec/workers/conflate_stops_with_osm_worker_spec.rb @@ -17,15 +17,15 @@ correlated_lon: -122.413601, way_id: 8917801, correlated_lat: 37.775692, - side_of_street: "right", - percent_along: .63 + side_of_street: 'right', + percent_along: 0.63 }, { correlated_lon: -122.413601, way_id: 8917801, correlated_lat: 37.775692, - side_of_street: "left", - percent_along: .37 + side_of_street: 'left', + percent_along: 0.37 } ] }, @@ -38,15 +38,15 @@ correlated_lon: -122.413601, way_id: 8917802, correlated_lat: 37.775692 - side_of_street: "right", - percent_along: .82 + side_of_street: 'right', + percent_along: 0.82 }, { correlated_lon: -122.413601, way_id: 8917802, correlated_lat: 37.775692 - side_of_street: "left", - percent_along: .18 + side_of_street: 'left', + percent_along: 0.18 } ] } From 4d4c6470e89ac3c7095c3e7774ec1c16514c4d6c Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Fri, 2 Oct 2015 15:25:49 -0400 Subject: [PATCH 3/6] update cassetts --- spec/support/vcr_cassettes/tyr_one_location.yml | 2 +- spec/support/vcr_cassettes/tyr_two_locations.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/support/vcr_cassettes/tyr_one_location.yml b/spec/support/vcr_cassettes/tyr_one_location.yml index 5112019e2..93349e70e 100644 --- a/spec/support/vcr_cassettes/tyr_one_location.yml +++ b/spec/support/vcr_cassettes/tyr_one_location.yml @@ -44,7 +44,7 @@ http_interactions: - keep-alive body: encoding: UTF-8 - string: '[{"input_lon":-122.413605,"ways":[{"correlated_lon":-122.413605,"way_id":8917801,"correlated_lat":37.775692}],"input_lat":37.775692}]' + string: '[{"input_lon":-122.413605,"node":null,"edges":[{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"left","percent_along":0.39047,"correlated_lon":-122.413521},{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"right","percent_along":0.60953,"correlated_lon":-122.413521}],"input_lat":37.775692}]' http_version: recorded_at: Thu, 28 May 2015 18:45:11 GMT recorded_with: VCR 2.9.3 diff --git a/spec/support/vcr_cassettes/tyr_two_locations.yml b/spec/support/vcr_cassettes/tyr_two_locations.yml index c8ce68492..48bf27979 100644 --- a/spec/support/vcr_cassettes/tyr_two_locations.yml +++ b/spec/support/vcr_cassettes/tyr_two_locations.yml @@ -44,7 +44,7 @@ http_interactions: - keep-alive body: encoding: UTF-8 - string: '[{"input_lon":-122.413605,"ways":[{"correlated_lon":-122.413605,"way_id":8917801,"correlated_lat":37.775692}],"input_lat":37.775692},{"input_lon":-73.990471,"ways":[{"correlated_lon":-73.990471,"way_id":5671311,"correlated_lat":40.744549}],"input_lat":40.744549}]' + string: '[{"input_lon":-122.413605,"node":null,"edges":[{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"left","percent_along":0.39047,"correlated_lon":-122.413521},{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"right","percent_along":0.60953,"correlated_lon":-122.413521}],"input_lat":37.775692},{"input_lon":-73.990471,"node":null,"edges":[{"way_id":5671311,"correlated_lat":40.744427,"side_of_street":"right","percent_along":0.87621,"correlated_lon":-73.990524},{"way_id":5671311,"correlated_lat":40.744427,"side_of_street":"left","percent_along":0.12379,"correlated_lon":-73.990524}],"input_lat":40.744549}]' http_version: recorded_at: Thu, 28 May 2015 18:45:11 GMT recorded_with: VCR 2.9.3 From 6f13ba3bd78d3af39b3e2ee731f218e2f09f5f4c Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Fri, 2 Oct 2015 15:30:26 -0400 Subject: [PATCH 4/6] missing comma --- spec/workers/conflate_stops_with_osm_worker_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/workers/conflate_stops_with_osm_worker_spec.rb b/spec/workers/conflate_stops_with_osm_worker_spec.rb index f07aa7de1..01d726134 100644 --- a/spec/workers/conflate_stops_with_osm_worker_spec.rb +++ b/spec/workers/conflate_stops_with_osm_worker_spec.rb @@ -37,14 +37,14 @@ { correlated_lon: -122.413601, way_id: 8917802, - correlated_lat: 37.775692 + correlated_lat: 37.775692, side_of_street: 'right', percent_along: 0.82 }, { correlated_lon: -122.413601, way_id: 8917802, - correlated_lat: 37.775692 + correlated_lat: 37.775692, side_of_street: 'left', percent_along: 0.18 } From ff1cd3073a4178d59f84505ab581ae1a75d7f935 Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Wed, 7 Oct 2015 13:23:51 -0400 Subject: [PATCH 5/6] update expected --- spec/services/tyr_service_spec.rb | 66 ++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/spec/services/tyr_service_spec.rb b/spec/services/tyr_service_spec.rb index 9196c957b..7c16a7ab0 100644 --- a/spec/services/tyr_service_spec.rb +++ b/spec/services/tyr_service_spec.rb @@ -16,11 +16,23 @@ expect(response).to eq [ { input_lon: -122.413605, - ways: [{ - correlated_lon: -122.413605, - way_id: 8917801, - correlated_lat: 37.775692 - }], + node: nil, + edges:[ + { + way_id: 8917801, + correlated_lat: 37.775589, + side_of_street: "left", + percent_along: 0.39047, + correlated_lon: -122.413521 + }, + { + way_id: 8917801, + correlated_lat: 37.775589, + side_of_street: "right", + percent_along: 0.60953, + correlated_lon: -122.413521 + } + ], input_lat: 37.775692 } ] @@ -42,19 +54,43 @@ expect(response).to eq [ { input_lon: -122.413605, - ways: [{ - correlated_lon: -122.413605, - way_id: 8917801, - correlated_lat: 37.775692 - }], + node: null, + edges: [ + { + way_id: 8917801, + correlated_lat: 37.775589, + side_of_street: "left", + percent_along: 0.39047, + correlated_lon: -122.413521 + }, + { + way_id: 8917801, + correlated_lat: 37.775589, + side_of_street: "right", + percent_along: 0.60953, + correlated_lon: -122.413521 + } + ], input_lat: 37.775692 },{ input_lon: -73.990471, - ways: [{ - correlated_lon: -73.990471, - way_id: 5671311, - correlated_lat: 40.744549 - }], + node: null, + edges: [ + { + way_id: 5671311, + correlated_lat: 40.744427, + side_of_street: "right", + percent_along: 0.87621, + correlated_lon: -73.990524 + }, + { + way_id: 5671311, + correlated_lat: 40.744427, + side_of_street: "left", + percent_along: 0.12379, + correlated_lon: -73.990524 + } + ], input_lat: 40.744549 } ] From a95fe99b6ab7e8ea6ad037730de77f8bcb5c7f22 Mon Sep 17 00:00:00 2001 From: Kevin Kreiser Date: Wed, 7 Oct 2015 13:58:12 -0400 Subject: [PATCH 6/6] thanks to @drewda, for fixing my noob pr! --- spec/services/tyr_service_spec.rb | 4 ++-- .../support/vcr_cassettes/tyr_one_location.yml | 18 +++++------------- .../vcr_cassettes/tyr_two_locations.yml | 18 +++++------------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/spec/services/tyr_service_spec.rb b/spec/services/tyr_service_spec.rb index 7c16a7ab0..92b4b4584 100644 --- a/spec/services/tyr_service_spec.rb +++ b/spec/services/tyr_service_spec.rb @@ -54,7 +54,7 @@ expect(response).to eq [ { input_lon: -122.413605, - node: null, + node: nil, edges: [ { way_id: 8917801, @@ -74,7 +74,7 @@ input_lat: 37.775692 },{ input_lon: -73.990471, - node: null, + node: nil, edges: [ { way_id: 5671311, diff --git a/spec/support/vcr_cassettes/tyr_one_location.yml b/spec/support/vcr_cassettes/tyr_one_location.yml index 93349e70e..6d878d07d 100644 --- a/spec/support/vcr_cassettes/tyr_one_location.yml +++ b/spec/support/vcr_cassettes/tyr_one_location.yml @@ -18,33 +18,25 @@ http_interactions: code: 200 message: OK headers: - Access-Control-Allow-Credentials: - - 'true' - Access-Control-Allow-Headers: - - Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token - Access-Control-Allow-Methods: - - GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD Access-Control-Allow-Origin: - "*" - Access-Control-Expose-Headers: - - content-type, content-length, X-ApiaxleProxy-Qps-Left, X-ApiaxleProxy-Qpd-Left Content-Type: - application/json;charset=utf-8 Date: - - Thu, 28 May 2015 18:45:07 GMT + - Wed, 07 Oct 2015 17:46:11 GMT Server: - nginx/1.4.6 (Ubuntu) X-Apiaxleproxy-Qpd-Left: - - '19999' + - '999999' X-Apiaxleproxy-Qps-Left: - - '1' + - '99' Content-Length: - - '133' + - '318' Connection: - keep-alive body: encoding: UTF-8 string: '[{"input_lon":-122.413605,"node":null,"edges":[{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"left","percent_along":0.39047,"correlated_lon":-122.413521},{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"right","percent_along":0.60953,"correlated_lon":-122.413521}],"input_lat":37.775692}]' http_version: - recorded_at: Thu, 28 May 2015 18:45:11 GMT + recorded_at: Wed, 07 Oct 2015 17:46:13 GMT recorded_with: VCR 2.9.3 diff --git a/spec/support/vcr_cassettes/tyr_two_locations.yml b/spec/support/vcr_cassettes/tyr_two_locations.yml index 48bf27979..06a51d840 100644 --- a/spec/support/vcr_cassettes/tyr_two_locations.yml +++ b/spec/support/vcr_cassettes/tyr_two_locations.yml @@ -18,33 +18,25 @@ http_interactions: code: 200 message: OK headers: - Access-Control-Allow-Credentials: - - 'true' - Access-Control-Allow-Headers: - - Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token - Access-Control-Allow-Methods: - - GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD Access-Control-Allow-Origin: - "*" - Access-Control-Expose-Headers: - - content-type, content-length, X-ApiaxleProxy-Qps-Left, X-ApiaxleProxy-Qpd-Left Content-Type: - application/json;charset=utf-8 Date: - - Thu, 28 May 2015 18:45:08 GMT + - Wed, 07 Oct 2015 17:46:11 GMT Server: - nginx/1.4.6 (Ubuntu) X-Apiaxleproxy-Qpd-Left: - - '19998' + - '999998' X-Apiaxleproxy-Qps-Left: - - '1' + - '98' Content-Length: - - '263' + - '632' Connection: - keep-alive body: encoding: UTF-8 string: '[{"input_lon":-122.413605,"node":null,"edges":[{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"left","percent_along":0.39047,"correlated_lon":-122.413521},{"way_id":8917801,"correlated_lat":37.775589,"side_of_street":"right","percent_along":0.60953,"correlated_lon":-122.413521}],"input_lat":37.775692},{"input_lon":-73.990471,"node":null,"edges":[{"way_id":5671311,"correlated_lat":40.744427,"side_of_street":"right","percent_along":0.87621,"correlated_lon":-73.990524},{"way_id":5671311,"correlated_lat":40.744427,"side_of_street":"left","percent_along":0.12379,"correlated_lon":-73.990524}],"input_lat":40.744549}]' http_version: - recorded_at: Thu, 28 May 2015 18:45:11 GMT + recorded_at: Wed, 07 Oct 2015 17:46:13 GMT recorded_with: VCR 2.9.3