Class: GeoWeb::Projection::Base
- Inherits:
-
Object
- Object
- GeoWeb::Projection::Base
- Defined in:
- lib/geoweb/projection/base.rb
Instance Attribute Summary collapse
-
#transformation ⇒ Object
Returns the value of attribute transformation.
-
#zoom ⇒ Object
Returns the value of attribute zoom.
Instance Method Summary collapse
- #coordinate_location(coordinate) ⇒ Object
-
#initialize(zoom, t = Transformation.new(1, 0, 0, 0, 1, 0)) ⇒ Base
constructor
A new instance of Base.
- #location_coordinate(latlon) ⇒ Object
- #project(point) ⇒ Object
- #raw_project(point) ⇒ Object
- #raw_unproject(point) ⇒ Object
- #unproject(point) ⇒ Object
Constructor Details
#initialize(zoom, t = Transformation.new(1, 0, 0, 0, 1, 0)) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/geoweb/projection/base.rb', line 7 def initialize(zoom, t=Transformation.new(1, 0, 0, 0, 1, 0)) @zoom = zoom @transformation = t end |
Instance Attribute Details
#transformation ⇒ Object
Returns the value of attribute transformation.
5 6 7 |
# File 'lib/geoweb/projection/base.rb', line 5 def transformation @transformation end |
#zoom ⇒ Object
Returns the value of attribute zoom.
5 6 7 |
# File 'lib/geoweb/projection/base.rb', line 5 def zoom @zoom end |
Instance Method Details
#coordinate_location(coordinate) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/geoweb/projection/base.rb', line 32 def coordinate_location(coordinate) coordinate = coordinate.zoom_to(self.zoom) point = Point.new(coordinate.x, coordinate.y) point = self.unproject(point) LatLon.new(point).to_deg end |
#location_coordinate(latlon) ⇒ Object
27 28 29 30 |
# File 'lib/geoweb/projection/base.rb', line 27 def location_coordinate(latlon) point = self.project(latlon.to_rad) Coordinate.new(point.x, point.y, self.zoom) end |
#project(point) ⇒ Object
15 16 17 18 19 |
# File 'lib/geoweb/projection/base.rb', line 15 def project(point) point = self.raw_project(point) point = transformation.transform(point) unless transformation.nil? point end |
#raw_project(point) ⇒ Object
12 |
# File 'lib/geoweb/projection/base.rb', line 12 def raw_project(point); nil; end |
#raw_unproject(point) ⇒ Object
13 |
# File 'lib/geoweb/projection/base.rb', line 13 def raw_unproject(point); nil; end |
#unproject(point) ⇒ Object
21 22 23 24 25 |
# File 'lib/geoweb/projection/base.rb', line 21 def unproject(point) point = transformation.untransform(point) unless transformation.nil? point = self.raw_unproject(point) point end |