Exemple #1
0
VALUE rgeo_geos_polygons_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2, char check_z)
{
  VALUE result = Qnil;
  if (geom1 && geom2) {
    result = rgeo_geos_coordseqs_eql(context, GEOSGetExteriorRing_r(context, geom1), GEOSGetExteriorRing_r(context, geom2), check_z);
    if (RTEST(result)) {
      int len1 = GEOSGetNumInteriorRings_r(context, geom1);
      int len2 = GEOSGetNumInteriorRings_r(context, geom2);
      if (len1 >= 0 && len2 >= 0) {
        if (len1 == len2) {
          int i;
          for (i=0; i<len1; ++i) {
            result = rgeo_geos_coordseqs_eql(context, GEOSGetInteriorRingN_r(context, geom1, i), GEOSGetInteriorRingN_r(context, geom2, i), check_z);
            if (!RTEST(result)) {
              break;
            }
          }
        }
        else {
          result = Qfalse;
        }
      }
      else {
        result = Qnil;
      }
    }
  }
  return result;
}
Exemple #2
0
static VALUE method_point_eql(VALUE self, VALUE rhs)
{
  VALUE result = rgeo_geos_klasses_and_factories_eql(self, rhs);
  if (RTEST(result)) {
    RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
    result = rgeo_geos_coordseqs_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom, RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
  }
  return result;
}