ninoxe 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.md +4 -0
  2. data/app/models/chouette/access_link.rb +5 -1
  3. data/app/models/chouette/access_point.rb +14 -10
  4. data/app/models/chouette/connection_link.rb +5 -1
  5. data/app/models/chouette/group_of_line.rb +1 -1
  6. data/app/models/chouette/journey_pattern.rb +1 -1
  7. data/app/models/chouette/line.rb +5 -1
  8. data/app/models/chouette/mobility_need.rb +4 -0
  9. data/app/models/chouette/network.rb +1 -1
  10. data/app/models/chouette/pt_link.rb +1 -1
  11. data/app/models/chouette/route.rb +5 -1
  12. data/app/models/chouette/stop_area.rb +21 -13
  13. data/app/models/chouette/stop_point.rb +1 -1
  14. data/app/models/chouette/suitability.rb +5 -0
  15. data/app/models/chouette/time_table.rb +11 -2
  16. data/app/models/chouette/time_table_date.rb +1 -1
  17. data/app/models/chouette/time_table_period.rb +1 -1
  18. data/app/models/chouette/vehicle_journey.rb +1 -1
  19. data/app/models/chouette/vehicle_journey_at_stop.rb +1 -1
  20. data/app/presenters/chouette/geometry/access_link_presenter.rb +11 -0
  21. data/app/presenters/chouette/geometry/access_point_presenter.rb +11 -0
  22. data/app/presenters/chouette/geometry/connection_link_presenter.rb +11 -0
  23. data/app/presenters/chouette/geometry/general_presenter.rb +20 -0
  24. data/app/presenters/chouette/geometry/line_presenter.rb +42 -0
  25. data/app/presenters/chouette/geometry/route_presenter.rb +22 -0
  26. data/app/presenters/chouette/geometry/stop_area_presenter.rb +13 -0
  27. data/db/migrate/20130628124932_remove_projection_from_stop_areas.rb +19 -0
  28. data/db/migrate/20130628124951_remove_projection_from_access_points.rb +19 -0
  29. data/db/migrate/20130708081951_add_accessibility_to_stop_areas.rb +30 -0
  30. data/db/migrate/20130710122648_set_accessibiliity_to_existing_stop_area.rb +16 -0
  31. data/lib/factories/chouette_lines.rb +11 -0
  32. data/lib/ninoxe/version.rb +1 -1
  33. data/spec/models/chouette/access_point_spec.rb +0 -29
  34. data/spec/models/chouette/stop_area_spec.rb +0 -28
  35. data/spec/models/chouette/time_table_spec.rb +35 -13
  36. data/spec/presenters/chouette/geometry/general_presenter.rb +1 -0
  37. data/spec/presenters/chouette/geometry/line_presenter_spec.rb +13 -0
  38. data/spec/spec_helper.rb +0 -17
  39. metadata +242 -206
  40. data/README.rdoc +0 -3
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Ninoxe [![Gem Version](https://badge.fury.io/rb/ninoxe.png)](http://badge.fury.io/rb/ninoxe) [![Build Status](https://travis-ci.org/dryade/ninoxe.png)](http://travis-ci.org/dryade/ninoxe?branch=master) [![Dependency Status](https://gemnasium.com/dryade/ninoxe.png)](https://gemnasium.com/dryade/ninoxe) [![Code Climate](https://codeclimate.com/github/dryade/ninoxe.png)](https://codeclimate.com/github/dryade/ninoxe)
2
+
3
+ This gem rocks and uses MIT-LICENSE.
4
+
@@ -1,6 +1,6 @@
1
1
  class Chouette::AccessLink < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  attr_accessor :access_link_type, :link_orientation_type, :link_key
6
6
 
@@ -59,5 +59,9 @@ class Chouette::AccessLink < Chouette::TridentActiveRecord
59
59
  "S_#{stop_area.id}-A_#{access_point.id}"
60
60
  end
61
61
  end
62
+
63
+ def geometry_presenter
64
+ Chouette::Geometry::AccessLinkPresenter.new self
65
+ end
62
66
  end
63
67
 
@@ -3,23 +3,24 @@ require 'geo_ruby'
3
3
 
4
4
  class Chouette::AccessPoint < Chouette::TridentActiveRecord
5
5
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
6
- set_primary_key :id
6
+ self.primary_key = "id"
7
7
  include Geokit::Mappable
8
8
  has_many :access_links, :dependent => :destroy
9
9
  belongs_to :stop_area
10
10
 
11
11
  attr_accessor :access_point_type
12
12
  attr_accessible :objectid, :object_version, :creation_time, :creator_id, :name, :comment
13
- attr_accessible :longitude, :latitude, :long_lat_type, :x, :y, :projection_type
13
+ attr_accessible :longitude, :latitude, :long_lat_type
14
+ #attr_accessible :x, :y, :projection_type
14
15
  attr_accessible :country_code, :street_name
15
16
  attr_accessible :openning_time, :closing_time, :access_type, :access_point_type
16
17
  attr_accessible :mobility_restricted_suitability, :stairs_availability, :lift_availability
17
18
  attr_accessible :stop_area_id
18
19
 
19
20
  # workaround of ruby 1.8 private method y block attribute y reading access
20
- def y
21
- read_attribute :y
22
- end
21
+ #def y
22
+ # read_attribute :y
23
+ #end
23
24
 
24
25
  validates_presence_of :name
25
26
  validates_presence_of :access_type
@@ -29,13 +30,13 @@ class Chouette::AccessPoint < Chouette::TridentActiveRecord
29
30
  validates_numericality_of :latitude, :less_than_or_equal_to => 90, :greater_than_or_equal_to => -90, :allow_nil => true
30
31
  validates_numericality_of :longitude, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180, :allow_nil => true
31
32
 
32
- validates_presence_of :x, :if => :y
33
- validates_presence_of :y, :if => :x
34
- validates_numericality_of :x, :allow_nil => true
35
- validates_numericality_of :y, :allow_nil => true
33
+ #validates_presence_of :x, :if => :y
34
+ #validates_presence_of :y, :if => :x
35
+ #validates_numericality_of :x, :allow_nil => true
36
+ #validates_numericality_of :y, :allow_nil => true
36
37
 
37
38
  def self.nullable_attributes
38
- [:street_name, :country_code, :comment, :projection_type, :long_lat_type, :x, :y]
39
+ [:street_name, :country_code, :comment, :long_lat_type]
39
40
  end
40
41
 
41
42
  def to_lat_lng
@@ -142,4 +143,7 @@ class Chouette::AccessPoint < Chouette::TridentActiveRecord
142
143
  matrix
143
144
  end
144
145
 
146
+ def geometry_presenter
147
+ Chouette::Geometry::AccessPointPresenter.new self
148
+ end
145
149
  end
@@ -1,6 +1,6 @@
1
1
  class Chouette::ConnectionLink < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  attr_accessor :connection_link_type
6
6
 
@@ -39,5 +39,9 @@ class Chouette::ConnectionLink < Chouette::TridentActiveRecord
39
39
  GeoRuby::SimpleFeatures::LineString.from_points( [ departure.geometry, arrival.geometry], 4326) if departure.geometry and arrival.geometry
40
40
  end
41
41
 
42
+ def geometry_presenter
43
+ Chouette::Geometry::ConnectionLinkPresenter.new self
44
+ end
45
+
42
46
  end
43
47
 
@@ -1,6 +1,6 @@
1
1
  class Chouette::GroupOfLine < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  has_and_belongs_to_many :lines, :class_name => 'Chouette::Line', :order => 'lines.name'
6
6
 
@@ -1,6 +1,6 @@
1
1
  class Chouette::JourneyPattern < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  belongs_to :route
6
6
  has_many :vehicle_journeys, :dependent => :destroy
@@ -1,6 +1,6 @@
1
1
  class Chouette::Line < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  attr_accessor :transport_mode
6
6
  attr_accessible :transport_mode, :network_id, :company_id, :objectid, :object_version
@@ -29,6 +29,10 @@ class Chouette::Line < Chouette::TridentActiveRecord
29
29
  [:published_name, :number, :comment]
30
30
  end
31
31
 
32
+ def geometry_presenter
33
+ Chouette::Geometry::LinePresenter.new self
34
+ end
35
+
32
36
  def transport_mode
33
37
  # return nil if transport_mode_name is nil
34
38
  transport_mode_name && Chouette::TransportMode.new( transport_mode_name.underscore)
@@ -0,0 +1,4 @@
1
+ class Chouette::MobilityNeed < Chouette::ActiveRecord
2
+ set_primary_key :id
3
+
4
+ end
@@ -1,6 +1,6 @@
1
1
  class Chouette::Network < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  has_many :lines
6
6
 
@@ -2,7 +2,7 @@ require 'geokit'
2
2
 
3
3
  class Chouette::PtLink < Chouette::ActiveRecord
4
4
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
5
- set_primary_key :id
5
+ self.primary_key = "id"
6
6
 
7
7
  attr_accessible :start_of_link_id, :end_of_link_id, :route_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :link_distance
8
8
  include Geokit::Mappable
@@ -1,6 +1,6 @@
1
1
  class Chouette::Route < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  attr_accessor :wayback_code
6
6
  attr_accessor :direction_code
@@ -60,6 +60,10 @@ class Chouette::Route < Chouette::TridentActiveRecord
60
60
 
61
61
  before_destroy :dereference_opposite_route
62
62
 
63
+ def geometry_presenter
64
+ Chouette::Geometry::RoutePresenter.new self
65
+ end
66
+
63
67
  def dereference_opposite_route
64
68
  self.line.routes.each do |r|
65
69
  r.update_attributes( :opposite_route => nil) if r.opposite_route == self
@@ -3,7 +3,7 @@ require 'geo_ruby'
3
3
 
4
4
  class Chouette::StopArea < Chouette::TridentActiveRecord
5
5
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
6
- set_primary_key :id
6
+ self.primary_key = "id"
7
7
  include Geokit::Mappable
8
8
  has_many :stop_points, :dependent => :destroy
9
9
  has_many :access_points, :dependent => :destroy
@@ -18,14 +18,11 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
18
18
 
19
19
  attr_accessible :routing_stop_ids, :routing_line_ids, :children_ids, :stop_area_type, :parent_id, :objectid
20
20
  attr_accessible :object_version, :creation_time, :creator_id, :name, :comment, :area_type, :registration_number
21
- attr_accessible :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type, :x, :y, :projection_type
21
+ attr_accessible :nearest_topic_name, :fare_code, :longitude, :latitude, :long_lat_type
22
22
  attr_accessible :country_code, :street_name
23
-
24
- # workaround of ruby 1.8 private method y block attribute y reading access
25
- def y
26
- read_attribute :y
27
- end
23
+ attr_accessible :mobility_restricted_suitability, :stairs_availability, :lift_availability, :int_user_needs
28
24
 
25
+
29
26
  validates_uniqueness_of :registration_number, :allow_nil => true, :allow_blank => true
30
27
  validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_blank => true
31
28
  validates_presence_of :name
@@ -36,13 +33,8 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
36
33
  validates_numericality_of :latitude, :less_than_or_equal_to => 90, :greater_than_or_equal_to => -90, :allow_nil => true
37
34
  validates_numericality_of :longitude, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180, :allow_nil => true
38
35
 
39
- validates_presence_of :x, :if => :y
40
- validates_presence_of :y, :if => :x
41
- validates_numericality_of :x, :allow_nil => true
42
- validates_numericality_of :y, :allow_nil => true
43
-
44
36
  def self.nullable_attributes
45
- [:registration_number, :street_name, :country_code, :fare_code, :nearest_topic_name, :comment, :projection_type, :long_lat_type]
37
+ [:registration_number, :street_name, :country_code, :fare_code, :nearest_topic_name, :comment, :long_lat_type]
46
38
  end
47
39
 
48
40
  after_update :clean_invalid_access_links
@@ -75,6 +67,10 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
75
67
  end
76
68
  end
77
69
 
70
+ def geometry_presenter
71
+ Chouette::Geometry::StopAreaPresenter.new self
72
+ end
73
+
78
74
  def lines
79
75
  if (area_type == 'CommercialStopPoint')
80
76
  self.children.collect(&:stop_points).flatten.collect(&:route).flatten.collect(&:line).flatten.uniq
@@ -91,6 +87,18 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
91
87
  where :area_type => "CommercialStopPoint"
92
88
  end
93
89
 
90
+ def self.stop_place
91
+ where :area_type => "StopPlace"
92
+ end
93
+
94
+ def self.physical
95
+ where :area_type => [ "BoardingPosition", "Quay" ]
96
+ end
97
+
98
+ def self.itl
99
+ where :area_type => "ITL"
100
+ end
101
+
94
102
  def to_lat_lng
95
103
  Geokit::LatLng.new(latitude, longitude) if latitude and longitude
96
104
  end
@@ -1,6 +1,6 @@
1
1
  class Chouette::StopPoint < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  belongs_to :stop_area
6
6
  belongs_to :route
@@ -0,0 +1,5 @@
1
+ class Chouette::Suitability < Chouette::ActiveRecord
2
+ set_primary_key :id
3
+
4
+ end
5
+
@@ -1,6 +1,6 @@
1
1
  class Chouette::TimeTable < Chouette::TridentActiveRecord
2
2
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
3
- set_primary_key :id
3
+ self.primary_key = "id"
4
4
 
5
5
  attr_accessible :objectid, :object_version, :creation_time, :creator_id, :version, :comment
6
6
  attr_accessible :int_day_types,:monday,:tuesday,:wednesday,:thursday,:friday,:saturday,:sunday
@@ -60,8 +60,17 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord
60
60
  end
61
61
  end
62
62
 
63
+ # Return days which intersects with the time table dates and periods
64
+ def intersects(days)
65
+ [].tap do |intersect_days|
66
+ days.each do |day|
67
+ intersect_days << day if include_day?(day)
68
+ end
69
+ end
70
+ end
71
+
63
72
  def include_day?(day)
64
- self.dates.any?{ |d| d.date === day } || self.periods.any?{ |period| period.period_start <= day && day <= period.period_end }
73
+ include_in_dates?(day) || include_in_periods?(day)
65
74
  end
66
75
 
67
76
  def include_in_dates?(day)
@@ -1,5 +1,5 @@
1
1
  class Chouette::TimeTableDate < Chouette::ActiveRecord
2
- set_primary_key :id
2
+ self.primary_key = "id"
3
3
  belongs_to :time_table
4
4
  acts_as_list :scope => 'time_table_id = #{time_table_id}',:top_of_list => 0
5
5
 
@@ -1,5 +1,5 @@
1
1
  class Chouette::TimeTablePeriod < Chouette::ActiveRecord
2
- set_primary_key :id
2
+ self.primary_key = "id"
3
3
  belongs_to :time_table
4
4
  acts_as_list :scope => 'time_table_id = #{time_table_id}',:top_of_list => 0
5
5
 
@@ -1,7 +1,7 @@
1
1
  class Chouette::VehicleJourney < Chouette::TridentActiveRecord
2
2
  #
3
3
  # FIXME http://jira.codehaus.org/browse/JRUBY-6358
4
- set_primary_key :id
4
+ self.primary_key = "id"
5
5
 
6
6
  attr_accessor :transport_mode_name
7
7
  attr_accessible :route_id, :journey_pattern_id, :time_slot_id, :company_id, :objectid, :object_version, :creation_time, :creator_id, :comment, :status_value
@@ -1,5 +1,5 @@
1
1
  class Chouette::VehicleJourneyAtStop < Chouette::ActiveRecord
2
- set_primary_key :id
2
+ self.primary_key = "id"
3
3
 
4
4
  belongs_to :stop_point
5
5
  belongs_to :vehicle_journey
@@ -0,0 +1,11 @@
1
+ class Chouette::Geometry::AccessLinkPresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(access_link)
5
+ @access_link = access_link
6
+ end
7
+
8
+ def geometry
9
+ to_line_string_feature( [ @access_link.stop_area , @access_link.access_point ] )
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class Chouette::Geometry::AccessPointPresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(access_point)
5
+ @access_point = access_point
6
+ end
7
+
8
+ def geometry
9
+ to_point_feature( @access_point)
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class Chouette::Geometry::ConnectionLinkPresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(connection_link)
5
+ @connection_link = connection_link
6
+ end
7
+
8
+ def geometry
9
+ to_line_string_feature( @connection_link.stop_areas)
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module Chouette::Geometry::GeneralPresenter
2
+
3
+ def to_line_string_feature( stop_areas)
4
+ points = stop_areas.collect(&:geometry).compact
5
+ GeoRuby::SimpleFeatures::LineString.from_points(points)
6
+ end
7
+
8
+ def to_multi_point_feature( stop_areas)
9
+ points = stop_areas.collect(&:geometry).compact
10
+ GeoRuby::SimpleFeatures::MultiPoint.from_points( points )
11
+ end
12
+
13
+ def to_point_feature( stop_area)
14
+ return nil unless stop_area.longitude && stop_area.latitude
15
+ GeoRuby::SimpleFeatures::Point.from_lon_lat( stop_area.longitude, stop_area.latitude, 4326)
16
+ end
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,42 @@
1
+ class Chouette::Geometry::LinePresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(line)
5
+ @line = line
6
+ end
7
+
8
+ # return line geometry based on CommercialStopPoint
9
+ #
10
+ def geometry
11
+ features = commercial_links.map { |link| to_line_string_feature(link) }
12
+ GeoRuby::SimpleFeatures::MultiLineString.from_line_strings( features, 4326)
13
+ end
14
+ #
15
+ # return line's stop_areas cloud geometry
16
+ #
17
+ def stop_areas_geometry
18
+ to_multi_point_feature( @line.commercial_stop_areas)
19
+ end
20
+
21
+ def commercial_links
22
+ link_keys = []
23
+ [].tap do |stop_area_links|
24
+ @line.routes.each do |route|
25
+ previous_commercial = nil
26
+ routes_localized_commercials(route).each do |commercial|
27
+ if previous_commercial && !link_keys.include?( "#{previous_commercial.id}-#{commercial.id}")
28
+ stop_area_links << [ previous_commercial, commercial]
29
+ link_keys << "#{previous_commercial.id}-#{commercial.id}"
30
+ link_keys << "#{commercial.id}-#{previous_commercial.id}"
31
+ end
32
+ previous_commercial = commercial
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def routes_localized_commercials(route)
39
+ route.stop_areas.map { |sa| sa.parent}.compact.select { |sa| sa.latitude && sa.longitude}
40
+ end
41
+
42
+ end
@@ -0,0 +1,22 @@
1
+ class Chouette::Geometry::RoutePresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(route)
5
+ @route = route
6
+ end
7
+
8
+ # return route's stop_areas cloud geometry
9
+ #
10
+ def stop_areas_geometry
11
+ to_multi_point_feature( @route.stop_areas.with_geometry )
12
+ end
13
+
14
+ # return route geometry based on BoardingPosition or Quay
15
+ #
16
+ def geometry
17
+ to_line_string_feature( @route.stop_areas.with_geometry )
18
+ end
19
+
20
+
21
+ end
22
+
@@ -0,0 +1,13 @@
1
+ class Chouette::Geometry::StopAreaPresenter
2
+ include Chouette::Geometry::GeneralPresenter
3
+
4
+ def initialize(stop_area)
5
+ @stop_area = stop_area
6
+ end
7
+
8
+ # return line geometry based on CommercialStopPoint
9
+ #
10
+ def geometry
11
+ to_point_feature( @stop_area)
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class RemoveProjectionFromStopAreas < ActiveRecord::Migration
2
+ def up
3
+ if column_exists? :stop_areas, :x
4
+ remove_column :stop_areas, :x
5
+ end
6
+ if column_exists? :stop_areas, :y
7
+ remove_column :stop_areas, :y
8
+ end
9
+ if column_exists? :stop_areas, :projection_type
10
+ remove_column :stop_areas, :projection_type
11
+ end
12
+ end
13
+
14
+ def down
15
+ add_column :stop_areas, :x, :decimal,:precision => 19, :scale => 2
16
+ add_column :stop_areas, :y, :decimal,:precision => 19, :scale => 2
17
+ add_column :stop_areas, :projection_type, :string
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ class RemoveProjectionFromAccessPoints < ActiveRecord::Migration
2
+ def up
3
+ if column_exists? :access_points, :x
4
+ remove_column :access_points, :x
5
+ end
6
+ if column_exists? :access_points, :y
7
+ remove_column :access_points, :y
8
+ end
9
+ if column_exists? :access_points, :projection_type
10
+ remove_column :access_points, :projection_type
11
+ end
12
+ end
13
+
14
+ def down
15
+ add_column :access_points, :x, :decimal,:precision => 19, :scale => 2
16
+ add_column :access_points, :y, :decimal,:precision => 19, :scale => 2
17
+ add_column :access_points, :projection_type, :string
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ class AddAccessibilityToStopAreas < ActiveRecord::Migration
2
+ def up
3
+ unless column_exists? :stop_areas, :mobility_restricted_suitability
4
+ add_column :stop_areas, :mobility_restricted_suitability, :boolean
5
+ end
6
+ unless column_exists? :stop_areas, :stairs_availability
7
+ add_column :stop_areas, :stairs_availability, :boolean
8
+ end
9
+ unless column_exists? :stop_areas, :lift_availability
10
+ add_column :stop_areas, :lift_availability, :boolean
11
+ end
12
+ unless column_exists? :stop_areas, :int_user_needs
13
+ add_column :stop_areas, :int_user_needs, :integer
14
+ end
15
+ end
16
+ def down
17
+ if column_exists? :stop_areas, :mobility_restricted_suitability
18
+ remove_column :stop_areas, :mobility_restricted_suitability
19
+ end
20
+ if column_exists? :stop_areas, :stairs_availability
21
+ remove_column :stop_areas, :stairs_availability
22
+ end
23
+ if column_exists? :stop_areas, :lift_availability
24
+ remove_column :stop_areas, :lift_availability
25
+ end
26
+ if column_exists? :stop_areas, :int_user_needs
27
+ remove_column :stop_areas, :int_user_needs
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ class SetAccessibiliityToExistingStopArea < ActiveRecord::Migration
2
+ def up
3
+ Chouette::StopArea.all.each do |s|
4
+ if s.mobility_restricted_suitability.nil?
5
+ s.mobility_restricted_suitability = false
6
+ s.stairs_availability = false
7
+ s.lift_availability = false
8
+ s.int_user_needs = 0
9
+ s.save
10
+ end
11
+ end
12
+ end
13
+
14
+ def down
15
+ end
16
+ end
@@ -18,3 +18,14 @@ Factory.define :line_with_stop_areas, :parent => :line do |line|
18
18
  end
19
19
  end
20
20
  end
21
+
22
+ Factory.define :line_with_stop_areas_having_parent, :parent => :line do |line|
23
+ line.after_build do |line|
24
+ route = Factory(:route, :line => line)
25
+ route.stop_points.each do |stop_point|
26
+ commercial = Factory(:stop_area, :area_type => "CommercialStopPoint")
27
+ physical = Factory(:stop_area, :area_type => "Quay", :parent_id => commercial.id)
28
+ stop_point.update_attributes( :stop_area_id => physical.id)
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Ninoxe
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -7,35 +7,6 @@ describe Chouette::AccessPoint do
7
7
  it { should validate_presence_of :name }
8
8
  it { should validate_numericality_of :latitude }
9
9
  it { should validate_numericality_of :longitude }
10
- it { should validate_numericality_of :x }
11
- it { should validate_numericality_of :y }
12
-
13
- describe ".x_y" do
14
- it "should accept x and y both as nil" do
15
- subject = Factory :access_point
16
- subject.x = nil
17
- subject.y = nil
18
- subject.valid?.should be_true
19
- end
20
- it "should accept x and y both numerical" do
21
- subject = Factory :access_point
22
- subject.x = 10
23
- subject.y = 10
24
- subject.valid?.should be_true
25
- end
26
- it "should reject x nil with y numerical" do
27
- subject = Factory :access_point
28
- subject.x = nil
29
- subject.y = 10
30
- subject.valid?.should be_false
31
- end
32
- it "should reject x numerical with y nil" do
33
- subject = Factory :access_point
34
- subject.x = 10
35
- subject.y = nil
36
- subject.valid?.should be_false
37
- end
38
- end
39
10
 
40
11
  describe ".latitude" do
41
12
  it "should accept -90 value" do
@@ -13,35 +13,7 @@ describe Chouette::StopArea do
13
13
  it { should validate_presence_of :area_type }
14
14
  it { should validate_numericality_of :latitude }
15
15
  it { should validate_numericality_of :longitude }
16
- it { should validate_numericality_of :x }
17
- it { should validate_numericality_of :y }
18
16
 
19
- describe ".x_y" do
20
- it "should accept x and y both as nil" do
21
- subject = Factory :stop_area, :area_type => "BoardingPosition"
22
- subject.x = nil
23
- subject.y = nil
24
- subject.valid?.should be_true
25
- end
26
- it "should accept x and y both numerical" do
27
- subject = Factory :stop_area, :area_type => "BoardingPosition"
28
- subject.x = 10
29
- subject.y = 10
30
- subject.valid?.should be_true
31
- end
32
- it "should reject x nil with y numerical" do
33
- subject = Factory :stop_area, :area_type => "BoardingPosition"
34
- subject.x = nil
35
- subject.y = 10
36
- subject.valid?.should be_false
37
- end
38
- it "should reject x numerical with y nil" do
39
- subject = Factory :stop_area, :area_type => "BoardingPosition"
40
- subject.x = 10
41
- subject.y = nil
42
- subject.valid?.should be_false
43
- end
44
- end
45
17
 
46
18
  describe ".latitude" do
47
19
  it "should accept -90 value" do