Class: OGR::Point25D

Inherits:
Point
  • Object
show all
Includes:
Geometry::RttopoExtensions
Defined in:
lib/ogr/geometries/point_25d.rb

Overview

NOTE: {{#type} will return :wkbPoint (read: 2D instead of 2.5D) until a Z value is set.

Instance Attribute Summary

Attributes included from Geometry

#c_pointer

Instance Method Summary collapse

Methods included from Geometry::RttopoExtensions

#make_valid

Methods inherited from Point

#x, #y

Methods included from OGR::Point::Extensions

#point_values

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) ⇒ Point25D

Returns a new instance of Point25D.

Parameters:

  • geometry_ptr (FFI::Pointer) (defaults to: nil)


10
11
12
13
# File 'lib/ogr/geometries/point_25d.rb', line 10

def initialize(geometry_ptr = nil, spatial_reference: nil)
  geometry_ptr ||= OGR::Geometry.create(:wkbPoint25D)
  super(geometry_ptr, spatial_reference: spatial_reference)
end

Instance Method Details

#add_point(x, y, z) ⇒ Object

Adds a point to a LineString or Point geometry.

Parameters:



46
47
48
# File 'lib/ogr/geometries/point_25d.rb', line 46

def add_point(x, y, z)
  FFI::OGR::API.OGR_G_AddPoint(@c_pointer, x, y, z)
end

#pointArray<Float, Float, Float>

Returns [x, y, z].

Returns:



23
24
25
26
27
28
29
30
31
32
# File 'lib/ogr/geometries/point_25d.rb', line 23

def point
  return [] if empty?

  x_ptr = FFI::MemoryPointer.new(:double)
  y_ptr = FFI::MemoryPointer.new(:double)
  z_ptr = FFI::MemoryPointer.new(:double)
  FFI::OGR::API.OGR_G_GetPoint(@c_pointer, 0, x_ptr, y_ptr, z_ptr)

  [x_ptr.read_double, y_ptr.read_double, z_ptr.read_double]
end

#set_point(x, y, z) ⇒ Object

Parameters:

  • x (Number)
  • y (Number)
  • z (Number)


37
38
39
# File 'lib/ogr/geometries/point_25d.rb', line 37

def set_point(x, y, z)
  FFI::OGR::API.OGR_G_SetPoint(@c_pointer, 0, x, y, z)
end

#zFloat

Returns:



16
17
18
19
20
# File 'lib/ogr/geometries/point_25d.rb', line 16

def z
  return if empty?

  FFI::OGR::API.OGR_G_GetZ(@c_pointer, 0)
end