diff options
| author | Zakaria BOUZIANE | 2014-09-22 10:50:48 +0200 | 
|---|---|---|
| committer | Zakaria BOUZIANE | 2014-09-22 10:50:48 +0200 | 
| commit | 37a98d4ffd8998ccbc7577e4d03e0785199642ff (patch) | |
| tree | adcf2d20ba7362323e4c93b4c89ef60947a4d680 | |
| parent | d86f7fe8cad332890f0be146f229cde72dc52eec (diff) | |
| download | chouette-core-37a98d4ffd8998ccbc7577e4d03e0785199642ff.tar.bz2 | |
MAJ Export HUB
| -rw-r--r-- | app/exporters/chouette/hub/exporter.rb | 10 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/physical_stop_area_exporter.rb | 7 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb | 1 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/vehicle_journey_exporter.rb | 31 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb | 12 | ||||
| -rw-r--r-- | app/views/api/hub/arrets_generiques.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/arrets_physiques.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/chemins.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/correspondances.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/courses.hub.erb | 3 | ||||
| -rw-r--r-- | app/views/api/hub/courses_operations.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/horaires.hub.erb | 4 | ||||
| -rw-r--r-- | app/views/api/hub/lignes.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/periodes.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/reseaux.hub.erb | 2 | ||||
| -rw-r--r-- | app/views/api/hub/transporteurs.hub.erb | 2 | 
16 files changed, 61 insertions, 25 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 diff --git a/app/views/api/hub/arrets_generiques.hub.erb b/app/views/api/hub/arrets_generiques.hub.erb index a7cc7585a..bb989920f 100644 --- a/app/views/api/hub/arrets_generiques.hub.erb +++ b/app/views/api/hub/arrets_generiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.id %>;<%= @stop_area.name %>;;<%= @type %>;;;;<%= @stop_area.country_code %>;<%= @stop_area.country_code %>;<%= @stop_area.comment %>;<%= @stop_area.registration_number %> +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @stop_area.name %>;<%= @stop_area.nearest_topic_name %>;<%= @type %>;;;;;;<%= @stop_area.comment %>;<%= @stop_area.id %> diff --git a/app/views/api/hub/arrets_physiques.hub.erb b/app/views/api/hub/arrets_physiques.hub.erb index f2aee2e6d..a63ee2335 100644 --- a/app/views/api/hub/arrets_physiques.hub.erb +++ b/app/views/api/hub/arrets_physiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.id %>;<%= @stop_area.name %>;;<%= @type %>;<%= @stop_area.parent_id %>;<%= @stop_area.projection_x %>;<%= @stop_area.projection_y %>;<%= @stop_area.country_code %>;<%= @stop_area.country_code %>;<%= @stop_area.comment %>;<%= @stop_area.registration_number %> +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @stop_area.name %>;;<%= @type %>;<%= Chouette::StopArea.find(@stop_area.parent_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0] : -1 %>;<%=  (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1] : -1 %>;<%= @stop_area.city_name %>;<%= @stop_area.country_code %>;<%= @stop_area.comment %>;<%= @stop_area.id %> diff --git a/app/views/api/hub/chemins.hub.erb b/app/views/api/hub/chemins.hub.erb index ed6e9a4d1..37c5b1260 100644 --- a/app/views/api/hub/chemins.hub.erb +++ b/app/views/api/hub/chemins.hub.erb @@ -1 +1 @@ -<%= @journey_pattern.route.line_id %>;<%= @journey_pattern.id %>;<%= @journey_pattern.registration_number %>;<%= @journey_pattern.name %>;<%= @journey_pattern.route.wayback == 'A' ? 1 : 2 %>;<%= @type %>;<% @journey_pattern.stop_points.each do |sp| %>;<%= sp.stop_area_id %>;<%= sp.stop_area.registration_number %>;;<% end %> +<%= Chouette::Line.find(@journey_pattern.route.line_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @journey_pattern.registration_number %>;<%= @journey_pattern.name %>;<%= @journey_pattern.route.wayback == 'A' ? 1 : 2 %>;<%= @type %>;<% @journey_pattern.stop_points.each do |sp| %>;<%= Chouette::StopArea.find(sp.stop_area_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= sp.stop_area_id %>;;<% end %> diff --git a/app/views/api/hub/correspondances.hub.erb b/app/views/api/hub/correspondances.hub.erb index 8d4c5ba7c..91fdd9215 100644 --- a/app/views/api/hub/correspondances.hub.erb +++ b/app/views/api/hub/correspondances.hub.erb @@ -1 +1 @@ -<%= @connection_link.departure_id %>;<%= @connection_link.departure.registration_number %>;<%= @connection_link.arrival_id %>;<%= @connection_link.arrival.registration_number %>;<%= @connection_link.link_distance %>;<%= @connection_link.default_duration %>;<%= @connection_link.id %> +<%= Chouette::StopArea.find(@connection_link.departure_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @connection_link.departure_id %>;<%= Chouette::StopArea.find(@connection_link.arrival_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @connection_link.arrival_id %>;<%= @connection_link.link_distance %>;<%= @connection_link.default_duration %>;<%= @connection_link.id %> diff --git a/app/views/api/hub/courses.hub.erb b/app/views/api/hub/courses.hub.erb index d92939dc2..b0ef2fe2b 100644 --- a/app/views/api/hub/courses.hub.erb +++ b/app/views/api/hub/courses.hub.erb @@ -1 +1,2 @@ -<%= @vehicle_journey.id %>;;;;;<%= @vehicle_journey.route.line_id %>;<%= @vehicle_journey.journey_pattern.id %>;... +<%= @numero %>;;;<%= @departure_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @departure_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= "D" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @departure_stop_area.id %>;;<%= @periods %>;<%= 1 %>; +<%= @numero %>;;;<%= @arrival_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @arrival_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= "A" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @arrival_stop_area.id %>;;<%= @periods %>;<%= 1 %>; diff --git a/app/views/api/hub/courses_operations.hub.erb b/app/views/api/hub/courses_operations.hub.erb index f85b3508e..ee6b27581 100644 --- a/app/views/api/hub/courses_operations.hub.erb +++ b/app/views/api/hub/courses_operations.hub.erb @@ -1 +1 @@ -<%= @vehicle_journey.id %>;<%= @vehicle_journey.published_journey_identifier %>;;;<%= @vehicle_journey.transport_mode %>;; +<%= @number %>;<%= @vehicle_journey.published_journey_identifier %>;;;<%= @vehicle_journey.transport_mode %>;; diff --git a/app/views/api/hub/horaires.hub.erb b/app/views/api/hub/horaires.hub.erb index bebea0959..7716976d6 100644 --- a/app/views/api/hub/horaires.hub.erb +++ b/app/views/api/hub/horaires.hub.erb @@ -1,2 +1,2 @@ -<%= @vehicle_journey_at_stop.stop_point.stop_area_id %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_at_stop.vehicle_journey_id %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @vehicle_journey_at_stop.stop_point.stop_area.registration_number %>;<%= @vehicle_journey_at_stop.id %> -<%= @vehicle_journey_at_stop.stop_point.stop_area_id %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_at_stop.vehicle_journey_id %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @vehicle_journey_at_stop.stop_point.stop_area.registration_number %>;<%= @vehicle_journey_at_stop.id %> +<%= @stop_area_code %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_at_stop.vehicle_journey_id %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @vehicle_journey_at_stop.stop_point.stop_area.id %>;<%= @vehicle_journey_at_stop.id %> +<%= @stop_area_code %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_at_stop.vehicle_journey_id %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @vehicle_journey_at_stop.stop_point.stop_area.id %>;<%= @vehicle_journey_at_stop.id %> diff --git a/app/views/api/hub/lignes.hub.erb b/app/views/api/hub/lignes.hub.erb index ee6d4de8f..e5d2c4c4c 100644 --- a/app/views/api/hub/lignes.hub.erb +++ b/app/views/api/hub/lignes.hub.erb @@ -1 +1 @@ -<%= @line.id %>;<%= @line.objectid %>;<%= @line.name %>;;;<%= @line.company_id %>;<%= @line.network_id %>;;<%= @line.registration_number %> +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @line.number %>;<%= @line.name %>;;;<%= Chouette::Company.find(@line.company_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= Chouette::Network.find(@line.network_id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;;<%= @line.id %> diff --git a/app/views/api/hub/periodes.hub.erb b/app/views/api/hub/periodes.hub.erb index 342e4016f..dc3e475df 100644 --- a/app/views/api/hub/periodes.hub.erb +++ b/app/views/api/hub/periodes.hub.erb @@ -1 +1 @@ -<%= @time_table.id %>;<%= @time_table.comment %>;<%= @time_table.start_date %>;<%= @time_table.end_date %>;<%= @calendar %> +<%= Chouette::TimeTable.find(@time_table.id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @time_table.comment %>;<%= @time_table.start_date %>;<%= @time_table.end_date %>;<%= @calendar %> diff --git a/app/views/api/hub/reseaux.hub.erb b/app/views/api/hub/reseaux.hub.erb index 25f24dc6d..634b10b30 100644 --- a/app/views/api/hub/reseaux.hub.erb +++ b/app/views/api/hub/reseaux.hub.erb @@ -1 +1 @@ -<%= @network.id %>;<%= @network.name %>;<%= @network.registration_number %> +<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @network.name %>;<%= @network.id %> diff --git a/app/views/api/hub/transporteurs.hub.erb b/app/views/api/hub/transporteurs.hub.erb index 3f175b053..fdabda5b1 100644 --- a/app/views/api/hub/transporteurs.hub.erb +++ b/app/views/api/hub/transporteurs.hub.erb @@ -1 +1 @@ -<%= @company.id %>;<%= @company.name %>;<%= @company.registration_number %> +<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @company.name %>;<%= @company.id %> | 
