Method: RGeo::Geos::CAPILineStringMethods#point_n

Defined in:
ext/geos_c_impl/line_string.c

#point_n(n) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'ext/geos_c_impl/line_string.c', line 151

static VALUE
method_line_string_point_n(VALUE self, VALUE n)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  const GEOSCoordSequence* coord_seq;
  char has_z;
  int si;
  unsigned int i;
  unsigned int size;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    coord_seq = GEOSGeom_getCoordSeq(self_geom);
    if (coord_seq) {
      has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
                     RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
      si = RB_NUM2INT(n);
      if (si >= 0) {
        i = si;
        if (GEOSCoordSeq_getSize(coord_seq, &size)) {
          if (i < size) {
            result = get_point_from_coordseq(self, coord_seq, i, has_z);
          }
        }
      }
    }
  }
  return result;
}