lib/rgeo/geography/simple_mercator/feature_classes.rb in rgeo-0.1.18 vs lib/rgeo/geography/simple_mercator/feature_classes.rb in rgeo-0.1.19
- old
+ new
@@ -44,12 +44,12 @@
class PointImpl # :nodoc:
include ::RGeo::Features::Point
include ::RGeo::ImplHelpers::BasicGeometryMethods
- include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::ImplHelpers::BasicPointMethods
+ include ::RGeo::Geography::SimpleMercator::GeometryMethods
def _validate_geometry
@y = 85.0511287 if @y > 85.0511287
@y = -85.0511287 if @y < -85.0511287
@@ -68,33 +68,46 @@
def scaling_factor
1.0 / ::Math.cos(::RGeo::ImplHelpers::Math::RADIANS_PER_DEGREE * @y)
end
+ def canonical_x
+ x_ = @x % 360.0
+ x_ -= 360.0 if x_ >= 180.0
+ x_
+ end
+ alias_method :canonical_longitude, :canonical_x
+ alias_method :canonical_lon, :canonical_x
+
+
def canonical_point
if @x >= -180.0 && @x < 180.0
self
else
- x_ = @x % 360.0
- x_ -= 360.0 if x_ >= 180.0
- PointImpl.new(@factory, x_, @y)
+ PointImpl.new(@factory, canonical_x, @y)
end
end
+ alias_method :longitude, :x
+ alias_method :lon, :x
+ alias_method :latitude, :y
+ alias_method :lat, :y
+
+
end
class LineStringImpl # :nodoc:
include ::RGeo::Features::LineString
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicLineStringMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NCurveMethods
include ::RGeo::Geography::SimpleMercator::CurveMethods
- include ::RGeo::ImplHelpers::BasicLineStringMethods
include ::RGeo::Geography::SimpleMercator::LineStringMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.line_string(@points.map{ |p_| p_.projection })
@@ -107,16 +120,16 @@
class LinearRingImpl # :nodoc:
include ::RGeo::Features::Line
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicLineStringMethods
+ include ::RGeo::ImplHelpers::BasicLinearRingMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NCurveMethods
include ::RGeo::Geography::SimpleMercator::CurveMethods
- include ::RGeo::ImplHelpers::BasicLineStringMethods
include ::RGeo::Geography::SimpleMercator::LineStringMethods
- include ::RGeo::ImplHelpers::BasicLinearRingMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.linear_ring(@points.map{ |p_| p_.projection })
end
@@ -128,16 +141,16 @@
class LineImpl # :nodoc:
include ::RGeo::Features::Line
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicLineStringMethods
+ include ::RGeo::ImplHelpers::BasicLineMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NCurveMethods
include ::RGeo::Geography::SimpleMercator::CurveMethods
- include ::RGeo::ImplHelpers::BasicLineStringMethods
include ::RGeo::Geography::SimpleMercator::LineStringMethods
- include ::RGeo::ImplHelpers::BasicLineMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.line(start_point.projection, end_point.projection)
end
@@ -149,14 +162,14 @@
class PolygonImpl # :nodoc:
include ::RGeo::Features::Polygon
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicPolygonMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NSurfaceMethods
include ::RGeo::Geography::SimpleMercator::SurfaceMethods
- include ::RGeo::ImplHelpers::BasicPolygonMethods
def _validate_geometry
super
unless projection
@@ -177,12 +190,12 @@
class GeometryCollectionImpl # :nodoc:
include ::RGeo::Features::GeometryCollection
include ::RGeo::ImplHelpers::BasicGeometryMethods
- include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
+ include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.collection(@elements.map{ |p_| p_.projection })
@@ -195,14 +208,14 @@
class MultiPointImpl # :nodoc:
include ::RGeo::Features::GeometryCollection
include ::RGeo::ImplHelpers::BasicGeometryMethods
- include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
- include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
include ::RGeo::ImplHelpers::BasicMultiPointMethods
+ include ::RGeo::Geography::SimpleMercator::GeometryMethods
+ include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.multi_point(@elements.map{ |p_| p_.projection })
end
@@ -214,15 +227,15 @@
class MultiLineStringImpl # :nodoc:
include ::RGeo::Features::GeometryCollection
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
+ include ::RGeo::ImplHelpers::BasicMultiLineStringMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NCurveMethods
- include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
- include ::RGeo::ImplHelpers::BasicMultiLineStringMethods
def _make_projection(projection_factory_) # :nodoc:
projection_factory_.multi_line_string(@elements.map{ |p_| p_.projection })
end
@@ -234,14 +247,14 @@
class MultiPolygonImpl # :nodoc:
include ::RGeo::Features::GeometryCollection
include ::RGeo::ImplHelpers::BasicGeometryMethods
+ include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
+ include ::RGeo::ImplHelpers::BasicMultiPolygonMethods
include ::RGeo::Geography::SimpleMercator::GeometryMethods
include ::RGeo::Geography::SimpleMercator::NSurfaceMethods
- include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
- include ::RGeo::ImplHelpers::BasicMultiPolygonMethods
def _validate_geometry
super
unless projection