Module: RGeo::Geos::CAPIPolygonMethods

Included in:
CAPIPolygonImpl
Defined in:
ext/geos_c_impl/polygon.c

Instance Method Summary collapse

Instance Method Details

#areaObject


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'ext/geos_c_impl/polygon.c', line 68

static VALUE method_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


87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'ext/geos_c_impl/polygon.c', line 87

static VALUE method_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), rgeo_geos_point_class);
  }
  return result;
}

#coordinatesObject


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'ext/geos_c_impl/polygon.c', line 119

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

  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;
    self_context = self_data->geos_context;
    result = extract_points_from_polygon(self_context, self_geom, zCoordinate);
  }
  return result;
}

#eql?Boolean

Returns:

  • (Boolean)

#exterior_ringObject


139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'ext/geos_c_impl/polygon.c', line 139

static VALUE method_polygon_exterior_ring(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_clone(self_data->factory, GEOSGetExteriorRing_r(self_data->geos_context, self_geom), rgeo_geos_linear_ring_class);
  }
  return result;
}

#geometry_typeObject


54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/geos_c_impl/polygon.c', line 54

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

#hashObject


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'ext/geos_c_impl/polygon.c', line 39

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

#interior_ring_n(n) ⇒ Object


175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'ext/geos_c_impl/polygon.c', line 175

static VALUE method_polygon_interior_ring_n(VALUE self, VALUE n)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  int i;
  GEOSContextHandle_t self_context;
  int num;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    i = NUM2INT(n);
    if (i >= 0) {
      self_context = self_data->geos_context;
      num = GEOSGetNumInteriorRings_r(self_context, self_geom);
      if (i < num) {
        result = rgeo_wrap_geos_geometry_clone(self_data->factory,
          GEOSGetInteriorRingN_r(self_context, self_geom, i),
          rgeo_geos_linear_ring_class);
      }
    }
  }
  return result;
}

#interior_ringsObject


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'ext/geos_c_impl/polygon.c', line 203

static VALUE method_polygon_interior_rings(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  GEOSContextHandle_t self_context;
  int count;
  VALUE factory;
  VALUE linear_ring_class;
  int i;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    self_context = self_data->geos_context;
    count = GEOSGetNumInteriorRings_r(self_context, self_geom);
    if (count >= 0) {
      result = rb_ary_new2(count);
      factory = self_data->factory;
      for (i=0; i<count; ++i) {
        rb_ary_store(result, i, rgeo_wrap_geos_geometry_clone(factory, GEOSGetInteriorRingN_r(self_context, self_geom, i), rgeo_geos_linear_ring_class));
      }
    }
  }
  return result;
}

#num_interior_ringsObject


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'ext/geos_c_impl/polygon.c', line 155

static VALUE method_polygon_num_interior_rings(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  int num;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    num = GEOSGetNumInteriorRings_r(self_data->geos_context, self_geom);
    if (num >= 0) {
      result = INT2NUM(num);
    }
  }
  return result;
}

#point_on_surfaceObject


103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'ext/geos_c_impl/polygon.c', line 103

static VALUE method_polygon_point_on_surface(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, GEOSPointOnSurface_r(self_data->geos_context, self_geom), rgeo_geos_point_class);
  }
  return result;
}

#rep_equals?Boolean

Returns:

  • (Boolean)