+ long long lat = *(long long *)args->args[0];
+ long long lon = *(long long *)args->args[1];
+
+ return xy2tile(lon2x(lon / 10000000.0), lat2y(lat / 10000000.0));
+}
+#endif
+
+#ifdef USE_PGSQL
+#ifdef USE_MYSQL
+#error ONLY one of USE_MYSQL and USE_PGSQL should be defined
+#endif
+
+#include <postgres.h>
+#include <fmgr.h>
+
+Datum
+tile_for_point(PG_FUNCTION_ARGS)
+{
+ double lat = PG_GETARG_INT32(0) / 10000000.0;
+ double lon = PG_GETARG_INT32(1) / 10000000.0;