Module: RGeo::Geos::CAPIMultiLineStringMethods

Included in:
CAPIMultiLineStringImpl
Defined in:
lib/rgeo/geos/capi_feature_classes.rb,
ext/geos_c_impl/geometry_collection.c

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)

430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'ext/geos_c_impl/geometry_collection.c', line 430

static VALUE method_multi_line_string_is_closed(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  GEOSContextHandle_t self_context;
  int len;
  int i;
  const GEOSGeometry* geom;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    self_context = self_data->geos_context;
    result = Qtrue;
    len = GEOSGetNumGeometries_r(self_context, self_geom);
    if (len > 0) {
      for (i=0; i<len; ++i) {
        geom = GEOSGetGeometryN_r(self_context, self_geom, i);
        if (geom) {
          result = rgeo_is_geos_line_string_closed(self_context, self_geom);
          if (result != Qtrue) {
            break;
          }
        }
      }
    }
  }
  return result;
}

#coordinatesObject


380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'ext/geos_c_impl/geometry_collection.c', line 380

static VALUE method_multi_line_string_coordinates(VALUE self)
{
  VALUE result = Qnil;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  GEOSContextHandle_t context;
  const GEOSCoordSequence* coord_sequence;

  const GEOSGeometry* line_string;
  unsigned int count;
  unsigned int i;
  int zCoordinate;

  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;

  if(self_geom) {
    zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
    context = self_data->geos_context;
    count = GEOSGetNumGeometries_r(context, self_geom);
    result = rb_ary_new2(count);
    for(i = 0; i < count; ++i) {
      line_string = GEOSGetGeometryN_r(context, self_geom, i);
      coord_sequence = GEOSGeom_getCoordSeq_r(context, line_string);
      rb_ary_push(result, extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
    }
  }

  return result;
}

#geometry_typeObject


334
335
336
337
338
339
340
341
342
343
344
345
# File 'ext/geos_c_impl/geometry_collection.c', line 334

static VALUE method_multi_line_string_geometry_type(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  if (self_data->geom) {
    result = rgeo_feature_multi_line_string_module;
  }
  return result;
}

#hashObject


348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'ext/geos_c_impl/geometry_collection.c', line 348

static VALUE method_multi_line_string_hash(VALUE self)
{
  st_index_t hash;
  RGeo_GeometryData* self_data;
  VALUE factory;

  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  factory = self_data->factory;
  hash = rb_hash_start(0);
  hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_line_string_module, hash);
  hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
  return LONG2FIX(rb_hash_end(hash));
}

#is_closed?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)

64
65
66
67
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 64

def is_closed? # rubocop:disable Naming/PredicateName
  warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
  closed?
end

#lengthObject


411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'ext/geos_c_impl/geometry_collection.c', line 411

static VALUE method_multi_line_string_length(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  double len;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    if (GEOSLength_r(self_data->geos_context, self_geom, &len)) {
      result = rb_float_new(len);
    }
  }
  return result;
}