Method: RGeo::Geos::CAPIGeometryMethods#invalid_reason

Defined in:
ext/geos_c_impl/geometry.c

#invalid_reasonObject



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'ext/geos_c_impl/geometry.c', line 1078

static VALUE
method_geometry_invalid_reason(VALUE self)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  char* str;

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    // We use NULL there to tell GEOS that we don't care about the position.
    switch (GEOSisValidDetail(self_geom, 0, &str, NULL)) {
      case 0: // invalid
        result = rb_utf8_str_new_cstr(str);
      case 1: // valid
        break;
      case 2: // exception
      default:
        result = rb_utf8_str_new_cstr("Exception");
        break;
    };
    if (str)
      GEOSFree(str);
  }
  return result;
}