Class: RGeo::Geographic::SphericalPointImpl

Inherits:
Object
  • Object
show all
Includes:
Feature::Point, SphericalGeometryMethods, ImplHelper::BasicGeometryMethods, ImplHelper::BasicPointMethods
Defined in:
lib/rgeo/geographic/spherical_feature_classes.rb

Overview

:nodoc:

Constant Summary

Constants included from Feature::Type

Feature::Type::Instance

Instance Method Summary collapse

Methods included from SphericalGeometryMethods

#srid

Methods included from ImplHelper::BasicPointMethods

#boundary, #convex_hull, #dimension, #envelope, #eql?, #geometry_type, #initialize, #is_empty?, #is_simple?, #m, #x, #y, #z

Methods included from ImplHelper::BasicGeometryMethods

#_set_factory, #as_binary, #as_text, #factory, #inspect, #to_s

Methods included from Feature::Point

#m, #x, #y, #z

Methods included from Feature::Type

#check_type, #subtype_of?, #type_name

Methods included from Feature::Geometry

#*, #+, #-, #==, #as_binary, #as_text, #boundary, #buffer, #contains?, #convex_hull, #crosses?, #difference, #dimension, #disjoint?, #envelope, #eql?, #factory, #geometry_type, #intersection, #intersects?, #is_empty?, #is_simple?, #overlaps?, #relate, #srid, #sym_difference, #touches?, #union, #within?

Instance Method Details

#_validate_geometryObject



51
52
53
54
55
56
57
# File 'lib/rgeo/geographic/spherical_feature_classes.rb', line 51

def _validate_geometry
  @x = @x % 360.0
  @x -= 360.0 if @x >= 180.0
  @y = 90.0 if @y > 90.0
  @y = -90.0 if @y < -90.0
  super
end

#_xyzObject



60
61
62
# File 'lib/rgeo/geographic/spherical_feature_classes.rb', line 60

def _xyz
  @xyz ||= SphericalMath::PointXYZ.from_latlon(@y, @x)
end

#distance(rhs_) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/rgeo/geographic/spherical_feature_classes.rb', line 65

def distance(rhs_)
  rhs_ = Feature.cast(rhs_, @factory)
  case rhs_
  when SphericalPointImpl
    _xyz.dist_to_point(rhs_._xyz) * SphericalMath::RADIUS
  else
    super
  end
end

#equals?(rhs_) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rgeo/geographic/spherical_feature_classes.rb', line 76

def equals?(rhs_)
  return false unless rhs_.is_a?(self.class) && rhs_.factory == self.factory
  case rhs_
  when Feature::Point
    if @y == 90
      rhs_.y == 90
    elsif @y == -90
      rhs_.y == -90
    else
      rhs_.x == @x && rhs_.y == @y
    end
  when Feature::LineString
    rhs_.num_points > 0 && rhs_.points.all?{ |elem_| equals?(elem_) }
  when Feature::GeometryCollection
    rhs_.num_geometries > 0 && rhs_.all?{ |elem_| equals?(elem_) }
  else
    false
  end
end