Class: Geos::LineString

Inherits:
Geometry show all
Includes:
Enumerable
Defined in:
lib/ffi-geos/line_string.rb

Direct Known Subclasses

LinearRing

Constant Summary

Constants included from GeomTypes

GeomTypes::GEOS_GEOMETRYCOLLECTION, GeomTypes::GEOS_LINEARRING, GeomTypes::GEOS_LINESTRING, GeomTypes::GEOS_MULTILINESTRING, GeomTypes::GEOS_MULTIPOINT, GeomTypes::GEOS_MULTIPOLYGON, GeomTypes::GEOS_POINT, GeomTypes::GEOS_POLYGON

Instance Attribute Summary

Attributes inherited from Geometry

#ptr

Instance Method Summary collapse

Methods inherited from Geometry

#area, #boundary, #buffer, #centroid, #contains?, #convex_hull, #coord_seq, #covered_by?, #covers?, #crosses?, #difference, #dimensions, #disjoint?, #distance, #empty?, #end_point, #envelope, #eql?, #eql_almost?, #eql_exact?, #extract_unique_points, #geom_type, #has_z?, #hausdorff_distance, #initialize, #initialize_copy, #interpolate, #interpolate_normalized, #intersection, #intersects?, #length, #line_merge, #normalize!, #num_coordinates, #num_geometries, #overlaps?, #point_on_surface, #polygonize, #polygonize_cut_edges, #polygonize_full, #project, #project_normalized, #relate, #relate_boundary_node_rule, #relate_pattern, release, #ring?, #shared_paths, #simple?, #simplify, #snap, #srid, #srid=, #start_point, #sym_difference, #to_prepared, #to_s, #topology_preserve_simplify, #touches?, #type_id, #unary_union, #union, #union_cascaded, #valid?, #valid_detail, #valid_reason, #within?

Methods included from Tools

#bool_result, #cast_geometry_ptr, #check_enum_value, #check_geometry, #pick_srid_according_to_policy, #pick_srid_from_geoms, #symbol_for_enum

Constructor Details

This class inherits a constructor from Geos::Geometry

Instance Method Details

#[](*args) ⇒ Object Also known as: slice



42
43
44
45
46
47
48
# File 'lib/ffi-geos/line_string.rb', line 42

def [](*args)
  if args.length == 1 && args.first.is_a?(Numeric) && args.first >= 0
    self.point_n(args.first)
  else
    self.to_a[*args]
  end
end

#closed?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/ffi-geos/line_string.rb', line 67

def closed?
  bool_result(FFIGeos.GEOSisClosed_r(Geos.current_handle, self.ptr))
end

#eachObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ffi-geos/line_string.rb', line 7

def each
  if block_given?
    self.num_points.times do |n|
      yield self.point_n(n)
    end
    self
  else
    self.num_points.times.collect { |n|
      self.point_n(n)
    }.to_enum
  end
end

#num_pointsObject



21
22
23
# File 'lib/ffi-geos/line_string.rb', line 21

def num_points
  FFIGeos.GEOSGeomGetNumPoints_r(Geos.current_handle, self.ptr)
end

#offset_curve(width, options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ffi-geos/line_string.rb', line 51

def offset_curve(width, options = {})
  options = Constants::BUFFER_PARAM_DEFAULTS.merge(options)

  cast_geometry_ptr(FFIGeos.GEOSOffsetCurve_r(
      Geos.current_handle,
      self.ptr,
      width,
      options[:quad_segs],
      options[:join],
      options[:mitre_limit]
  ), {
    :srid_copy => self.srid
  })
end

#point_n(n) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ffi-geos/line_string.rb', line 30

def point_n(n)
  if n < 0 || n >= self.num_points
    raise RuntimeError.new("Index out of bounds")
  else
    cast_geometry_ptr(
      FFIGeos.GEOSGeomGetPointN_r(Geos.current_handle, self.ptr, n), {
        :srid_copy => self.srid
      }
    )
  end
end