-CREATE FUNCTION public.maptile_for_point(bigint, bigint, integer) RETURNS integer
- LANGUAGE c STRICT
- AS '$libdir/libpgosm', 'maptile_for_point';
+CREATE FUNCTION public.tile_for_point(scaled_lat integer, scaled_lon integer) RETURNS bigint
+ LANGUAGE plpgsql IMMUTABLE
+ AS $$
+DECLARE
+ x int8; -- quantized x from lon,
+ y int8; -- quantized y from lat,
+BEGIN
+ x := round(((scaled_lon / 10000000.0) + 180.0) * 65535.0 / 360.0);
+ y := round(((scaled_lat / 10000000.0) + 90.0) * 65535.0 / 180.0);