diff options
| author | cedricnjanga | 2017-11-22 00:45:48 +0100 |
|---|---|---|
| committer | cedricnjanga | 2017-11-22 00:45:48 +0100 |
| commit | 510afa8b86fb6f5e4b7d9c39e3a6d3b071cd8ce9 (patch) | |
| tree | 1b3a162722389df4f6b2e444d03e91131032f0d5 /lib | |
| parent | be2bd2e4f902ef12a21425ebe7dcf5699768762a (diff) | |
| parent | 96afaed78fa043449c0264ea09f0106147755c8e (diff) | |
| download | chouette-core-510afa8b86fb6f5e4b7d9c39e3a6d3b071cd8ce9.tar.bz2 | |
Merge branch 'master' into 4941-refactoring_object_id
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/osrm_route_section_processor.rb | 42 | ||||
| -rw-r--r-- | lib/stif/permission_translator.rb | 4 | ||||
| -rw-r--r-- | lib/tasks/route_sections.rake | 17 |
3 files changed, 2 insertions, 61 deletions
diff --git a/lib/osrm_route_section_processor.rb b/lib/osrm_route_section_processor.rb deleted file mode 100644 index e9f92def0..000000000 --- a/lib/osrm_route_section_processor.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'open-uri' - -class OsrmRouteSectionProcessor - - def call(route_section) - osrm_endpoint = Rails.application.secrets.osrm_endpoint - - points_string = (route_section.input_geometry || route_section.default_geometry).points.map do |point| - "loc=#{point.y.to_f},#{point.x.to_f}" - end.join - - Rails.logger.info "Invoke #{osrm_endpoint} for RouteSection StopArea:#{route_section.departure.id} -> StopArea:#{route_section.arrival.id}" - - response = open "#{osrm_endpoint}/viaroute?#{points_string}instructions=false" - return nil unless response - - geometry = JSON.parse(response.read.to_s)['route_geometry'] - if geometry - decoded_geometry = Polylines::Decoder.decode_polyline(geometry, 1e6).map do |point| - GeoRuby::SimpleFeatures::Point.from_x_y(point[1], point[0], 4326) - end - - GeoRuby::SimpleFeatures::LineString.from_points(decoded_geometry).try(:to_rgeo) if decoded_geometry.many? - end - rescue OpenURI::HTTPError => e - Rails.logger.error "#{osrm_endpoint} failed: #{e}" - nil - rescue IOError => e - Rails.logger.error "#{osrm_endpoint} failed: #{e}" - nil - end - - def self.create_all - Chouette::JourneyPattern.find_each do |journey_pattern| - selector = RouteSectionsSelector.new(journey_pattern) - selector.sections.each do |section| - section.create_candidate unless section.candidates.present? - end - end - end - -end diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb index 121e89694..2d267bc7b 100644 --- a/lib/stif/permission_translator.rb +++ b/lib/stif/permission_translator.rb @@ -29,8 +29,8 @@ module Stif vehicle_journeys api_keys compliance_controls - compliance_controls_sets - compliance_controls_blocks + compliance_control_sets + compliance_control_blocks compliance_check_sets ] end diff --git a/lib/tasks/route_sections.rake b/lib/tasks/route_sections.rake deleted file mode 100644 index d48ddbba4..000000000 --- a/lib/tasks/route_sections.rake +++ /dev/null @@ -1,17 +0,0 @@ -namespace :route_sections do - - def find_referential(id_or_slug) - if id_or_slug.to_s =~ /\A\d+\Z/ - Referential.find id_or_slug.to_i - else - Referential.find_by slug: id_or_slug - end - end - - desc "Generate all RouteSections for a given Referential" - task :create_all, [:referential] => [:environment] do |t, args| - find_referential(args[:referential]).switch - OsrmRouteSectionProcessor.create_all - end - -end |
