4 static VALUE tile_for_point(VALUE self, VALUE lat, VALUE lon)
6 unsigned int x = lon2x(NUM2DBL(lon));
7 unsigned int y = lat2y(NUM2DBL(lat));
9 return UINT2NUM(xy2tile(x, y));
12 static VALUE tiles_for_area(VALUE self, VALUE minlat, VALUE minlon, VALUE maxlat, VALUE maxlon)
14 unsigned int minx = lon2x(NUM2DBL(minlon));
15 unsigned int maxx = lon2x(NUM2DBL(maxlon));
16 unsigned int miny = lat2y(NUM2DBL(minlat));
17 unsigned int maxy = lat2y(NUM2DBL(maxlat));
18 VALUE tiles = rb_ary_new();
22 for (x = minx; x <= maxx; x++)
24 for (y = miny; y <= maxy; y++)
26 rb_ary_push(tiles, UINT2NUM(xy2tile(x, y)));
33 static VALUE tile_for_xy(VALUE self, VALUE x, VALUE y)
35 return UINT2NUM(xy2tile(NUM2UINT(x), NUM2UINT(y)));
38 void Init_quad_tile_so(void)
40 VALUE m = rb_define_module("QuadTile");
42 rb_define_module_function(m, "tile_for_point", tile_for_point, 2);
43 rb_define_module_function(m, "tiles_for_area", tiles_for_area, 4);
44 rb_define_module_function(m, "tile_for_xy", tile_for_xy, 2);