afimb/chouette2

View on GitHub
app/views/routes/show.kml.erb

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark id="route_<%= @route.id %>" >
      <name><%= @route.name %></name>
      <inactive>true</inactive>
      <%= @route.geometry.kml_representation.html_safe %>
    </Placemark>
    <% @route.stop_areas.where("latitude is not null and longitude is not null").each_with_index do |stop_area, index| %>
      <Placemark id="<%= stop_area.id %>" >
        <name><%= "#{stop_area.name} (#{index+1})" %></name>
        <stop_area_type_label><%= t("area_types.label.#{stop_area.stop_area_type}") %></stop_area_type_label>
        <% if stop_area.id==@route.stop_areas.first.id %>
        <departure>true</departure>
        <% elsif stop_area.id==@route.stop_areas.last.id %>
        <arrival>true</arrival>
        <% end %>
        <%= stop_area.geometry.kml_representation.html_safe %>
      </Placemark>
    <% end %>
  </Document>
</kml>