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)


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

def closed?
  @fg_geom.closed?
end

#coordinatesObject



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

def coordinates
  points.map(&:coordinates)
end

#end_pointObject



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

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

#geometry_typeObject



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

def geometry_type
  Feature::LineString
end

#hashObject



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

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

#lengthObject



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

def length
  @fg_geom.length
end

#num_pointsObject



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

def num_points
  @fg_geom.num_points
end

#point_n(idx) ⇒ Object



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

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



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

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)


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

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)


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

def ring?
  @fg_geom.ring?
end

#start_pointObject



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

def start_point
  point_n(0)
end