diff options
34 files changed, 168 insertions, 50 deletions
| diff --git a/app/exporters/chouette/hub/city_code_exporter.rb b/app/exporters/chouette/hub/city_code_exporter.rb new file mode 100644 index 000000000..7198f0de2 --- /dev/null +++ b/app/exporters/chouette/hub/city_code_exporter.rb @@ -0,0 +1,35 @@ +class Chouette::Hub::CityCodeExporter +  include ERB::Util +  attr_accessor :city_code, :city_name, :directory, :template +   +  def initialize(city_code, city_name, directory) +    @city_code = city_code +    @city_name = city_name +    @directory = directory +    @template = File.open('app/views/api/hub/communes.hub.erb' ){ |f| f.read } +  end +   +  def render() +    ERB.new(@template).result(binding) +  end +   +  def hub_name +    "/COMMUNE.TXT" +  end +   +  def self.save( city_codes, directory, hub_export) +    city_codes.keys.sort.each do |key| +      self.new( key, city_codes[key], directory).tap do |specific_exporter| +        specific_exporter.save +      end +    end +    hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|COMMUNE_COUNT", :arguments => {"0" => city_codes.keys.size}) +  end +   +  def save +    File.open(directory + hub_name , "a") do |f| +      f.write("COMMUNE\u000D\u000A") if f.size == 0 +      f.write(render) +    end +  end +end diff --git a/app/exporters/chouette/hub/commercial_stop_area_exporter.rb b/app/exporters/chouette/hub/commercial_stop_area_exporter.rb index 2c7828d59..bd1ee27cf 100644 --- a/app/exporters/chouette/hub/commercial_stop_area_exporter.rb +++ b/app/exporters/chouette/hub/commercial_stop_area_exporter.rb @@ -28,7 +28,7 @@ class Chouette::Hub::CommercialStopAreaExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("ARRET\n") if f.size == 0 +      f.write("ARRET\u000D\u000A") if f.size == 0        f.write(render)      end if stop_area.present?    end diff --git a/app/exporters/chouette/hub/company_exporter.rb b/app/exporters/chouette/hub/company_exporter.rb index 824e857f2..830e5bf96 100644 --- a/app/exporters/chouette/hub/company_exporter.rb +++ b/app/exporters/chouette/hub/company_exporter.rb @@ -27,7 +27,7 @@ class Chouette::Hub::CompanyExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("TRANSPORTEUR\n") if f.size == 0 +      f.write("TRANSPORTEUR\u000D\u000A") if f.size == 0        f.write(render)      end if company.present?    end diff --git a/app/exporters/chouette/hub/connection_link_exporter.rb b/app/exporters/chouette/hub/connection_link_exporter.rb index e70c773b9..fec8838a9 100644 --- a/app/exporters/chouette/hub/connection_link_exporter.rb +++ b/app/exporters/chouette/hub/connection_link_exporter.rb @@ -2,9 +2,10 @@ class Chouette::Hub::ConnectionLinkExporter    include ERB::Util    attr_accessor :connection_link, :directory, :template -  def initialize(connection_link, directory) +  def initialize(connection_link, directory, count)      @connection_link = connection_link      @directory = directory +    @count = count      @template = File.open('app/views/api/hub/correspondances.hub.erb' ){ |f| f.read }      @departure = Chouette::StopArea.find(@connection_link.departure_id) if @connection_link.departure_id      @arrival = Chouette::StopArea.find(@connection_link.arrival_id) if @connection_link.arrival_id @@ -19,9 +20,11 @@ class Chouette::Hub::ConnectionLinkExporter    end    def self.save( connection_links, directory, hub_export) +    count = 1      connection_links.each do |connection_link| -      self.new( connection_link, directory).tap do |specific_exporter| +      self.new( connection_link, directory, count).tap do |specific_exporter|          specific_exporter.save +        count += 1        end      end      hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|CONNECTION_LINK_COUNT", :arguments => {"0" => connection_links.size}) @@ -29,9 +32,9 @@ class Chouette::Hub::ConnectionLinkExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("CORRESPONDANCE\n") if f.size == 0 -      f.write(render) -    end if connection_link.present? +      f.write("CORRESPONDANCE\u000D\u000A") if f.size == 0 +      f.write(render) if (connection_link.present? && connection_link.link_distance.present?) +    end    end  end diff --git a/app/exporters/chouette/hub/direction_exporter.rb b/app/exporters/chouette/hub/direction_exporter.rb index 27f89b4a1..a3f04d141 100644 --- a/app/exporters/chouette/hub/direction_exporter.rb +++ b/app/exporters/chouette/hub/direction_exporter.rb @@ -31,7 +31,7 @@ class Chouette::Hub::DirectionExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("DIRECTION\n") if f.size == 0 +      f.write("DIRECTION\u000D\u000A") if f.size == 0        f.write(render)      end if journey_pattern.present?    end diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb index 8b9bc226e..58454a0cb 100644 --- a/app/exporters/chouette/hub/exporter.rb +++ b/app/exporters/chouette/hub/exporter.rb @@ -82,33 +82,40 @@ 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?          @routes = []          if @lines -          @lines.each { |line| @routes << Chouette::Route.where( "line_id = ?", line.id ) } +          @lines.each { |line| @routes << Chouette::Route.where( "line_id = ?", line.id ).order(:wayback) }          end -        #@routes = @routes.flatten - -        #@journey_patterns = Chouette::JourneyPattern.where(:route_id => @routes.map(&:id)).order(:objectid) if routes_exportable? +                  @journey_patterns = []          if @routes            @routes.each { |subroutes| @journey_patterns << Chouette::JourneyPattern.where( :route_id => subroutes.map(&:id) ).order(:objectid) }          end          @journey_patterns = @journey_patterns.flatten - +                  @routes = @routes.flatten          @vehicle_journeys = Chouette::VehicleJourney.where(:route_id => @routes.map(&:id)).order(:objectid) if routes_exportable? -                 +         +        rts = [] +        jps = []          vjs = []          tts = []          @vehicle_journeys.each do |vj|            unless (vj.time_tables & @time_tables).empty?              vjs << vj              tts << (vj.time_tables & @time_tables) +            rts << vj.route_id +            jps << vj.journey_pattern_id            end          end          @time_tables = tts.flatten.uniq          @vehicle_journeys = vjs.uniq +        rts = rts.flatten.uniq +        jps = jps.flatten.uniq +         +        @routes.delete_if {|r| !(rts.include?(r.id)) } +        @journey_patterns.delete_if {|jp| !(jps.include?(jp.id)) } +                  vehicle_journey_at_stops = Chouette::VehicleJourneyAtStop.where( :vehicle_journey_id => @vehicle_journeys.map(&:id) ) #.order(:id) if vehicle_journeys_exportable? @@ -135,10 +142,19 @@ class Chouette::Hub::Exporter            log_overflow_warning(Chouette::VehicleJourney)          end -        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) +        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(:objectid) +        physical_stop_areas = [] +        commercial_stop_areas.each { |commercial_stop_area| physical_stop_areas << Chouette::StopArea.where( :parent_id => [commercial_stop_area.id] ).order(:objectid) } +        physical_stop_areas = physical_stop_areas.flatten + +        city_codes = Hash.new +        commercial_stop_areas.each { |commercial_stop_area| city_codes[commercial_stop_area.zip_code] =  commercial_stop_area.city_name if commercial_stop_area.zip_code } +        physical_stop_areas.each { |physical_stop_area| city_codes[physical_stop_area.zip_code] =  physical_stop_area.city_name if physical_stop_area.zip_code } +         +        Chouette::Hub::CityCodeExporter.save(city_codes, temp_dir, hub_export)          Chouette::Hub::CommercialStopAreaExporter.save(commercial_stop_areas, temp_dir, hub_export)          Chouette::Hub::PhysicalStopAreaExporter.save(physical_stop_areas, temp_dir, hub_export) @@ -146,10 +162,32 @@ class Chouette::Hub::Exporter          Chouette::Hub::ConnectionLinkExporter.save(connection_links, temp_dir, hub_export) +                  if lines_exportable?            Chouette::Hub::LineExporter.save(@lines, temp_dir, hub_export) +           +          transport_modes = Hash.new +          @lines.each do |l| +            if l.transport_mode_name +              case l.transport_mode_name +              when "Coach" +                if transport_modes["CAR"] +                  transport_modes["CAR"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') +                else +                  transport_modes["CAR"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') +                end +              when "Bus" +                if transport_modes["BUS"] +                  transport_modes["BUS"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') +                else +                  transport_modes["BUS"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') +                end +              end +            end +          end +          Chouette::Hub::TransportModeExporter.save(transport_modes, temp_dir, hub_export)            networks = Chouette::Network.where( :id => @lines.map(&:network_id)) -          companies = Chouette::Network.where( :id => @lines.map(&:company_id)) +          companies = Chouette::Company.where( :id => @lines.map(&:company_id))            groups_of_lines = []            @lines.each { |l| groups_of_lines << l.group_of_lines }            groups_of_lines = groups_of_lines.flatten.uniq diff --git a/app/exporters/chouette/hub/group_of_lines_exporter.rb b/app/exporters/chouette/hub/group_of_lines_exporter.rb index 129913c8b..8113bfd60 100644 --- a/app/exporters/chouette/hub/group_of_lines_exporter.rb +++ b/app/exporters/chouette/hub/group_of_lines_exporter.rb @@ -27,7 +27,7 @@ class Chouette::Hub::GroupOfLinesExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("GROUPELIGNE\n") if f.size == 0 +      f.write("GROUPELIGNE\u000D\u000A") if f.size == 0        f.write(render)      end if group_of_lines.present?    end diff --git a/app/exporters/chouette/hub/journey_pattern_exporter.rb b/app/exporters/chouette/hub/journey_pattern_exporter.rb index 27333d90e..af7e27eef 100644 --- a/app/exporters/chouette/hub/journey_pattern_exporter.rb +++ b/app/exporters/chouette/hub/journey_pattern_exporter.rb @@ -41,7 +41,7 @@ class Chouette::Hub::JourneyPatternExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("CHEMIN\n") if f.size == 0 +      f.write("CHEMIN\u000D\u000A") if f.size == 0        f.write(render)      end if journey_pattern.present?    end diff --git a/app/exporters/chouette/hub/line_exporter.rb b/app/exporters/chouette/hub/line_exporter.rb index 9804bf96c..be2f52060 100644 --- a/app/exporters/chouette/hub/line_exporter.rb +++ b/app/exporters/chouette/hub/line_exporter.rb @@ -32,7 +32,7 @@ class Chouette::Hub::LineExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("LIGNE\n") if f.size == 0 +      f.write("LIGNE\u000D\u000A") if f.size == 0        f.write(render)      end if line.present?    end diff --git a/app/exporters/chouette/hub/network_exporter.rb b/app/exporters/chouette/hub/network_exporter.rb index 2673b7bb8..584c3770b 100644 --- a/app/exporters/chouette/hub/network_exporter.rb +++ b/app/exporters/chouette/hub/network_exporter.rb @@ -27,7 +27,7 @@ class Chouette::Hub::NetworkExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("RESEAU\n") if f.size == 0 +      f.write("RESEAU\u000D\u000A") if f.size == 0        f.write(render)      end if network.present?    end diff --git a/app/exporters/chouette/hub/physical_stop_area_exporter.rb b/app/exporters/chouette/hub/physical_stop_area_exporter.rb index 13e236b68..3086bb850 100644 --- a/app/exporters/chouette/hub/physical_stop_area_exporter.rb +++ b/app/exporters/chouette/hub/physical_stop_area_exporter.rb @@ -39,7 +39,7 @@ class Chouette::Hub::PhysicalStopAreaExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("ARRET\n") if f.size == 0 +      f.write("ARRET\u000D\u000A") if f.size == 0        f.write(render)      end if stop_area.present?    end diff --git a/app/exporters/chouette/hub/route_exporter.rb b/app/exporters/chouette/hub/route_exporter.rb index 2d25df9e0..e4e6579ce 100644 --- a/app/exporters/chouette/hub/route_exporter.rb +++ b/app/exporters/chouette/hub/route_exporter.rb @@ -36,7 +36,7 @@ class Chouette::Hub::RouteExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("SCHEMA\n") if f.size == 0 +      f.write("SCHEMA\u000D\u000A") if f.size == 0        f.write(render)      end if route.present?    end diff --git a/app/exporters/chouette/hub/time_table_exporter.rb b/app/exporters/chouette/hub/time_table_exporter.rb index f3a28cf79..8620a38dd 100644 --- a/app/exporters/chouette/hub/time_table_exporter.rb +++ b/app/exporters/chouette/hub/time_table_exporter.rb @@ -1,10 +1,11 @@  class Chouette::Hub::TimeTableExporter    include ERB::Util -  attr_accessor :time_table, :directory, :template, :start_date, :end_date +  attr_accessor :time_table, :directory, :template, :start_date, :end_date, :identifier -  def initialize(time_table, directory) +  def initialize(time_table, directory, identifier)      @time_table = time_table      @directory = directory +    @identifier = identifier      @template = File.open('app/views/api/hub/periodes.hub.erb' ){ |f| f.read }      @calendar = ""      s_date = @time_table.start_date @@ -28,9 +29,11 @@ class Chouette::Hub::TimeTableExporter    end    def self.save(time_tables, directory, hub_export) +    identifier = 1      time_tables.each do |time_table| -      self.new(time_table, directory).tap do |specific_exporter| +      self.new(time_table, directory, identifier).tap do |specific_exporter|          specific_exporter.save +        identifier += 1        end      end      hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|TIME_TABLE_COUNT", :arguments => {"0" => time_tables.size}) @@ -38,7 +41,7 @@ class Chouette::Hub::TimeTableExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("PERIODE\n") if f.size == 0 +      f.write("PERIODE\u000D\u000A") if f.size == 0        f.write(render)      end if time_table.present?    end diff --git a/app/exporters/chouette/hub/transport_mode_exporter.rb b/app/exporters/chouette/hub/transport_mode_exporter.rb new file mode 100644 index 000000000..af9a2357a --- /dev/null +++ b/app/exporters/chouette/hub/transport_mode_exporter.rb @@ -0,0 +1,35 @@ +class Chouette::Hub::TransportModeExporter +  include ERB::Util +  attr_accessor :transport_mode, :transport_lines, :directory, :template +   +  def initialize(transport_mode, transport_lines, directory) +    @transport_mode = transport_mode +    @transport_lines = transport_lines +    @directory = directory +    @template = File.open('app/views/api/hub/modes_transports.hub.erb' ){ |f| f.read } +  end +   +  def render() +    ERB.new(@template).result(binding) +  end +   +  def hub_name +    "/MODETRANSPORT.TXT" +  end +   +  def self.save( transport_modes, directory, hub_export) +    transport_modes.keys.sort.each do |key| +      self.new( key, transport_modes[key], directory).tap do |specific_exporter| +        specific_exporter.save +      end +    end +    hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|TRANSPORT_MODE_COUNT", :arguments => {"0" => transport_modes.keys.size}) +  end +   +  def save +    File.open(directory + hub_name , "a") do |f| +      f.write("MODETRANSPORT\u000D\u000A") if f.size == 0 +      f.write(render) +    end +  end +end 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 25e3bb864..ede411463 100644 --- a/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb @@ -11,7 +11,7 @@ class Chouette::Hub::VehicleJourneyAtStopExporter      stop_point = @vehicle_journey_at_stop.stop_point      stop_area = stop_point.stop_area      @stop_area_code = stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if stop_area -    @stop_area_id = stop_area.id if stop_area +    @stop_area_id = stop_area.registration_number if stop_area      @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 @@ -47,7 +47,7 @@ class Chouette::Hub::VehicleJourneyAtStopExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("HORAIRE\n") if f.size == 0 +      f.write("HORAIRE\u000D\u000A") if f.size == 0        f.write(render)      end if vehicle_journey_at_stop.present?    end diff --git a/app/exporters/chouette/hub/vehicle_journey_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_exporter.rb index b710b2d7a..ad82f7c0a 100644 --- a/app/exporters/chouette/hub/vehicle_journey_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_exporter.rb @@ -37,8 +37,8 @@ class Chouette::Hub::VehicleJourneyExporter      end      File.open(directory + "/RENVOI.TXT" , "a") do |f|        if f.size == 0 -        f.write("RENVOI\n")  -        f.write("a:PMR:1\n") +        f.write("RENVOI\u000D\u000A")  +        f.write("a:PMR:1\u000D\u000A")        end      end    end @@ -62,7 +62,7 @@ class Chouette::Hub::VehicleJourneyExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("COURSE\n") if f.size == 0 +      f.write("COURSE\u000D\u000A") if f.size == 0        f.write(render)      end if vehicle_journey.present?    end diff --git a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb index 37b4cc8f9..7f1e52245 100644 --- a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb @@ -92,7 +92,7 @@ class Chouette::Hub::VehicleJourneyOperationExporter    def save      File.open(directory + hub_name , "a") do |f| -      f.write("COURSE_OPERATION\n") if f.size == 0 +      f.write("COURSE_OPERATION\u000D\u000A") if f.size == 0        f.write(render)      end if vehicle_journey.present?    end diff --git a/app/views/api/hub/arrets_generiques.hub.erb b/app/views/api/hub/arrets_generiques.hub.erb index 89fe718a2..b540130f9 100644 --- a/app/views/api/hub/arrets_generiques.hub.erb +++ b/app/views/api/hub/arrets_generiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name if @stop_area.name %>;<%= @stop_area.nearest_topic_name if @stop_area.nearest_topic_name %>;<%= @type %>;;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0] : '' %>;<%=  (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1] : '' %>;<%= @stop_area.city_name if @stop_area.city_name %>;<%= @stop_area.country_code if @stop_area.country_code %>;<%= @stop_area.comment if @stop_area.comment %>;<%= @stop_area.id %> +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name if @stop_area.name %>;<%= @stop_area.nearest_topic_name if @stop_area.nearest_topic_name %>;<%= @type %>;;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : '' %>;<%=  (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : '' %>;<%= @stop_area.city_name if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment if @stop_area.comment %>;<%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/arrets_physiques.hub.erb b/app/views/api/hub/arrets_physiques.hub.erb index 8164ae35c..a69047882 100644 --- a/app/views/api/hub/arrets_physiques.hub.erb +++ b/app/views/api/hub/arrets_physiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name if @stop_area.name %>;<%= @stop_area.nearest_topic_name if @stop_area.nearest_topic_name %>;<%= @type %>;<%= @parent.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @parent %>;<%= (@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 if @stop_area.city_name %>;<%= @stop_area.country_code if @stop_area.country_code %>;<%= @stop_area.comment if @stop_area.comment %>;<%= @stop_area.id %> +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name if @stop_area.name %>;<%= @stop_area.nearest_topic_name if @stop_area.nearest_topic_name %>;<%= @type %>;<%= @parent.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @parent %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : -1 %>;<%=  (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : -1 %>;<%= @stop_area.city_name if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment if @stop_area.comment %>;<%= @stop_area.registration_number %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/chemins.hub.erb b/app/views/api/hub/chemins.hub.erb index 9d94cebd0..2a4235db9 100644 --- a/app/views/api/hub/chemins.hub.erb +++ b/app/views/api/hub/chemins.hub.erb @@ -1 +1 @@ -<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %>;<%= @journey_pattern.registration_number if @journey_pattern.registration_number %>;<%= @journey_pattern.name if @journey_pattern.name %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @type %>;<% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.id %>;;<% end %> +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %>;<%= @journey_pattern.registration_number if @journey_pattern.registration_number %>;<%= @journey_pattern.name if @journey_pattern.name %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @type %>;<% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.registration_number %>;;<% end %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/communes.hub.erb b/app/views/api/hub/communes.hub.erb new file mode 100644 index 000000000..714969301 --- /dev/null +++ b/app/views/api/hub/communes.hub.erb @@ -0,0 +1 @@ +<%= @city_code %>;<%= @city_name %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/correspondances.hub.erb b/app/views/api/hub/correspondances.hub.erb index 77c558953..3e2076947 100644 --- a/app/views/api/hub/correspondances.hub.erb +++ b/app/views/api/hub/correspondances.hub.erb @@ -1 +1 @@ -<%= @departure.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @departure %>;<%= @connection_link.departure_id %>;<%= @arrival.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @connection_link.arrival_id %>;<%= @connection_link.link_distance %>;<%= @connection_link.default_duration %>;<%= @connection_link.id %> +<%= @departure.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @departure %>;<%= @departure.registration_number if @departure %>;<%= @arrival.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @arrival %>;<%= @arrival.registration_number if @arrival %>;<%= @connection_link.link_distance %>;<%= @connection_link.default_duration %>;<%= @count %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/courses.hub.erb b/app/views/api/hub/courses.hub.erb index cf711ca6b..416cd5ec2 100644 --- a/app/views/api/hub/courses.hub.erb +++ b/app/views/api/hub/courses.hub.erb @@ -1,2 +1 @@ -<%= @numero %>;;;<%= @departure_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @departure_stop_area %>;<%= @departure_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern %>;<%= "D" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @departure_stop_area.id if @departure_stop_area %>;<%= @renvoi %>;<%= @periods %>;<%= 1 %>;<%= @vehicle_journey.id %> -<%= @numero %>;;;<%= @arrival_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @arrival_stop_area %>;<%= @arrival_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern %>;<%= "A" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @arrival_stop_area.id if @arrival_stop_area %>;<%= @renvoi %>;<%= @periods %>;<%= 1 %>;<%= @vehicle_journey.id %> +<%= @numero %>;;;<%= @departure_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @departure_stop_area %>;<%= @departure_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern %>;<%= "D" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @departure_stop_area.registration_number if @departure_stop_area %>;<%= @renvoi %>;<%= @periods %>;<%= 1 %>;<%= @vehicle_journey.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %><%= "\u000D\u000A" %><%= @numero %>;;;<%= @arrival_stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @arrival_stop_area %>;<%= @arrival_time_sec %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern %>;<%= "A" %>;<%= (@route.wayback == "R") ? 2 : 1 %>;<%= @validity %>;;<%= @arrival_stop_area.registration_number if @arrival_stop_area %>;<%= @renvoi %>;<%= @periods %>;<%= 1 %>;<%= @vehicle_journey.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/courses_operations.hub.erb b/app/views/api/hub/courses_operations.hub.erb index 503018825..5c293a2ad 100644 --- a/app/views/api/hub/courses_operations.hub.erb +++ b/app/views/api/hub/courses_operations.hub.erb @@ -1 +1 @@ -<%= @number %>;<%= @vehicle_journey.published_journey_identifier %>;;;<%= @transport_mode %>;; +<%= @number %>;<%= @vehicle_journey.published_journey_identifier %>;;;<%= @transport_mode %>;;<%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/directions.hub.erb b/app/views/api/hub/directions.hub.erb index bce4b0a9c..f7ae19781 100644 --- a/app/views/api/hub/directions.hub.erb +++ b/app/views/api/hub/directions.hub.erb @@ -1 +1 @@ -<%= @direction.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @direction %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %> +<%= @direction.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @direction %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/groupe_de_lignes.hub.erb b/app/views/api/hub/groupe_de_lignes.hub.erb index f098b7a5e..7f7e24abc 100644 --- a/app/views/api/hub/groupe_de_lignes.hub.erb +++ b/app/views/api/hub/groupe_de_lignes.hub.erb @@ -1 +1 @@ -<%= @group_of_lines.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_lines.name %>;<%= @group_of_lines.id %> +<%= @group_of_lines.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_lines.name %>;<%= @group_of_lines.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/horaires.hub.erb b/app/views/api/hub/horaires.hub.erb index c9d170be8..1497588af 100644 --- a/app/views/api/hub/horaires.hub.erb +++ b/app/views/api/hub/horaires.hub.erb @@ -1,2 +1 @@ -<%= @stop_area_code %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id - 1 %> -<%= @stop_area_code %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id %> +<%= @stop_area_code %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id - 1 %><%= "\u000D\u000A" %><%= @stop_area_code %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/lignes.hub.erb b/app/views/api/hub/lignes.hub.erb index 7fb7d24a8..312d45e1c 100644 --- a/app/views/api/hub/lignes.hub.erb +++ b/app/views/api/hub/lignes.hub.erb @@ -1 +1 @@ -<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line.objectid %>;<%= @line.number %>;<%= @line.name %>;<%= @line.registration_number %>;;<%= @ompany.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @ompany %>;<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @network %>;<%= @group_of_line %>;<%= @line.id %> +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line.objectid %>;<%= @line.number %>;<%= @line.name %>;;;<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @company %>;<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @network %>;<%= @group_of_line %>;<%= @line.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/modes_transports.hub.erb b/app/views/api/hub/modes_transports.hub.erb new file mode 100644 index 000000000..742f8033e --- /dev/null +++ b/app/views/api/hub/modes_transports.hub.erb @@ -0,0 +1 @@ +<%= @transport_mode %>;;<%= @transport_lines %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/periodes.hub.erb b/app/views/api/hub/periodes.hub.erb index dc3e475df..38b2d3db9 100644 --- a/app/views/api/hub/periodes.hub.erb +++ b/app/views/api/hub/periodes.hub.erb @@ -1 +1 @@ -<%= Chouette::TimeTable.find(@time_table.id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @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.strftime("%d/%m/%Y") %>;<%= @time_table.end_date.strftime("%d/%m/%Y") %>;<%= @calendar %>;<%= @identifier %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/reseaux.hub.erb b/app/views/api/hub/reseaux.hub.erb index 634b10b30..1f12a7017 100644 --- a/app/views/api/hub/reseaux.hub.erb +++ b/app/views/api/hub/reseaux.hub.erb @@ -1 +1 @@ -<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @network.name %>;<%= @network.id %> +<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @network.name %>;<%= @network.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/schemas.hub.erb b/app/views/api/hub/schemas.hub.erb index 3a93294f8..f2759a871 100644 --- a/app/views/api/hub/schemas.hub.erb +++ b/app/views/api/hub/schemas.hub.erb @@ -1 +1 @@ -<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @route.wayback == 'A' ? 1 : 2 %><% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.id %><% end %> +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @route.wayback == 'A' ? 1 : 2 %>;<%= @route.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %><% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.registration_number if s.registration_number %><% end %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/transporteurs.hub.erb b/app/views/api/hub/transporteurs.hub.erb index fdabda5b1..7d153ad7c 100644 --- a/app/views/api/hub/transporteurs.hub.erb +++ b/app/views/api/hub/transporteurs.hub.erb @@ -1 +1 @@ -<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @company.name %>;<%= @company.id %> +<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @company.name %>;<%= @company.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/config/locales/exports.yml b/config/locales/exports.yml index 041bde2c8..7b1531314 100644 --- a/config/locales/exports.yml +++ b/config/locales/exports.yml @@ -33,6 +33,8 @@ en:        overflow: "Can't export more than %{count} %{data} in a single KML export operation. You should proceed with some exports, each one based on less selected lines."        LINE_COUNT: "Exported line count : %{0}"        GROUP_OF_LINES_COUNT: "Exported group of lines count : %{0}" +      COMMUNE_COUNT: "City count : %{0}" +      TRANSPORT_MODE_COUNT: "Transport Mode count : %{0}"        ROUTE_COUNT: "Route count : %{0}"        JOURNEY_PATTERN_COUNT: "Journey pattern count : %{0}"        QUAY_AND_BOARDING_POSITION_COUNT: "Quays and Boarding positions count : %{0}" @@ -154,6 +156,8 @@ fr:        overflow: "Impossible d'exporter plus de %{count} %{data} en un seul export. Veuillez procéder par exports successifs en sélectionnant une moindre quantité de lignes."        LINE_COUNT: "Nombre de lignes exportées : %{0}"        GROUP_OF_LINES_COUNT: "Nombre de groupe de lignes exportés : %{0}" +      COMMUNE_COUNT: "Nombre de communes : %{0}" +      TRANSPORT_MODE_COUNT: "Nombre de modes de transport : %{0}"        ROUTE_COUNT: "Nombre de séquences d'arrêts exportées : %{0}"        QUAY_AND_BOARDING_POSITION_COUNT: "Nombre d'arrêts physiques exportés : %{0}"        COMMERCIAL_COUNT: "Nombre d'arrêts commerciaux exportés : %{0}" | 
