Class: OGR::LineString

Inherits:
Object
  • Object
show all
Includes:
Geometry, Geometry::RttopoExtensions, GeometryTypes::Curve, GeometryTypes::Curve::Extensions
Defined in:
lib/ogr/geometries/line_string.rb

Direct Known Subclasses

LineString25D, LinearRing

Instance Attribute Summary

Attributes included from Geometry

#c_pointer

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GeometryTypes::Curve::Extensions

#closed?, #each_point_geometry, #end_point, #pixels, #point_geometries, #point_geometry, #start_point

Methods included from Geometry::RttopoExtensions

#make_valid

Methods included from GeometryTypes::Curve

#length, #point, #point_count=, #points, #set_point, #x, #y, #z

Methods included from Geometry

#boundary, #buffer, #centroid, #clone, #close_rings!, #contains?, #convex_hull, #coordinate_dimension, #coordinate_dimension=, #crosses?, #destroy!, #difference, #dimension, #disjoint?, #distance_to, #dump_readable, #empty!, #empty?, #envelope, #equals?, #flatten_to_2d!, #geometry_count, #import_from_wkb, #import_from_wkt, included, #intersection, #intersects?, #is_2d?, #is_3d?, #name, #overlaps?, #point_count, #point_on_surface, #polygonize, #ring?, #segmentize!, #simple?, #simplify, #spatial_reference, #spatial_reference=, #symmetric_difference, #to_geo_json, #to_geo_json_ex, #to_gml, #to_iso_wkt, #to_kml, #to_line_string, #to_linear_ring, #to_multi_line_string, #to_multi_point, #to_multi_polygon, #to_polygon, #to_wkb, #to_wkt, #touches?, #transform!, #transform_to!, #type, #type_to_name, #union, #valid?, #within?, #wkb_size

Methods included from Geometry::ClassMethods

#create, #create_from_gml, #create_from_json, #create_from_wkb, #create_from_wkt, #factory, #merge_geometry_types, #release, #type_to_name

Methods included from Geometry::EWKBIOExtensions

included, #to_ewkb

Methods included from GeometryMixins::Extensions

#!=, #collection?, #container?, #curve?, #invalid?, #surface?, #to_vector, #utm_zone

Constructor Details

#initialize(geometry_ptr = nil, spatial_reference: nil) ⇒ LineString

Returns a new instance of LineString.



28
29
30
31
32
# File 'lib/ogr/geometries/line_string.rb', line 28

def initialize(geometry_ptr = nil, spatial_reference: nil)
  geometry_ptr ||= OGR::Geometry.create(:wkbLineString)
  initialize_from_pointer(geometry_ptr)
  self.spatial_reference = spatial_reference if spatial_reference
end

Class Method Details

.approximate_arc_angles(center_x, center_y, z, primary_radius, secondary_radius, rotation, start_angle, end_angle, max_angle_step_size_degrees = 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ogr/geometries/line_string.rb', line 10

def self.approximate_arc_angles(center_x, center_y, z, primary_radius, secondary_radius,
  rotation, start_angle, end_angle, max_angle_step_size_degrees = 0)
  geometry_ptr = FFI::GDAL::GDAL.OGR_G_ApproximateArcAngles(
    center_x,
    center_y,
    z,
    primary_radius,
    secondary_radius,
    rotation,
    start_angle,
    end_angle,
    max_angle_step_size_degrees
  )
  return nil if geometry_ptr.null?

  new(geometry_ptr)
end

Instance Method Details

#add_geometry(point) ⇒ Object

Wrapper for #add_point to allow passing in an Point instead of individual coordinates.

Parameters:



51
52
53
54
55
56
57
# File 'lib/ogr/geometries/line_string.rb', line 51

def add_geometry(point)
  if point.is_3d?
    add_point(point.x, point.y, point.z)
  else
    add_point(point.x, point.y)
  end
end

#add_point(x, y, z = nil) ⇒ Object

Adds a point to a LineString or Point geometry.

Parameters:



39
40
41
42
43
44
45
# File 'lib/ogr/geometries/line_string.rb', line 39

def add_point(x, y, z = nil)
  if z
    FFI::OGR::API.OGR_G_AddPoint(@c_pointer, x, y, z)
  else
    FFI::OGR::API.OGR_G_AddPoint_2D(@c_pointer, x, y)
  end
end