* The included version of the map call is quite slow and eats a lot of memory. You should consider using [CGIMap](https://github.com/zerebubuth/openstreetmap-cgimap) instead.
* Make sure you generate the i18n files and precompile the production assets: `RAILS_ENV=production rake i18n:js:export assets:precompile`
* Make sure the web server user as well as the rails user can read, write and create directories in `tmp/`.
-* If you want to use diff replication then you might want to consider installing the shared library special SQL functions for the `xid_to_int4` function. A pure SQL version is available, but may become a performance issue on large databases with a high rate of changes. Note that you will need a version of PostgreSQL < 9.6 (yes, _less than_) to use `xid` indexing, whether pure SQL or shared library.
* If you expect to serve a lot of `/changes` API calls, then you might also want to install the shared library versions of the SQL functions.
```
psql -d openstreetmap -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '`pwd`/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT"
-psql -d openstreetmap -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '`pwd`/db/functions/libpgosm', 'xid_to_int4' LANGUAGE C STRICT"
```
# Ruby development install and versions<a name="rbenv"></a> (optional)
clean:
$(RM) ${DESTDIR}/*.so ${DESTDIR}/*.o
-${DESTDIR}/libpgosm.so: ${DESTDIR}/quadtile.o ${DESTDIR}/xid_to_int4.o
+${DESTDIR}/libpgosm.so: ${DESTDIR}/quadtile.o
cc ${LDFLAGS} -o $@ $^
${DESTDIR}/%.o: %.c
RETURN (x << 1) | y;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
-
-
--- xid_to_int4 converts a PostgreSQL transaction ID (xid) to a 32-bit integer
--- which can then be used to efficiently find rows which have changed between
--- two given transactions. This is currently used by Osmosis to extract a
--- stream of edits for "diff replication" **HOWEVER** this is a pain point, as
--- (ab)using the xid in this way is _not_ supported or recommended by Postgres
--- devs. It is preventing us upgrading to PostgreSQL version 10+, and will
--- hopefully be replaced Real Soon Now.
---
--- From the Osmosis distribution by Brett Henderson:
--- https://github.com/openstreetmap/osmosis/blob/master/package/script/contrib/apidb_0.6_osmosis_xid_indexing.sql
-CREATE OR REPLACE FUNCTION xid_to_int4(t xid)
- RETURNS integer
- AS
-$$
-DECLARE
- tl bigint;
- ti int;
-BEGIN
- tl := t;
-
- IF tl >= 2147483648 THEN
- tl := tl - 4294967296;
- END IF;
-
- ti := tl;
-
- RETURN ti;
-END;
-$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+++ /dev/null
-#include <postgres.h>
-#include <fmgr.h>
-
-Datum
-xid_to_int4(PG_FUNCTION_ARGS)
-{
- TransactionId xid = PG_GETARG_INT32(0);
-
- PG_RETURN_INT32(xid);
-}
-
-PG_FUNCTION_INFO_V1(xid_to_int4);
-
-/*
- * To bind this into PGSQL, try something like:
- *
- * CREATE FUNCTION xid_to_int4(xid) RETURNS int4
- * AS '/path/to/rails-port/db/functions/libpgosm', 'xid_to_int4'
- * LANGUAGE C IMMUTABLE STRICT;
- *
- * (without all the *s)
- */
$$;
---
--- Name: xid_to_int4(xid); Type: FUNCTION; Schema: public; Owner: -
---
-
-CREATE FUNCTION public.xid_to_int4(t xid) RETURNS integer
- LANGUAGE plpgsql IMMUTABLE STRICT
- AS $$
-DECLARE
- tl bigint;
- ti int;
-BEGIN
- tl := t;
-
- IF tl >= 2147483648 THEN
- tl := tl - 4294967296;
- END IF;
-
- ti := tl;
-
- RETURN ti;
-END;
-$$;
-
-
-SET default_tablespace = '';
-
-SET default_table_access_method = heap;
-
--
-- Name: acls; Type: TABLE; Schema: public; Owner: -
--
#pushd db/functions
#sudo -u vagrant make
#sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'tile_for_point' LANGUAGE C STRICT"
-#sudo -u vagrant psql openstreetmap -c "CREATE OR REPLACE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/srv/openstreetmap-website/db/functions/libpgosm.so', 'xid_to_int4' LANGUAGE C STRICT"
#popd