3 #error One of USE_MYSQL or USE_PGSQL must be defined
12 #error ONLY one of USE_MYSQL and USE_PGSQL should be defined
15 #include <my_global.h>
20 my_bool tile_for_point_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
22 if ( args->arg_count != 2 ||
23 args->arg_type[0] != INT_RESULT ||
24 args->arg_type[1] != INT_RESULT )
26 strcpy( message, "Your tile_for_point arguments are bogus!" );
33 void tile_for_point_deinit(UDF_INIT *initid)
38 long long tile_for_point(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
40 long long lat = *(long long *)args->args[0];
41 long long lon = *(long long *)args->args[1];
43 return xy2tile(lon2x(lon / 10000000.0), lat2y(lat / 10000000.0));
49 #error ONLY one of USE_MYSQL and USE_PGSQL should be defined
56 tile_for_point(PG_FUNCTION_ARGS)
58 double lat = PG_GETARG_INT32(0) / 10000000.0;
59 double lon = PG_GETARG_INT32(1) / 10000000.0;
61 PG_RETURN_INT64(xy2tile(lon2x(lon), lat2y(lat)));
64 PG_FUNCTION_INFO_V1(tile_for_point);
67 * To bind this into PGSQL, try something like:
69 * CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8
70 * AS '/path/to/rails-port/db/functions/libpgosm', 'tile_for_point'
73 * (without all the *s)