Module: RGeo::Geos::CAPIMultiLineStringMethods

Included in:
CAPIMultiLineStringImpl
Defined in:
ext/geos_c_impl/geometry_collection.c

Instance Method Summary collapse

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'ext/geos_c_impl/geometry_collection.c', line 409

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

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

#coordinatesObject



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'ext/geos_c_impl/geometry_collection.c', line 357

static VALUE
method_multi_line_string_coordinates(VALUE self)
{
  VALUE result = Qnil;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  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;
    count = GEOSGetNumGeometries(self_geom);
    result = rb_ary_new2(count);
    for (i = 0; i < count; ++i) {
      line_string = GEOSGetGeometryN(self_geom, i);
      coord_sequence = GEOSGeom_getCoordSeq(line_string);
      rb_ary_push(
        result,
        extract_points_from_coordinate_sequence(coord_sequence, zCoordinate));
    }
  }

  return result;
}

#geometry_typeObject



310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'ext/geos_c_impl/geometry_collection.c', line 310

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



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'ext/geos_c_impl/geometry_collection.c', line 324

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->geom, hash);
  return LONG2FIX(rb_hash_end(hash));
}

#lengthObject



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'ext/geos_c_impl/geometry_collection.c', line 390

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(self_geom, &len)) {
      result = rb_float_new(len);
    }
  }
  return result;
}