Module: RGeo::Geos::FFILineStringMethods

Included in:
FFILineImpl, FFILineStringImpl, FFILinearRingImpl
Defined in:
lib/rgeo/geos/ffi_feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#coordinatesObject


387
388
389
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 387

def coordinates
  points.map(&:coordinates)
end

#end_pointObject


355
356
357
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 355

def end_point
  point_n(@fg_geom.num_points - 1)
end

#geometry_typeObject


329
330
331
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 329

def geometry_type
  Feature::LineString
end

#hashObject


383
384
385
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 383

def hash
  @hash ||= Utils.ffi_coord_seq_hash(@fg_geom.coord_seq, [@factory, geometry_type].hash)
end

#is_closed?Boolean

Returns:

  • (Boolean)

370
371
372
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 370

def is_closed?
  @fg_geom.closed?
end

#is_ring?Boolean

Returns:

  • (Boolean)

374
375
376
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 374

def is_ring?
  @fg_geom.ring?
end

#lengthObject


333
334
335
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 333

def length
  @fg_geom.length
end

#num_pointsObject


337
338
339
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 337

def num_points
  @fg_geom.num_points
end

#point_n(n) ⇒ Object


341
342
343
344
345
346
347
348
349
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 341

def point_n(n)
  if n >= 0 && n < @fg_geom.num_points
    coord_seq = @fg_geom.coord_seq
    x = coord_seq.get_x(n)
    y = coord_seq.get_y(n)
    extra = @factory._has_3d ? [coord_seq.get_z(n)] : []
    @factory.point(x, y, *extra)
  end
end

#pointsObject


359
360
361
362
363
364
365
366
367
368
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 359

def points
  coord_seq = @fg_geom.coord_seq
  has_3d = @factory._has_3d
  Array.new(@fg_geom.num_points) do |n|
    x = coord_seq.get_x(n)
    y = coord_seq.get_y(n)
    extra = has_3d ? [coord_seq.get_z(n)] : []
    @factory.point(x, y, *extra)
  end
end

#rep_equals?(rhs) ⇒ Boolean

Returns:

  • (Boolean)

378
379
380
381
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 378

def rep_equals?(rhs)
  rhs.class == self.class && rhs.factory.eql?(@factory) &&
    Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
end

#start_pointObject


351
352
353
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 351

def start_point
  point_n(0)
end