diff options
| author | Luc Donnet | 2015-01-15 16:40:30 +0100 | 
|---|---|---|
| committer | Luc Donnet | 2015-01-15 16:40:30 +0100 | 
| commit | c89c3508eb953e79165ba61aee878db8e4d15ff5 (patch) | |
| tree | f59b362c96c13bd5facba44f356676f3383e6cd3 /app/models | |
| parent | b9a4d3cde1604f4bea01551d8c85624a313a2dfe (diff) | |
| parent | 7d984efe77efd8e610c91fcefc35c4a3e17412fd (diff) | |
| download | chouette-core-c89c3508eb953e79165ba61aee878db8e4d15ff5.tar.bz2 | |
Fix tests and merge master
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/referential.rb | 137 | 
1 files changed, 26 insertions, 111 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index e5646d7e9..be6e3a3ad 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -191,11 +191,13 @@ class Referential < ActiveRecord::Base      GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope    end -end - +  ## +  # In Development environment where cache_classes = false +  # each time a controller rb file is saved +  # ninoxe models are reloaded without after_initialize from config/initializers +  # so for development confort, it's better to keep here that after_initialize  Rails.application.config.after_initialize do -    Chouette::TridentActiveRecord    class Chouette::TridentActiveRecord @@ -212,11 +214,26 @@ Rails.application.config.after_initialize do    end +  Chouette::TimeTable + +  class Chouette::TimeTable +    def presenter +      @presenter ||= ::TimeTablePresenter.new( self) +    end +  end + +  Chouette::VehicleJourney + +  class Chouette::VehicleJourney +    def presenter +      @presenter ||= ::VehicleJourneyPresenter.new( self) +    end +  end +    Chouette::StopArea    class Chouette::StopArea - -    #attr_accessible :projection_x,:projection_y,:projection_xy +    include  NinoxeExtension::ProjectionFields      # override default_position method to add referential envelope when no stoparea is positioned      def default_position @@ -224,118 +241,16 @@ Rails.application.config.after_initialize do        Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center      end -    # add projection_type set on pre-insert and pre_update action -    before_save :set_projections -    def set_projections -      if ! self.coordinates.blank? -        self.long_lat_type = 'WGS84' -      else -        self.long_lat_type = nil -      end -    end - -    def projection -      if self.referential.projection_type.nil? || self.referential.projection_type.empty? -        nil -      else -        self.referential.projection_type -      end -    end -    @point = nil - -    def projection_x -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.x -      end -    end -    def projection_y -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.y -      end -    end -    def projection_xy -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.x.to_s+","+@point.y.to_s -      end -    end -    def projection_x=(dummy) -      # dummy method -    end -    def projection_y=(dummy) -      # dummy method -    end -    def projection_xy=(dummy) -      # dummy method -    end    end    Chouette::AccessPoint    class Chouette::AccessPoint -    #attr_accessible :projection_x,:projection_y,:projection_xy - -    # add projection_type set on pre-insert and pre_update action -    before_save :set_projections -    def set_projections -      if ! self.coordinates.blank? -        self.long_lat_type = 'WGS84' -      else -        self.long_lat_type = nil -      end -    end - -    def projection -      if self.referential.projection_type.nil? || self.referential.projection_type.empty? -        nil -      else -        self.referential.projection_type -      end -    end -    @point = nil - -    def projection_x -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.x -      end -    end -    def projection_y -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.y -      end -    end -    def projection_xy -      if self.long_lat_type.nil? || self.projection.nil? -        nil -      else -        @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i) -        @point.x.to_s+","+@point.y.to_s -      end -    end -    def projection_x=(dummy) -      # dummy method -    end -    def projection_y=(dummy) -      # dummy method -    end -    def projection_xy=(dummy) -      # dummy method -    end +    include  NinoxeExtension::ProjectionFields    end  end +end + + | 
