Method: RGeo::Geos::CAPIGeometryMethods#touches?

Defined in:
ext/geos_c_impl/geometry.c

#touches?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


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
498
499
500
501
502
503
504
505
506
507
508
509
# File 'ext/geos_c_impl/geometry.c', line 473

static VALUE
method_geometry_touches(VALUE self, VALUE rhs)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  const GEOSGeometry* rhs_geom;
  char val;
  int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
  const GEOSPreparedGeometry* prep;
#endif

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    rhs_geom =
      rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
    if (state) {
      rb_jump_tag(state);
    }
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
    prep = rgeo_request_prepared_geometry(self_data);
    if (prep)
      val = GEOSPreparedTouches(prep, rhs_geom);
    else
#endif
      val = GEOSTouches(self_geom, rhs_geom);
    if (val == 0) {
      result = Qfalse;
    } else if (val == 1) {
      result = Qtrue;
    }
  }
  return result;
}