Stop pretending we support MySQL
This commit is contained in:
parent
4ee126a878
commit
beb0ef6357
9 changed files with 85 additions and 394 deletions
|
@ -7,26 +7,17 @@ else
|
|||
LDFLAGS=-shared
|
||||
endif
|
||||
|
||||
all: libmyosm.so libpgosm.so
|
||||
all: libpgosm.so
|
||||
|
||||
clean:
|
||||
$(RM) *.so *.o
|
||||
|
||||
libmyosm.so: quadtile-mysql.o maptile-mysql.o
|
||||
cc ${LDFLAGS} -o libmyosm.so quadtile-mysql.o maptile-mysql.o
|
||||
|
||||
libpgosm.so: quadtile-pgsql.o maptile-pgsql.o xid_to_int4-pgsql.o
|
||||
cc ${LDFLAGS} -o libpgosm.so quadtile-pgsql.o maptile-pgsql.o xid_to_int4-pgsql.o
|
||||
|
||||
quadtile-mysql.o: quadtile.c ${QTDIR}/quad_tile.h
|
||||
cc `mysql_config --include` -I${QTDIR} -fPIC -O3 -DUSE_MYSQL -c -o quadtile-mysql.o quadtile.c
|
||||
|
||||
quadtile-pgsql.o: quadtile.c ${QTDIR}/quad_tile.h
|
||||
cc -I `pg_config --includedir` -I `pg_config --includedir-server` -I${QTDIR} -fPIC -O3 -DUSE_PGSQL -c -o quadtile-pgsql.o quadtile.c
|
||||
|
||||
maptile-mysql.o: maptile.c
|
||||
cc `mysql_config --include` -fPIC -O3 -DUSE_MYSQL -c -o maptile-mysql.o maptile.c
|
||||
|
||||
maptile-pgsql.o: maptile.c
|
||||
cc -I `pg_config --includedir` -I `pg_config --includedir-server` -fPIC -O3 -DUSE_PGSQL -c -o maptile-pgsql.o maptile.c
|
||||
|
||||
|
|
|
@ -1,81 +1,22 @@
|
|||
#ifndef USE_MYSQL
|
||||
#ifndef USE_PGSQL
|
||||
#error One of USE_MYSQL or USE_PGSQL must be defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* The real maptile-for-point functionality is here */
|
||||
|
||||
static long long internal_maptile_for_point(double lat, double lon, long long zoom)
|
||||
{
|
||||
double scale = pow(2, zoom);
|
||||
double r_per_d = M_PI / 180;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
|
||||
x = floor((lon + 180.0) * scale / 360.0);
|
||||
y = floor((1 - log(tan(lat * r_per_d) + 1.0 / cos(lat * r_per_d)) / M_PI) * scale / 2.0);
|
||||
|
||||
return (x << zoom) | y;
|
||||
}
|
||||
|
||||
#ifdef USE_MYSQL
|
||||
#ifdef USE_PGSQL
|
||||
#error ONLY one of USE_MYSQL and USE_PGSQL should be defined
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql.h>
|
||||
|
||||
my_bool maptile_for_point_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
if ( args->arg_count != 3 ||
|
||||
args->arg_type[0] != INT_RESULT ||
|
||||
args->arg_type[1] != INT_RESULT ||
|
||||
args->arg_type[2] != INT_RESULT )
|
||||
{
|
||||
strcpy( message, "Your maptile_for_point arguments are bogus!" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void maptile_for_point_deinit(UDF_INIT *initid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long long maptile_for_point(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
|
||||
{
|
||||
double lat = *(long long *)args->args[0] / 10000000.0;
|
||||
double lon = *(long long *)args->args[1] / 10000000.0;
|
||||
long long zoom = *(long long *)args->args[2];
|
||||
|
||||
return internal_maptile_for_point(lat, lon, zoom);
|
||||
}
|
||||
#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
|
||||
maptile_for_point(PG_FUNCTION_ARGS)
|
||||
{
|
||||
double lat = PG_GETARG_INT64(0) / 10000000.0;
|
||||
double lon = PG_GETARG_INT64(1) / 10000000.0;
|
||||
int zoom = PG_GETARG_INT32(2);
|
||||
double lat = PG_GETARG_INT64(0) / 10000000.0;
|
||||
double lon = PG_GETARG_INT64(1) / 10000000.0;
|
||||
int zoom = PG_GETARG_INT32(2);
|
||||
double scale = pow(2, zoom);
|
||||
double r_per_d = M_PI / 180;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
|
||||
PG_RETURN_INT32(internal_maptile_for_point(lat, lon, zoom));
|
||||
x = floor((lon + 180.0) * scale / 360.0);
|
||||
y = floor((1 - log(tan(lat * r_per_d) + 1.0 / cos(lat * r_per_d)) / M_PI) * scale / 2.0);
|
||||
|
||||
PG_RETURN_INT32((x << zoom) | y);
|
||||
}
|
||||
|
||||
PG_FUNCTION_INFO_V1(maptile_for_point);
|
||||
|
@ -93,5 +34,3 @@ PG_FUNCTION_INFO_V1(maptile_for_point);
|
|||
#ifdef PG_MODULE_MAGIC
|
||||
PG_MODULE_MAGIC;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,54 +1,5 @@
|
|||
#ifndef USE_MYSQL
|
||||
#ifndef USE_PGSQL
|
||||
#error One of USE_MYSQL or USE_PGSQL must be defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <quad_tile.h>
|
||||
|
||||
#ifdef USE_MYSQL
|
||||
#ifdef USE_PGSQL
|
||||
#error ONLY one of USE_MYSQL and USE_PGSQL should be defined
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql.h>
|
||||
|
||||
my_bool tile_for_point_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
|
||||
{
|
||||
if ( args->arg_count != 2 ||
|
||||
args->arg_type[0] != INT_RESULT ||
|
||||
args->arg_type[1] != INT_RESULT )
|
||||
{
|
||||
strcpy( message, "Your tile_for_point arguments are bogus!" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tile_for_point_deinit(UDF_INIT *initid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long long tile_for_point(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
|
||||
{
|
||||
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>
|
||||
|
||||
|
@ -72,5 +23,3 @@ PG_FUNCTION_INFO_V1(tile_for_point);
|
|||
*
|
||||
* (without all the *s)
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
#ifndef USE_MYSQL
|
||||
#ifndef USE_PGSQL
|
||||
#error One of USE_MYSQL or USE_PGSQL must be defined
|
||||
#endif
|
||||
#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>
|
||||
|
||||
|
@ -26,5 +15,3 @@ int xid_to_int4(TransactionId xid)
|
|||
*
|
||||
* (without all the *s)
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue