Method: RGeo::Geos::CAPIGeometryMethods#crosses?

Defined in:
ext/geos_c_impl/geometry.c

#crosses?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'ext/geos_c_impl/geometry.c', line 511

static VALUE
method_geometry_crosses(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 = GEOSPreparedCrosses(prep, rhs_geom);
    else
#endif
      val = GEOSCrosses(self_geom, rhs_geom);
    if (val == 0) {
      result = Qfalse;
    } else if (val == 1) {
      result = Qtrue;
    }
  }
  return result;
}