示例#1
0
st_index_t rgeo_geos_coordseq_hash(GEOSContextHandle_t context, const GEOSGeometry* geom, st_index_t hash)
{
  const GEOSCoordSequence* cs;
  unsigned int len;
  unsigned int i;
  RGeo_Coordseq_Hash_Struct hash_struct;

  if (geom) {
    cs = GEOSGeom_getCoordSeq_r(context, geom);
    if (cs) {
      if (GEOSCoordSeq_getSize_r(context, cs, &len)) {
        for (i=0; i<len; ++i) {
          if (GEOSCoordSeq_getX_r(context, cs, i, &hash_struct.x)) {
            if (GEOSCoordSeq_getY_r(context, cs, i, &hash_struct.y)) {
              if (!GEOSCoordSeq_getY_r(context, cs, i, &hash_struct.z)) {
                hash_struct.z = 0;
              }
              hash_struct.seed_hash = hash;
              hash = rb_memhash(&hash_struct, sizeof(RGeo_Coordseq_Hash_Struct));
            }
          }
        }
      }
    }
  }
  return hash;
}
示例#2
0
st_index_t rgeo_geos_objbase_hash(VALUE factory, VALUE type_module, st_index_t hash)
{
  ID hash_method;
  RGeo_Objbase_Hash_Struct hash_struct;

  hash_method = RGEO_FACTORY_DATA_PTR(factory)->globals->id_hash;
  hash_struct.seed_hash = hash;
  hash_struct.h1 = FIX2LONG(rb_funcall(factory, hash_method, 0));
  hash_struct.h2 = FIX2LONG(rb_funcall(type_module, hash_method, 0));
  return rb_memhash(&hash_struct, sizeof(RGeo_Objbase_Hash_Struct));
}
示例#3
0
/* :nodoc: */
static VALUE
nucomp_hash(VALUE self)
{
    st_index_t v, h[2];
    VALUE n;

    get_dat1(self);
    n = rb_hash(dat->real);
    h[0] = NUM2LONG(n);
    n = rb_hash(dat->imag);
    h[1] = NUM2LONG(n);
    v = rb_memhash(h, sizeof(h));
    return LONG2FIX(v);
}
示例#4
0
/* :nodoc: */
static VALUE
nurat_hash(VALUE self, SEL sel)
{
    long v, h[2];
    VALUE n;

    get_dat1(self);
    n = rb_hash(dat->num);
    h[0] = NUM2LONG(n);
    n = rb_hash(dat->den);
    h[1] = NUM2LONG(n);
    v = rb_memhash(h, sizeof(h));
    return LONG2FIX(v);
}
static st_index_t
memcmp_hash_hash(st_data_t a)
{
    struct memcmp_key_data *k = (struct memcmp_key_data *)a;
    return rb_memhash(k->data, sizeof(st_data_t) * k->n);
}