Module: RGeo::Geos::CAPIMultiPolygonMethods

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

Instance Method Summary collapse

Instance Method Details

#areaObject



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'ext/geos_c_impl/geometry_collection.c', line 499

static VALUE
method_multi_polygon_area(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  double area;

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

#centroidObject



518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'ext/geos_c_impl/geometry_collection.c', line 518

static VALUE
method_multi_polygon_centroid(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    result = rgeo_wrap_geos_geometry(
      self_data->factory, GEOSGetCentroid(self_geom), Qnil);
  }
  return result;
}

#coordinatesObject



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'ext/geos_c_impl/geometry_collection.c', line 470

static VALUE
method_multi_polygon_coordinates(VALUE self)
{
  VALUE result = Qnil;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;

  const GEOSGeometry* poly;
  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) {
      poly = GEOSGetGeometryN(self_geom, i);
      rb_ary_push(result, extract_points_from_polygon(poly, zCoordinate));
    }
  }

  return result;
}

#geometry_typeObject



440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'ext/geos_c_impl/geometry_collection.c', line 440

static VALUE
method_multi_polygon_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_polygon_module;
  }
  return result;
}

#hashObject



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'ext/geos_c_impl/geometry_collection.c', line 454

static VALUE
method_multi_polygon_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_polygon_module, hash);
  hash = rgeo_geos_geometry_collection_hash(self_data->geom, hash);
  return LONG2FIX(rb_hash_end(hash));
}