Module: RGeo::ImplHelper::BasicMultiLineStringMethods

Included in:
Cartesian::MultiLineStringImpl, Geographic::ProjectedMultiLineStringImpl, Geographic::SphericalMultiLineStringImpl
Defined in:
lib/rgeo/impl_helper/basic_geometry_collection_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#boundaryObject


114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 114

def boundary
  hash = {}
  @elements.each do |line|
    if !line.empty? && !line.closed?
      add_boundary(hash, line.start_point)
      add_boundary(hash, line.end_point)
    end
  end
  array = []
  hash.each do |_hval, data_|
    array << data_[0] if data_[1].odd?
  end
  factory.multipoint([array])
end

#closed?Boolean

Returns:

  • (Boolean)

101
102
103
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 101

def closed?
  all?(&:closed?)
end

#contains?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

133
134
135
136
137
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 133

def contains?(rhs)
  return super unless Feature::Point === rhs

  @elements.any? { |line| line.contains?(rhs) }
end

#coordinatesObject


129
130
131
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 129

def coordinates
  @elements.map(&:coordinates)
end

#geometry_typeObject


97
98
99
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 97

def geometry_type
  Feature::MultiLineString
end

#initialize(factory, elements) ⇒ Object


87
88
89
90
91
92
93
94
95
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 87

def initialize(factory, elements)
  self.factory = factory
  @elements = elements.map do |elem|
    elem = Feature.cast(elem, factory, Feature::LineString, :keep_subtype)
    raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
    elem
  end
  validate_geometry
end

#is_closed?Boolean

Returns:

  • (Boolean)

105
106
107
108
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 105

def is_closed?
  warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
  closed?
end

#lengthObject


110
111
112
# File 'lib/rgeo/impl_helper/basic_geometry_collection_methods.rb', line 110

def length
  @elements.inject(0.0) { |sum, obj| sum + obj.length }
end