class OGR::Point25D

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

Public Class Methods

new(geometry_ptr = nil, spatial_reference: nil) click to toggle source

@param [FFI::Pointer] geometry_ptr

Calls superclass method OGR::Point::new
# 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

Public Instance Methods

add_point(x, y, z) click to toggle source

Adds a point to a LineString or Point geometry.

@param x [Float] @param y [Float] @param z [Float]

# 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
point() click to toggle source

@return [Array<Float, Float, Float>] [x, y, z].

# 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) click to toggle source

@param x [Number] @param y [Number] @param z [Number]

# 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
z() click to toggle source

@return [Float]

# File lib/ogr/geometries/point_25d.rb, line 16
def z
  return if empty?

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