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

#closed?Boolean

Returns:

  • (Boolean)


372
373
374
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 372

def closed?
  @fg_geom.closed?
end

#coordinatesObject



389
390
391
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 389

def coordinates
  points.map(&:coordinates)
end

#end_pointObject



357
358
359
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 357

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

#geometry_typeObject



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

def geometry_type
  Feature::LineString
end

#hashObject



385
386
387
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 385

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

#lengthObject



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

def length
  @fg_geom.length
end

#num_pointsObject



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

def num_points
  @fg_geom.num_points
end

#point_n(idx) ⇒ Object



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

def point_n(idx)
  return unless idx >= 0 && idx < @fg_geom.num_points

  coord_seq = @fg_geom.coord_seq
  x = coord_seq.get_x(idx)
  y = coord_seq.get_y(idx)
  extra = @factory._has_3d ? [coord_seq.get_z(idx)] : []

  @factory.point(x, y, *extra)
end

#pointsObject



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

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)


380
381
382
383
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 380

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

#ring?Boolean

Returns:

  • (Boolean)


376
377
378
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 376

def ring?
  @fg_geom.ring?
end

#start_pointObject



353
354
355
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 353

def start_point
  point_n(0)
end