aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXinhui2017-11-09 11:25:42 +0100
committerXinhui2017-11-09 11:25:42 +0100
commit7d3a9ca840b479e0394005ba72311fedbd4160ff (patch)
treee0c606a5771165577f827c7ab25fe37a80855510 /lib
parent1d35d77ff3801c6e1ac56d10f1898ad6527a1048 (diff)
downloadchouette-core-7d3a9ca840b479e0394005ba72311fedbd4160ff.tar.bz2
Remove model route_sections
Diffstat (limited to 'lib')
-rw-r--r--lib/osrm_route_section_processor.rb42
-rw-r--r--lib/tasks/route_sections.rake17
2 files changed, 0 insertions, 59 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/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