Module: RGeo::Geos::CAPIMultiPolygonMethods

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

Instance Method Summary collapse

Instance Method Details

#areaObject


522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'ext/geos_c_impl/geometry_collection.c', line 522

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

#centroidObject


541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'ext/geos_c_impl/geometry_collection.c', line 541

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_r(self_data->geos_context, self_geom), Qnil);
  }
  return result;
}

#coordinatesObject


492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'ext/geos_c_impl/geometry_collection.c', line 492

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

  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;
    context = self_data->geos_context;
    count = GEOSGetNumGeometries_r(context, self_geom);
    result = rb_ary_new2(count);
    for(i = 0; i < count; ++i) {
      poly = GEOSGetGeometryN_r(context, self_geom, i);
      rb_ary_push(result, extract_points_from_polygon(context, poly, zCoordinate));
    }
  }

  return result;
}

#geometry_typeObject


463
464
465
466
467
468
469
470
471
472
473
474
# File 'ext/geos_c_impl/geometry_collection.c', line 463

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


477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'ext/geos_c_impl/geometry_collection.c', line 477

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