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)

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

def closed?
  @fg_geom.closed?
end

#coordinatesObject


407
408
409
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 407

def coordinates
  points.map(&:coordinates)
end

#end_pointObject


365
366
367
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 365

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

#geometry_typeObject


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

def geometry_type
  Feature::LineString
end

#hashObject


403
404
405
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 403

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

#is_closed?Boolean

Returns:

  • (Boolean)

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

def is_closed?
  warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
  closed?
end

#is_ring?Boolean

Returns:

  • (Boolean)

393
394
395
396
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 393

def is_ring?
  warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
  ring?
end

#lengthObject


343
344
345
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 343

def length
  @fg_geom.length
end

#num_pointsObject


347
348
349
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 347

def num_points
  @fg_geom.num_points
end

#point_n(n) ⇒ Object


351
352
353
354
355
356
357
358
359
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 351

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


369
370
371
372
373
374
375
376
377
378
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 369

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)

398
399
400
401
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 398

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

#ring?Boolean

Returns:

  • (Boolean)

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

def ring?
  @fg_geom.ring?
end

#start_pointObject


361
362
363
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 361

def start_point
  point_n(0)
end