aboutsummaryrefslogtreecommitdiffstats
path: root/app/exporters
diff options
context:
space:
mode:
authorZakaria BOUZIANE2014-09-22 10:50:48 +0200
committerZakaria BOUZIANE2014-09-22 10:50:48 +0200
commit37a98d4ffd8998ccbc7577e4d03e0785199642ff (patch)
treeadcf2d20ba7362323e4c93b4c89ef60947a4d680 /app/exporters
parentd86f7fe8cad332890f0be146f229cde72dc52eec (diff)
downloadchouette-core-37a98d4ffd8998ccbc7577e4d03e0785199642ff.tar.bz2
MAJ Export HUB
Diffstat (limited to 'app/exporters')
-rw-r--r--app/exporters/chouette/hub/exporter.rb10
-rw-r--r--app/exporters/chouette/hub/physical_stop_area_exporter.rb7
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb1
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_exporter.rb31
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb12
5 files changed, 48 insertions, 13 deletions
diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb
index 2d14d3a3b..091fa75c2 100644
--- a/app/exporters/chouette/hub/exporter.rb
+++ b/app/exporters/chouette/hub/exporter.rb
@@ -82,11 +82,9 @@ class Chouette::Hub::Exporter
@lines = select_lines( options[:o], options[:id] )
@routes = lines.map(&:routes).flatten.sort {|a,b| (a.name && b.name) ? a.name <=> b.name : a.id <=> b.id} if lines_exportable?
- @journey_patterns = Chouette::JourneyPattern.where( :route_id => routes.map(&:id) ).order(:name) if routes_exportable?
-
- @vehicle_journeys = Chouette::VehicleJourney.where( :route_id => routes.map(&:id) ).order(:id) if routes_exportable?
- @vehicle_journeys = Chouette::VehicleJourney.where( :route_id => routes.map(&:id) ).order(:id) if routes_exportable?
-
+ @journey_patterns = Chouette::JourneyPattern.where(:route_id => routes.map(&:id)).order(:name) if routes_exportable?
+ @vehicle_journeys = Chouette::VehicleJourney.where(:route_id => routes.map(&:id)).order(:objectid) if routes_exportable?
+
vjs = []
tts = []
@vehicle_journeys.each do |vj|
@@ -116,7 +114,7 @@ class Chouette::Hub::Exporter
stop_points = Chouette::StopPoint.where( :id => vehicle_journey_at_stops.map(&:stop_point_id)).order(:id)
physical_stop_areas = Chouette::StopArea.where( :id => stop_points.map(&:stop_area_id)).order(:parent_id)
- commercial_stop_areas = Chouette::StopArea.where( :id => physical_stop_areas.map(&:parent_id)).order(:id)
+ commercial_stop_areas = Chouette::StopArea.where( :id => physical_stop_areas.map(&:parent_id)).order(:objectid)
Chouette::Hub::CommercialStopAreaExporter.save(commercial_stop_areas, temp_dir, hub_export)
Chouette::Hub::PhysicalStopAreaExporter.save(physical_stop_areas, temp_dir, hub_export)
diff --git a/app/exporters/chouette/hub/physical_stop_area_exporter.rb b/app/exporters/chouette/hub/physical_stop_area_exporter.rb
index 7669aa64e..23e5d73ec 100644
--- a/app/exporters/chouette/hub/physical_stop_area_exporter.rb
+++ b/app/exporters/chouette/hub/physical_stop_area_exporter.rb
@@ -8,6 +8,13 @@ class Chouette::Hub::PhysicalStopAreaExporter
@template = File.open('app/views/api/hub/arrets_physiques.hub.erb' ){ |f| f.read }
@type = "NNNNNNNNNNNNNNNNNN"
@stop_area.referential.projection_type = "27562"
+
+ wgs84 = '+proj=lonlat +datum=WGS84 +ellps=WGS84'
+ @from_projection = RGeo::CoordSys::Proj4.new(wgs84)
+
+ lambert2_extended = '+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs'
+ @to_projection = RGeo::CoordSys::Proj4.new(lambert2_extended)
+
end
def render()
diff --git a/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb
index 546e3cec1..12cb5e1df 100644
--- a/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb
+++ b/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb
@@ -6,6 +6,7 @@ class Chouette::Hub::VehicleJourneyAtStopExporter
@vehicle_journey_at_stop = vehicle_journey_at_stop
@directory = directory
@template = File.open('app/views/api/hub/horaires.hub.erb' ) { |f| f.read }
+ @stop_area_code = Chouette::StopArea.find(@vehicle_journey_at_stop.stop_point.stop_area_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
@arrival_time = @vehicle_journey_at_stop.arrival_time.sec + 60 * @vehicle_journey_at_stop.arrival_time.min + 60 * 60 * @vehicle_journey_at_stop.arrival_time.hour
@arrival_type = "A"
@departure_time = @vehicle_journey_at_stop.departure_time.sec + 60 * @vehicle_journey_at_stop.departure_time.min + 60 * 60 * @vehicle_journey_at_stop.departure_time.hour
diff --git a/app/exporters/chouette/hub/vehicle_journey_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_exporter.rb
index df7cda97f..96b458953 100644
--- a/app/exporters/chouette/hub/vehicle_journey_exporter.rb
+++ b/app/exporters/chouette/hub/vehicle_journey_exporter.rb
@@ -2,10 +2,34 @@ class Chouette::Hub::VehicleJourneyExporter
include ERB::Util
attr_accessor :vehicle_journey, :directory, :template
- def initialize(vehicle_journey, directory)
+ def initialize(vehicle_journey, directory, index)
@vehicle_journey = vehicle_journey
@directory = directory
@template = File.open('app/views/api/hub/courses.hub.erb' ) { |f| f.read }
+ @numero = index
+ @journey_pattern = Chouette::JourneyPattern.find(@vehicle_journey.journey_pattern_id)
+ @route = Chouette::Route.find(@vehicle_journey.route_id)
+ @line = Chouette::Line.find(@route.line_id)
+ @departure_stop_point = Chouette::StopPoint.find(@journey_pattern.departure_stop_point_id)
+ @departure_stop_area = Chouette::StopArea.find(@departure_stop_point.stop_area_id)
+ @arrival_stop_point = Chouette::StopPoint.find(@journey_pattern.arrival_stop_point_id)
+ @arrival_stop_area = Chouette::StopArea.find(@arrival_stop_point.stop_area_id)
+ departure_time = Chouette::VehicleJourneyAtStop.where( :vehicle_journey_id => @vehicle_journey.id ).where( :stop_point_id => @departure_stop_point.id )[0].departure_time
+ arrival_time = Chouette::VehicleJourneyAtStop.where( :vehicle_journey_id => @vehicle_journey.id ).where( :stop_point_id => @arrival_stop_point.id )[0].arrival_time
+ @departure_time_sec = departure_time.sec + ( departure_time.min + departure_time.hour * 60 ) * 60
+ @arrival_time_sec = arrival_time.sec + ( arrival_time.min + arrival_time.hour * 60 ) * 60
+ @validity = 0
+ @vehicle_journey.time_tables.map(&:int_day_types).each { |v| @validity += v }
+
+ periods = Chouette::TimeTablePeriod.where( :time_table_id => @vehicle_journey.time_tables.map(&:id) ).map(&:id)
+ @periods = ""
+ unless periods.empty?
+ @periods += periods[0].to_s
+ periods.shift
+ end
+ unless periods.empty?
+ periods.each { |p| @periods += "|" + p.to_s }
+ end
end
def render()
@@ -17,9 +41,8 @@ class Chouette::Hub::VehicleJourneyExporter
end
def self.save( vehicle_journeys, directory, hub_export)
- vehicle_journeys.each do |vehicle_journey|
- #Chouette::Hub::VehicleJourneyAtStopExporter.save(vehicle_journey.vehicle_journey_at_stops, directory, hub_export)
- self.new( vehicle_journey, directory).tap do |specific_exporter|
+ vehicle_journeys.each_index do |index|
+ self.new( vehicle_journeys[index], directory, index).tap do |specific_exporter|
specific_exporter.save
end
end
diff --git a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb
index e6c5b8d07..3a45f2cab 100644
--- a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb
+++ b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb
@@ -2,8 +2,9 @@ class Chouette::Hub::VehicleJourneyOperationExporter
include ERB::Util
attr_accessor :vehicle_journey, :directory, :template
- def initialize(vehicle_journey, directory)
+ def initialize(vehicle_journey, directory, index)
@vehicle_journey = vehicle_journey
+ @number = index
@directory = directory
@template = File.open('app/views/api/hub/courses_operations.hub.erb' ) { |f| f.read }
end
@@ -17,11 +18,16 @@ class Chouette::Hub::VehicleJourneyOperationExporter
end
def self.save( vehicle_journeys, directory, hub_export)
- vehicle_journeys.each do |vehicle_journey|
- self.new( vehicle_journey, directory).tap do |specific_exporter|
+ vehicle_journeys.each_index do |index|
+ self.new( vehicle_journeys[index], directory, index).tap do |specific_exporter|
specific_exporter.save
end
end
+ #vehicle_journeys.each do |vehicle_journey|
+ # self.new( vehicle_journey, directory).tap do |specific_exporter|
+ # specific_exporter.save
+ # end
+ #end
hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|VEHICLE_JOURNEY_COUNT", :arguments => {"0" => vehicle_journeys.size})
end