Module: RGeo::Cartesian::LineStringMethods

Included in:
LineImpl, LineStringImpl, LinearRingImpl
Defined in:
lib/rgeo/cartesian/feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#crosses?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

94
95
96
97
98
99
100
101
# File 'lib/rgeo/cartesian/feature_methods.rb', line 94

def crosses?(rhs)
  case rhs
  when Feature::LineString
    crosses_line_string?(rhs)
  else
    super
  end
end

#is_simple?Boolean

Returns:

  • (Boolean)

85
86
87
88
# File 'lib/rgeo/cartesian/feature_methods.rb', line 85

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

#lengthObject


90
91
92
# File 'lib/rgeo/cartesian/feature_methods.rb', line 90

def length
  segments.inject(0.0) { |sum, seg| sum + seg.length }
end

#segmentsObject


68
69
70
71
72
# File 'lib/rgeo/cartesian/feature_methods.rb', line 68

def segments
  @segments ||= (0..num_points - 2).map do |i|
    Segment.new(point_n(i), point_n(i + 1))
  end
end

#simple?Boolean

Returns:

  • (Boolean)

74
75
76
77
78
79
80
81
82
83
# File 'lib/rgeo/cartesian/feature_methods.rb', line 74

def simple?
  # Use a SweeplineIntersector to determine if there are any self-intersections
  # in the ring. The GeometryGraph of the ring could be used by comparing the
  # edges to number of segments (graph.incident_edges.length == segments.length),
  # but this adds computational and memory overhead if graph isn't already memoized.
  # Since graph is not used elsewhere in LineStringMethods, we will just use the
  # SweeplineIntersector for now.
  li = SweeplineIntersector.new(segments)
  li.proper_intersections.empty?
end