mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-23 13:06:15 +03:00
update place_id to BIGINT
This commit is contained in:
parent
adb0b6ae1e
commit
4d16677d2e
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('DB.php');
|
require_once('DB.php');
|
||||||
|
|
||||||
function &getDB($bNew = false)
|
function &getDB($bNew = false, $bPersistent = false)
|
||||||
{
|
{
|
||||||
// Get the database object
|
// Get the database object
|
||||||
$oDB =& DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), false);
|
$oDB =& DB::connect(CONST_Database_DSN.($bNew?'?new_link=true':''), $bPersistent);
|
||||||
if (PEAR::IsError($oDB))
|
if (PEAR::IsError($oDB))
|
||||||
{
|
{
|
||||||
var_dump(CONST_Database_DSN);
|
var_dump(CONST_Database_DSN);
|
||||||
|
@ -121,7 +121,7 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
|
|||||||
PQclear(resPlaces);
|
PQclear(resPlaces);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (PQftype(resPlaces, 0) != PG_OID_INT4)
|
if (PQftype(resPlaces, 0) != PG_OID_INT8)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Place_id value has unexpected type\n");
|
fprintf(stderr, "Place_id value has unexpected type\n");
|
||||||
PQclear(resPlaces);
|
PQclear(resPlaces);
|
||||||
@ -131,7 +131,7 @@ void nominatim_export(int rank_min, int rank_max, const char *conninfo, const ch
|
|||||||
tuples = PQntuples(resPlaces);
|
tuples = PQntuples(resPlaces);
|
||||||
for (i = 0; i < tuples; i++)
|
for (i = 0; i < tuples; i++)
|
||||||
{
|
{
|
||||||
nominatim_exportPlace(PGint32(*((uint32_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL, NULL);
|
nominatim_exportPlace(PGint64(*((uint64_t *)PQgetvalue(resPlaces, i, 0))), conn, writer, NULL, NULL);
|
||||||
rankTotalDone++;
|
rankTotalDone++;
|
||||||
if (rankTotalDone%1000 == 0) printf("Done %i (k)\n", rankTotalDone/1000);
|
if (rankTotalDone%1000 == 0) printf("Done %i (k)\n", rankTotalDone/1000);
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ xmlHashTablePtr partionTableTagsHashDelete;
|
|||||||
char featureNameString[MAX_FEATURENAMESTRING];
|
char featureNameString[MAX_FEATURENAMESTRING];
|
||||||
char featureExtraTagString[MAX_FEATUREEXTRATAGSTRING];
|
char featureExtraTagString[MAX_FEATUREEXTRATAGSTRING];
|
||||||
|
|
||||||
|
extern int verbose;
|
||||||
|
|
||||||
void StartElement(xmlTextReaderPtr reader, const xmlChar *name)
|
void StartElement(xmlTextReaderPtr reader, const xmlChar *name)
|
||||||
{
|
{
|
||||||
char * value;
|
char * value;
|
||||||
@ -367,6 +369,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
if (fileMode == FILEMODE_UPDATE || fileMode == FILEMODE_DELETE || fileMode == FILEMODE_ADD)
|
if (fileMode == FILEMODE_UPDATE || fileMode == FILEMODE_DELETE || fileMode == FILEMODE_ADD)
|
||||||
{
|
{
|
||||||
paramValues[0] = (const char *)place_id;
|
paramValues[0] = (const char *)place_id;
|
||||||
|
if (verbose) fprintf(stderr, "placex_delete: %s\n", paramValues[0]);
|
||||||
res = PQexecPrepared(conn, "placex_delete", 1, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "placex_delete", 1, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -376,6 +379,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
|
if (verbose) fprintf(stderr, "search_name_delete: %s\n", paramValues[0]);
|
||||||
res = PQexecPrepared(conn, "search_name_delete", 1, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "search_name_delete", 1, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -385,6 +389,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
|
if (verbose) fprintf(stderr, "place_addressline_delete: %s\n", paramValues[0]);
|
||||||
res = PQexecPrepared(conn, "place_addressline_delete", 1, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "place_addressline_delete", 1, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -493,6 +498,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
paramValues[13] = (const char *)feature.geometry;
|
paramValues[13] = (const char *)feature.geometry;
|
||||||
if (strlen(paramValues[3]) && strlen(paramValues[13]))
|
if (strlen(paramValues[3]) && strlen(paramValues[13]))
|
||||||
{
|
{
|
||||||
|
if (verbose) fprintf(stderr, "placex_insert: %s\n", paramValues[0]);
|
||||||
res = PQexecPrepared(conn, "placex_insert", 14, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "placex_insert", 14, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -536,6 +542,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
{
|
{
|
||||||
paramValues[0] = (const char *)place_id;
|
paramValues[0] = (const char *)place_id;
|
||||||
paramValues[1] = feature.parentPlaceID;
|
paramValues[1] = feature.parentPlaceID;
|
||||||
|
if (verbose) fprintf(stderr, "search_name_from_parent_insert: INSERT %s %s\n", paramValues[0], paramValues[1]);
|
||||||
res = PQexecPrepared(conn, "search_name_from_parent_insert", 2, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "search_name_from_parent_insert", 2, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -548,6 +555,7 @@ void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
paramValues[0] = (const char *)place_id;
|
paramValues[0] = (const char *)place_id;
|
||||||
|
if (verbose) fprintf(stderr, "search_name_insert: INSERT %s\n", paramValues[0]);
|
||||||
res = PQexecPrepared(conn, "search_name_insert", 1, paramValues, NULL, NULL, 0);
|
res = PQexecPrepared(conn, "search_name_insert", 1, paramValues, NULL, NULL, 0);
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
@ -753,10 +761,12 @@ int nominatim_import(const char *conninfo, const char *partionTagsFilename, cons
|
|||||||
res = PQprepare(conn, "search_name_insert",
|
res = PQprepare(conn, "search_name_insert",
|
||||||
"insert into search_name (place_id, search_rank, address_rank, country_code, name_vector, nameaddress_vector, centroid) "
|
"insert into search_name (place_id, search_rank, address_rank, country_code, name_vector, nameaddress_vector, centroid) "
|
||||||
"select place_id, rank_search, rank_address, country_code, make_keywords(name), "
|
"select place_id, rank_search, rank_address, country_code, make_keywords(name), "
|
||||||
"(select uniq(sort(array_agg(parent_search_name.name_vector))) from place_addressline join search_name as parent_search_name on "
|
"(select uniq(sort(array_agg(parent_search_name.name_vector))) from search_name as parent_search_name where place_id in "
|
||||||
"(address_place_id = parent_search_name.place_id) where place_addressline.place_id = $1 ), st_centroid(geometry) from placex "
|
"(select distinct address_place_id from place_addressline where place_addressline.place_id = $1 limit 1000)"
|
||||||
|
"), st_centroid(geometry) from placex "
|
||||||
"where place_id = $1",
|
"where place_id = $1",
|
||||||
1, NULL);
|
1, NULL);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to prepare search_name_insert: %s\n", PQerrorMessage(conn));
|
fprintf(stderr, "Failed to prepare search_name_insert: %s\n", PQerrorMessage(conn));
|
||||||
|
@ -40,7 +40,6 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
int i;
|
int i;
|
||||||
int iSector;
|
int iSector;
|
||||||
int iResult;
|
int iResult;
|
||||||
int bSkip;
|
|
||||||
|
|
||||||
const char *paramValues[2];
|
const char *paramValues[2];
|
||||||
int paramLengths[2];
|
int paramLengths[2];
|
||||||
@ -117,7 +116,7 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_prepare_params[0] = PG_OID_INT4;
|
pg_prepare_params[0] = PG_OID_INT8;
|
||||||
res = PQprepare(thread_data[i].conn, "index_placex",
|
res = PQprepare(thread_data[i].conn, "index_placex",
|
||||||
"update placex set indexed_status = 0 where place_id = $1",
|
"update placex set indexed_status = 0 where place_id = $1",
|
||||||
1, pg_prepare_params);
|
1, pg_prepare_params);
|
||||||
@ -200,7 +199,7 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
|
|||||||
PQclear(resPlaces);
|
PQclear(resPlaces);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (PQftype(resPlaces, 0) != PG_OID_INT4)
|
if (PQftype(resPlaces, 0) != PG_OID_INT8)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Place_id value has unexpected type\n");
|
fprintf(stderr, "Place_id value has unexpected type\n");
|
||||||
PQclear(resPlaces);
|
PQclear(resPlaces);
|
||||||
@ -321,8 +320,8 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
const char *paramValues[1];
|
const char *paramValues[1];
|
||||||
int paramLengths[1];
|
int paramLengths[1];
|
||||||
int paramFormats[1];
|
int paramFormats[1];
|
||||||
uint32_t paramPlaceID;
|
uint64_t paramPlaceID;
|
||||||
uint32_t place_id;
|
uint64_t place_id;
|
||||||
time_t updateStartTime;
|
time_t updateStartTime;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
@ -334,12 +333,12 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
place_id = PGint32(*((uint32_t *)PQgetvalue(thread_data->res, *thread_data->count, 0)));
|
place_id = PGint64(*((uint64_t *)PQgetvalue(thread_data->res, *thread_data->count, 0)));
|
||||||
(*thread_data->count)++;
|
(*thread_data->count)++;
|
||||||
|
|
||||||
pthread_mutex_unlock( thread_data->count_mutex );
|
pthread_mutex_unlock( thread_data->count_mutex );
|
||||||
|
|
||||||
if (verbose) fprintf(stderr, " Processing place_id %d\n", place_id);
|
if (verbose) fprintf(stderr, " Processing place_id %ld\n", place_id);
|
||||||
|
|
||||||
updateStartTime = time(0);
|
updateStartTime = time(0);
|
||||||
int done = 0;
|
int done = 0;
|
||||||
@ -351,8 +350,7 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
|
|
||||||
while(!done)
|
while(!done)
|
||||||
{
|
{
|
||||||
|
paramPlaceID = PGint64(place_id);
|
||||||
paramPlaceID = PGint32(place_id);
|
|
||||||
paramValues[0] = (char *)¶mPlaceID;
|
paramValues[0] = (char *)¶mPlaceID;
|
||||||
paramLengths[0] = sizeof(paramPlaceID);
|
paramLengths[0] = sizeof(paramPlaceID);
|
||||||
paramFormats[0] = 1;
|
paramFormats[0] = 1;
|
||||||
@ -363,7 +361,7 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
{
|
{
|
||||||
if (strncmp(PQerrorMessage(thread_data->conn), "ERROR: deadlock detected", 25))
|
if (strncmp(PQerrorMessage(thread_data->conn), "ERROR: deadlock detected", 25))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "index_placex: UPDATE failed - deadlock, retrying\n");
|
fprintf(stderr, "index_placex: UPDATE failed - deadlock, retrying (%ld)\n", place_id);
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
sleep(rand() % 10);
|
sleep(rand() % 10);
|
||||||
}
|
}
|
||||||
@ -377,7 +375,7 @@ void *nominatim_indexThread(void * thread_data_in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
if (difftime(time(0), updateStartTime) > 1) fprintf(stderr, " Slow place_id %d\n", place_id);
|
if (difftime(time(0), updateStartTime) > 1) fprintf(stderr, " Slow place_id %ld\n", place_id);
|
||||||
|
|
||||||
if (thread_data->writer)
|
if (thread_data->writer)
|
||||||
{
|
{
|
||||||
|
@ -537,7 +537,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION delete_location(OLD_place_id INTEGER) RETURNS BOOLEAN
|
CREATE OR REPLACE FUNCTION delete_location(OLD_place_id BIGINT) RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -549,7 +549,7 @@ $$
|
|||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION add_location(
|
CREATE OR REPLACE FUNCTION add_location(
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
country_code varchar(2),
|
country_code varchar(2),
|
||||||
partition INTEGER,
|
partition INTEGER,
|
||||||
keywords INTEGER[],
|
keywords INTEGER[],
|
||||||
@ -654,7 +654,7 @@ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
CREATE OR REPLACE FUNCTION update_location(
|
CREATE OR REPLACE FUNCTION update_location(
|
||||||
partition INTEGER,
|
partition INTEGER,
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
place_country_code varchar(2),
|
place_country_code varchar(2),
|
||||||
name hstore,
|
name hstore,
|
||||||
rank_search INTEGER,
|
rank_search INTEGER,
|
||||||
@ -673,7 +673,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION search_name_add_words(parent_place_id INTEGER, to_add INTEGER[])
|
CREATE OR REPLACE FUNCTION search_name_add_words(parent_place_id BIGINT, to_add INTEGER[])
|
||||||
RETURNS BOOLEAN
|
RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
@ -704,7 +704,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION update_location_nameonly(partition INTEGER, OLD_place_id INTEGER, name hstore) RETURNS BOOLEAN
|
CREATE OR REPLACE FUNCTION update_location_nameonly(partition INTEGER, OLD_place_id BIGINT, name hstore) RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
newkeywords INTEGER[];
|
newkeywords INTEGER[];
|
||||||
@ -753,7 +753,7 @@ DECLARE
|
|||||||
originalnumberrange INTEGER;
|
originalnumberrange INTEGER;
|
||||||
housenum INTEGER;
|
housenum INTEGER;
|
||||||
linegeo GEOMETRY;
|
linegeo GEOMETRY;
|
||||||
search_place_id INTEGER;
|
search_place_id BIGINT;
|
||||||
defpostalcode TEXT;
|
defpostalcode TEXT;
|
||||||
|
|
||||||
havefirstpoint BOOLEAN;
|
havefirstpoint BOOLEAN;
|
||||||
@ -1176,7 +1176,7 @@ DECLARE
|
|||||||
search_maxrank INTEGER;
|
search_maxrank INTEGER;
|
||||||
address_maxrank INTEGER;
|
address_maxrank INTEGER;
|
||||||
address_street_word_id INTEGER;
|
address_street_word_id INTEGER;
|
||||||
parent_place_id_rank INTEGER;
|
parent_place_id_rank BIGINT;
|
||||||
|
|
||||||
isin TEXT[];
|
isin TEXT[];
|
||||||
isin_tokens INT[];
|
isin_tokens INT[];
|
||||||
@ -1450,7 +1450,7 @@ BEGIN
|
|||||||
-- Process area matches
|
-- Process area matches
|
||||||
location_rank_search := 100;
|
location_rank_search := 100;
|
||||||
location_distance := 0;
|
location_distance := 0;
|
||||||
--RAISE WARNING ' getNearFeatures(%,%,%,%)',NEW.partition, place_centroid, search_maxrank, isin_tokens;
|
--RAISE WARNING ' getNearFeatures(%,''%'',%,''%'')',NEW.partition, place_centroid, search_maxrank, isin_tokens;
|
||||||
FOR location IN SELECT * from getNearFeatures(NEW.partition, place_centroid, search_maxrank, isin_tokens) LOOP
|
FOR location IN SELECT * from getNearFeatures(NEW.partition, place_centroid, search_maxrank, isin_tokens) LOOP
|
||||||
|
|
||||||
--RAISE WARNING ' AREA: %',location;
|
--RAISE WARNING ' AREA: %',location;
|
||||||
@ -1460,13 +1460,15 @@ BEGIN
|
|||||||
location_distance := location.distance * 1.5;
|
location_distance := location.distance * 1.5;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF location.distance < location_distance THEN
|
IF location.distance < location_distance OR NOT location.isguess THEN
|
||||||
|
|
||||||
-- Add it to the list of search terms
|
-- Add it to the list of search terms
|
||||||
nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
|
nameaddress_vector := array_merge(nameaddress_vector, location.keywords::integer[]);
|
||||||
INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, true, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
|
INSERT INTO place_addressline VALUES (NEW.place_id, location.place_id, true, NOT address_havelevel[location.rank_address], location.distance, location.rank_address);
|
||||||
address_havelevel[location.rank_address] := true;
|
address_havelevel[location.rank_address] := true;
|
||||||
|
|
||||||
|
--RAISE WARNING ' Terms: (%) %',location, nameaddress_vector;
|
||||||
|
|
||||||
IF location.rank_address > parent_place_id_rank THEN
|
IF location.rank_address > parent_place_id_rank THEN
|
||||||
NEW.parent_place_id = location.place_id;
|
NEW.parent_place_id = location.place_id;
|
||||||
parent_place_id_rank = location.rank_address;
|
parent_place_id_rank = location.rank_address;
|
||||||
@ -1586,7 +1588,7 @@ LANGUAGE plpgsql;
|
|||||||
CREATE OR REPLACE FUNCTION place_delete() RETURNS TRIGGER
|
CREATE OR REPLACE FUNCTION place_delete() RETURNS TRIGGER
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
placeid INTEGER;
|
placeid BIGINT;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- RAISE WARNING 'delete: % % % %',OLD.osm_type,OLD.osm_id,OLD.class,OLD.type;
|
-- RAISE WARNING 'delete: % % % %',OLD.osm_type,OLD.osm_id,OLD.class,OLD.type;
|
||||||
@ -1614,7 +1616,7 @@ DECLARE
|
|||||||
existing RECORD;
|
existing RECORD;
|
||||||
existingplacex RECORD;
|
existingplacex RECORD;
|
||||||
existinggeometry GEOMETRY;
|
existinggeometry GEOMETRY;
|
||||||
existingplace_id INTEGER;
|
existingplace_id BIGINT;
|
||||||
result BOOLEAN;
|
result BOOLEAN;
|
||||||
partition INTEGER;
|
partition INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -1653,11 +1655,11 @@ BEGIN
|
|||||||
select * from placex where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type INTO existingplacex;
|
select * from placex where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type INTO existingplacex;
|
||||||
|
|
||||||
-- Handle a place changing type by removing the old data
|
-- Handle a place changing type by removing the old data
|
||||||
-- My generated 'place' types are causing havok because they overlap with real tags
|
-- My generated 'place' types are causing havok because they overlap with real keys
|
||||||
-- TODO: move them to their own special purpose key/class to avoid collisions
|
-- TODO: move them to their own special purpose key/class to avoid collisions
|
||||||
-- IF existing.osm_type IS NULL AND (NEW.type not in ('postcode','house','houses')) THEN
|
IF existing.osm_type IS NULL AND (NEW.type not in ('postcode','house','houses')) THEN
|
||||||
-- DELETE FROM place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type not in ('postcode','house','houses');
|
DELETE FROM place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type not in ('postcode','house','houses');
|
||||||
-- END IF;
|
END IF;
|
||||||
|
|
||||||
-- RAISE WARNING 'Existing: %',existing.place_id;
|
-- RAISE WARNING 'Existing: %',existing.place_id;
|
||||||
|
|
||||||
@ -1905,7 +1907,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql IMMUTABLE;
|
LANGUAGE plpgsql IMMUTABLE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_address_postcode(for_place_id INTEGER) RETURNS TEXT
|
CREATE OR REPLACE FUNCTION get_address_postcode(for_place_id BIGINT) RETURNS TEXT
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result TEXT[];
|
result TEXT[];
|
||||||
@ -1944,7 +1946,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_address_by_language(for_place_id INTEGER, languagepref TEXT[]) RETURNS TEXT
|
CREATE OR REPLACE FUNCTION get_address_by_language(for_place_id BIGINT, languagepref TEXT[]) RETURNS TEXT
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result TEXT[];
|
result TEXT[];
|
||||||
@ -1971,7 +1973,7 @@ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
DROP TYPE addressline CASCADE;
|
DROP TYPE addressline CASCADE;
|
||||||
create type addressline as (
|
create type addressline as (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
osm_type CHAR(1),
|
osm_type CHAR(1),
|
||||||
osm_id INTEGER,
|
osm_id INTEGER,
|
||||||
name HSTORE,
|
name HSTORE,
|
||||||
@ -1984,10 +1986,10 @@ create type addressline as (
|
|||||||
distance FLOAT
|
distance FLOAT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_addressdata(in_place_id INTEGER) RETURNS setof addressline
|
CREATE OR REPLACE FUNCTION get_addressdata(in_place_id BIGINT) RETURNS setof addressline
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
for_place_id INTEGER;
|
for_place_id BIGINT;
|
||||||
result TEXT[];
|
result TEXT[];
|
||||||
search TEXT[];
|
search TEXT[];
|
||||||
found INTEGER;
|
found INTEGER;
|
||||||
@ -2135,7 +2137,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_place_boundingbox(search_place_id INTEGER) RETURNS place_boundingbox
|
CREATE OR REPLACE FUNCTION get_place_boundingbox(search_place_id BIGINT) RETURNS place_boundingbox
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result place_boundingbox;
|
result place_boundingbox;
|
||||||
@ -2172,7 +2174,7 @@ $$
|
|||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
-- don't do the operation if it would be slow
|
-- don't do the operation if it would be slow
|
||||||
CREATE OR REPLACE FUNCTION get_place_boundingbox_quick(search_place_id INTEGER) RETURNS place_boundingbox
|
CREATE OR REPLACE FUNCTION get_place_boundingbox_quick(search_place_id BIGINT) RETURNS place_boundingbox
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result place_boundingbox;
|
result place_boundingbox;
|
||||||
@ -2211,7 +2213,7 @@ END;
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION update_place(search_place_id INTEGER) RETURNS BOOLEAN
|
CREATE OR REPLACE FUNCTION update_place(search_place_id BIGINT) RETURNS BOOLEAN
|
||||||
AS $$
|
AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
result place_boundingbox;
|
result place_boundingbox;
|
||||||
@ -2384,7 +2386,7 @@ DECLARE
|
|||||||
rangestartnumber INTEGER;
|
rangestartnumber INTEGER;
|
||||||
place_centroid GEOMETRY;
|
place_centroid GEOMETRY;
|
||||||
partition INTEGER;
|
partition INTEGER;
|
||||||
parent_place_id INTEGER;
|
parent_place_id BIGINT;
|
||||||
location RECORD;
|
location RECORD;
|
||||||
address_street_word_id INTEGER;
|
address_street_word_id INTEGER;
|
||||||
|
|
||||||
@ -2464,32 +2466,41 @@ DECLARE
|
|||||||
newpoints INTEGER;
|
newpoints INTEGER;
|
||||||
place_centroid GEOMETRY;
|
place_centroid GEOMETRY;
|
||||||
partition INTEGER;
|
partition INTEGER;
|
||||||
parent_place_id INTEGER;
|
out_parent_place_id BIGINT;
|
||||||
location RECORD;
|
location RECORD;
|
||||||
address_street_word_id INTEGER;
|
address_street_word_id INTEGER;
|
||||||
|
out_postcode TEXT;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
place_centroid := ST_Centroid(pointgeo);
|
place_centroid := ST_Centroid(pointgeo);
|
||||||
partition := get_partition(place_centroid, in_countrycode);
|
partition := get_partition(place_centroid, in_countrycode);
|
||||||
parent_place_id := null;
|
out_parent_place_id := null;
|
||||||
|
|
||||||
address_street_word_id := get_name_id(make_standard_name(in_street));
|
address_street_word_id := get_name_id(make_standard_name(in_street));
|
||||||
IF address_street_word_id IS NOT NULL THEN
|
IF address_street_word_id IS NOT NULL THEN
|
||||||
FOR location IN SELECT * from getNearestNamedRoadFeature(partition, place_centroid, address_street_word_id) LOOP
|
FOR location IN SELECT * from getNearestNamedRoadFeature(partition, place_centroid, address_street_word_id) LOOP
|
||||||
parent_place_id := location.place_id;
|
out_parent_place_id := location.place_id;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF parent_place_id IS NULL THEN
|
IF out_parent_place_id IS NULL THEN
|
||||||
FOR location IN SELECT place_id FROM getNearestRoadFeature(partition, place_centroid) LOOP
|
FOR location IN SELECT place_id FROM getNearestRoadFeature(partition, place_centroid) LOOP
|
||||||
parent_place_id := location.place_id;
|
out_parent_place_id := location.place_id;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
out_postcode := in_postcode;
|
||||||
|
IF out_postcode IS NULL THEN
|
||||||
|
SELECT postcode from placex where place_id = out_parent_place_id INTO out_postcode;
|
||||||
|
END IF;
|
||||||
|
IF out_postcode IS NULL THEN
|
||||||
|
out_postcode := getNearestPostcode(partition, place_centroid);
|
||||||
|
END IF;
|
||||||
|
|
||||||
newpoints := 0;
|
newpoints := 0;
|
||||||
insert into location_property_aux (place_id, partition, parent_place_id, housenumber, postcode, centroid)
|
insert into location_property_aux (place_id, partition, parent_place_id, housenumber, postcode, centroid)
|
||||||
values (nextval('seq_place'), partition, parent_place_id, in_housenumber, in_postcode, place_centroid);
|
values (nextval('seq_place'), partition, out_parent_place_id, in_housenumber, out_postcode, place_centroid);
|
||||||
newpoints := newpoints + 1;
|
newpoints := newpoints + 1;
|
||||||
|
|
||||||
RETURN newpoints;
|
RETURN newpoints;
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
|
drop type nearplace cascade;
|
||||||
create type nearplace as (
|
create type nearplace as (
|
||||||
place_id integer
|
place_id BIGINT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
drop type nearfeature cascade;
|
||||||
create type nearfeature as (
|
create type nearfeature as (
|
||||||
place_id integer,
|
place_id BIGINT,
|
||||||
keywords int[],
|
keywords int[],
|
||||||
rank_address integer,
|
rank_address integer,
|
||||||
rank_search integer,
|
rank_search integer,
|
||||||
distance float
|
distance float,
|
||||||
|
isguess boolean
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE location_area_country () INHERITS (location_area_large);
|
CREATE TABLE location_area_country () INHERITS (location_area_large);
|
||||||
@ -39,7 +42,7 @@ CREATE INDEX idx_location_property_-partition-_housenumber_parent_place_id ON lo
|
|||||||
|
|
||||||
CREATE TABLE location_road_-partition- (
|
CREATE TABLE location_road_-partition- (
|
||||||
partition integer,
|
partition integer,
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
country_code VARCHAR(2)
|
country_code VARCHAR(2)
|
||||||
);
|
);
|
||||||
SELECT AddGeometryColumn('location_road_-partition-', 'geometry', 4326, 'GEOMETRY', 2);
|
SELECT AddGeometryColumn('location_road_-partition-', 'geometry', 4326, 'GEOMETRY', 2);
|
||||||
@ -56,7 +59,7 @@ BEGIN
|
|||||||
-- start
|
-- start
|
||||||
IF in_partition = -partition- THEN
|
IF in_partition = -partition- THEN
|
||||||
FOR r IN
|
FOR r IN
|
||||||
SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(point, centroid)) as distance FROM (
|
SELECT place_id, keywords, rank_address, rank_search, min(ST_Distance(point, centroid)) as distance, isguess FROM (
|
||||||
SELECT * FROM location_area_large_-partition- WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
SELECT * FROM location_area_large_-partition- WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM location_area_country WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
SELECT * FROM location_area_country WHERE ST_Contains(geometry, point) and rank_search < maxrank
|
||||||
@ -81,7 +84,7 @@ END
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function deleteLocationArea(in_partition INTEGER, in_place_id integer) RETURNS BOOLEAN AS $$
|
create or replace function deleteLocationArea(in_partition INTEGER, in_place_id BIGINT) RETURNS BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
@ -100,7 +103,7 @@ $$
|
|||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function insertLocationAreaLarge(
|
create or replace function insertLocationAreaLarge(
|
||||||
in_partition INTEGER, in_place_id integer, in_country_code VARCHAR(2), in_keywords INTEGER[],
|
in_partition INTEGER, in_place_id BIGINT, in_country_code VARCHAR(2), in_keywords INTEGER[],
|
||||||
in_rank_search INTEGER, in_rank_address INTEGER, in_estimate BOOLEAN,
|
in_rank_search INTEGER, in_rank_address INTEGER, in_estimate BOOLEAN,
|
||||||
in_centroid GEOMETRY, in_geometry GEOMETRY) RETURNS BOOLEAN AS $$
|
in_centroid GEOMETRY, in_geometry GEOMETRY) RETURNS BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
@ -133,13 +136,13 @@ BEGIN
|
|||||||
IF in_partition = -partition- THEN
|
IF in_partition = -partition- THEN
|
||||||
FOR r IN
|
FOR r IN
|
||||||
SELECT place_id, name_vector, address_rank, search_rank,
|
SELECT place_id, name_vector, address_rank, search_rank,
|
||||||
ST_Distance(centroid, point) as distance
|
ST_Distance(centroid, point) as distance, null as isguess
|
||||||
FROM search_name_-partition-
|
FROM search_name_-partition-
|
||||||
WHERE name_vector @> ARRAY[isin_token]
|
WHERE name_vector @> ARRAY[isin_token]
|
||||||
AND search_rank < maxrank
|
AND search_rank < maxrank
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT place_id, name_vector, address_rank, search_rank,
|
SELECT place_id, name_vector, address_rank, search_rank,
|
||||||
ST_Distance(centroid, point) as distance
|
ST_Distance(centroid, point) as distance, null as isguess
|
||||||
FROM search_name_country
|
FROM search_name_country
|
||||||
WHERE name_vector @> ARRAY[isin_token]
|
WHERE name_vector @> ARRAY[isin_token]
|
||||||
AND search_rank < maxrank
|
AND search_rank < maxrank
|
||||||
@ -166,7 +169,7 @@ BEGIN
|
|||||||
IF in_partition = -partition- THEN
|
IF in_partition = -partition- THEN
|
||||||
FOR r IN
|
FOR r IN
|
||||||
SELECT place_id, name_vector, address_rank, search_rank,
|
SELECT place_id, name_vector, address_rank, search_rank,
|
||||||
ST_Distance(centroid, point) as distance
|
ST_Distance(centroid, point) as distance, null as isguess
|
||||||
FROM search_name_-partition-
|
FROM search_name_-partition-
|
||||||
WHERE name_vector @> ARRAY[isin_token]
|
WHERE name_vector @> ARRAY[isin_token]
|
||||||
AND ST_DWithin(centroid, point, 0.01)
|
AND ST_DWithin(centroid, point, 0.01)
|
||||||
@ -184,8 +187,31 @@ END
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
create or replace function getNearestPostcode(in_partition INTEGER, point GEOMETRY)
|
||||||
|
RETURNS TEXT AS $$
|
||||||
|
DECLARE
|
||||||
|
out_postcode TEXT;
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
-- start
|
||||||
|
IF in_partition = -partition- THEN
|
||||||
|
SELECT postcode
|
||||||
|
FROM location_area_large_-partition- join placex using (place_id)
|
||||||
|
WHERE st_contains(location_area_large_-partition-.geometry, point)
|
||||||
|
AND class = 'place' and type = 'postcode'
|
||||||
|
ORDER BY st_distance(location_area_large_-partition-.centroid, point) ASC limit 1
|
||||||
|
INTO out_postcode;
|
||||||
|
RETURN out_postcode;
|
||||||
|
END IF;
|
||||||
|
-- end
|
||||||
|
|
||||||
|
RAISE EXCEPTION 'Unknown partition %', in_partition;
|
||||||
|
END
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function insertSearchName(
|
create or replace function insertSearchName(
|
||||||
in_partition INTEGER, in_place_id integer, in_country_code VARCHAR(2),
|
in_partition INTEGER, in_place_id BIGINT, in_country_code VARCHAR(2),
|
||||||
in_name_vector INTEGER[], in_nameaddress_vector INTEGER[],
|
in_name_vector INTEGER[], in_nameaddress_vector INTEGER[],
|
||||||
in_rank_search INTEGER, in_rank_address INTEGER, in_importance FLOAT,
|
in_rank_search INTEGER, in_rank_address INTEGER, in_importance FLOAT,
|
||||||
in_centroid GEOMETRY) RETURNS BOOLEAN AS $$
|
in_centroid GEOMETRY) RETURNS BOOLEAN AS $$
|
||||||
@ -218,7 +244,7 @@ END
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function deleteSearchName(in_partition INTEGER, in_place_id integer) RETURNS BOOLEAN AS $$
|
create or replace function deleteSearchName(in_partition INTEGER, in_place_id BIGINT) RETURNS BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
@ -240,7 +266,7 @@ $$
|
|||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function insertLocationRoad(
|
create or replace function insertLocationRoad(
|
||||||
in_partition INTEGER, in_place_id integer, in_country_code VARCHAR(2), in_geometry GEOMETRY) RETURNS BOOLEAN AS $$
|
in_partition INTEGER, in_place_id BIGINT, in_country_code VARCHAR(2), in_geometry GEOMETRY) RETURNS BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
@ -258,7 +284,7 @@ END
|
|||||||
$$
|
$$
|
||||||
LANGUAGE plpgsql;
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
create or replace function deleteRoad(in_partition INTEGER, in_place_id integer) RETURNS BOOLEAN AS $$
|
create or replace function deleteRoad(in_partition INTEGER, in_place_id BIGINT) RETURNS BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
@ -288,7 +314,7 @@ BEGIN
|
|||||||
WHILE search_diameter < 0.1 LOOP
|
WHILE search_diameter < 0.1 LOOP
|
||||||
FOR r IN
|
FOR r IN
|
||||||
SELECT place_id, null, null, null,
|
SELECT place_id, null, null, null,
|
||||||
ST_Distance(geometry, point) as distance
|
ST_Distance(geometry, point) as distance, null as isguess
|
||||||
FROM location_road_-partition-
|
FROM location_road_-partition-
|
||||||
WHERE ST_DWithin(geometry, point, search_diameter)
|
WHERE ST_DWithin(geometry, point, search_diameter)
|
||||||
ORDER BY distance ASC limit 1
|
ORDER BY distance ASC limit 1
|
||||||
@ -330,7 +356,7 @@ BEGIN
|
|||||||
WHILE search_diameter < 0.01 LOOP
|
WHILE search_diameter < 0.01 LOOP
|
||||||
FOR r IN
|
FOR r IN
|
||||||
SELECT place_id, null, null, null,
|
SELECT place_id, null, null, null,
|
||||||
ST_Distance(geometry, line) as distance
|
ST_Distance(geometry, line) as distance, null as isguess
|
||||||
FROM location_road_-partition-
|
FROM location_road_-partition-
|
||||||
WHERE ST_DWithin(line, geometry, search_diameter)
|
WHERE ST_DWithin(line, geometry, search_diameter)
|
||||||
ORDER BY (ST_distance(geometry, p1)+
|
ORDER BY (ST_distance(geometry, p1)+
|
||||||
|
@ -29,9 +29,9 @@ CREATE SEQUENCE seq_word start 1;
|
|||||||
|
|
||||||
drop table IF EXISTS location_property CASCADE;
|
drop table IF EXISTS location_property CASCADE;
|
||||||
CREATE TABLE location_property (
|
CREATE TABLE location_property (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
partition integer,
|
partition integer,
|
||||||
parent_place_id INTEGER,
|
parent_place_id BIINT,
|
||||||
housenumber TEXT,
|
housenumber TEXT,
|
||||||
postcode TEXT
|
postcode TEXT
|
||||||
);
|
);
|
||||||
@ -49,7 +49,7 @@ CREATE INDEX idx_location_property_tiger_housenumber_parent_place_id ON location
|
|||||||
|
|
||||||
drop table IF EXISTS search_name_blank CASCADE;
|
drop table IF EXISTS search_name_blank CASCADE;
|
||||||
CREATE TABLE search_name_blank (
|
CREATE TABLE search_name_blank (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
search_rank integer,
|
search_rank integer,
|
||||||
address_rank integer,
|
address_rank integer,
|
||||||
importance FLOAT,
|
importance FLOAT,
|
||||||
@ -68,8 +68,8 @@ CREATE INDEX idx_search_name_place_id ON search_name USING BTREE (place_id);
|
|||||||
|
|
||||||
drop table IF EXISTS place_addressline;
|
drop table IF EXISTS place_addressline;
|
||||||
CREATE TABLE place_addressline (
|
CREATE TABLE place_addressline (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
address_place_id INTEGER,
|
address_place_id BIGINT,
|
||||||
fromarea boolean,
|
fromarea boolean,
|
||||||
isaddress boolean,
|
isaddress boolean,
|
||||||
distance float,
|
distance float,
|
||||||
@ -80,7 +80,7 @@ CREATE INDEX idx_place_addressline_address_place_id on place_addressline USING B
|
|||||||
|
|
||||||
drop table IF EXISTS place_boundingbox CASCADE;
|
drop table IF EXISTS place_boundingbox CASCADE;
|
||||||
CREATE TABLE place_boundingbox (
|
CREATE TABLE place_boundingbox (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
minlat float,
|
minlat float,
|
||||||
maxlat float,
|
maxlat float,
|
||||||
minlon float,
|
minlon float,
|
||||||
@ -108,7 +108,7 @@ CREATE INDEX idx_country_geometry ON country USING GIST (geometry);
|
|||||||
|
|
||||||
drop table placex;
|
drop table placex;
|
||||||
CREATE TABLE placex (
|
CREATE TABLE placex (
|
||||||
place_id INTEGER NOT NULL,
|
place_id BIGINT NOT NULL,
|
||||||
partition integer,
|
partition integer,
|
||||||
osm_type char(1),
|
osm_type char(1),
|
||||||
osm_id INTEGER,
|
osm_id INTEGER,
|
||||||
@ -122,8 +122,8 @@ CREATE TABLE placex (
|
|||||||
postcode TEXT,
|
postcode TEXT,
|
||||||
country_code varchar(2),
|
country_code varchar(2),
|
||||||
extratags HSTORE,
|
extratags HSTORE,
|
||||||
parent_place_id INTEGER,
|
parent_place_id BIGINT,
|
||||||
linked_place_id INTEGER,
|
linked_place_id BIGINT,
|
||||||
rank_address INTEGER,
|
rank_address INTEGER,
|
||||||
rank_search INTEGER,
|
rank_search INTEGER,
|
||||||
importance FLOAT,
|
importance FLOAT,
|
||||||
|
@ -87,7 +87,7 @@ CREATE SEQUENCE seq_word start 1;
|
|||||||
drop table IF EXISTS location_area CASCADE;
|
drop table IF EXISTS location_area CASCADE;
|
||||||
CREATE TABLE location_area (
|
CREATE TABLE location_area (
|
||||||
partition integer,
|
partition integer,
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
country_code VARCHAR(2),
|
country_code VARCHAR(2),
|
||||||
keywords INTEGER[],
|
keywords INTEGER[],
|
||||||
rank_search INTEGER NOT NULL,
|
rank_search INTEGER NOT NULL,
|
||||||
@ -103,9 +103,9 @@ CREATE TABLE location_area_roadfar () INHERITS (location_area);
|
|||||||
|
|
||||||
drop table IF EXISTS location_property CASCADE;
|
drop table IF EXISTS location_property CASCADE;
|
||||||
CREATE TABLE location_property (
|
CREATE TABLE location_property (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
partition integer,
|
partition integer,
|
||||||
parent_place_id INTEGER,
|
parent_place_id BIGINT,
|
||||||
housenumber TEXT,
|
housenumber TEXT,
|
||||||
postcode TEXT
|
postcode TEXT
|
||||||
);
|
);
|
||||||
@ -123,7 +123,7 @@ CREATE INDEX idx_location_property_tiger_housenumber_parent_place_id ON location
|
|||||||
|
|
||||||
drop table IF EXISTS search_name_blank CASCADE;
|
drop table IF EXISTS search_name_blank CASCADE;
|
||||||
CREATE TABLE search_name_blank (
|
CREATE TABLE search_name_blank (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
search_rank integer,
|
search_rank integer,
|
||||||
address_rank integer,
|
address_rank integer,
|
||||||
importance FLOAT,
|
importance FLOAT,
|
||||||
@ -142,8 +142,8 @@ CREATE INDEX idx_search_name_place_id ON search_name USING BTREE (place_id);
|
|||||||
|
|
||||||
drop table IF EXISTS place_addressline;
|
drop table IF EXISTS place_addressline;
|
||||||
CREATE TABLE place_addressline (
|
CREATE TABLE place_addressline (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
address_place_id INTEGER,
|
address_place_id BIGINT,
|
||||||
fromarea boolean,
|
fromarea boolean,
|
||||||
isaddress boolean,
|
isaddress boolean,
|
||||||
distance float,
|
distance float,
|
||||||
@ -154,7 +154,7 @@ CREATE INDEX idx_place_addressline_address_place_id on place_addressline USING B
|
|||||||
|
|
||||||
drop table IF EXISTS place_boundingbox CASCADE;
|
drop table IF EXISTS place_boundingbox CASCADE;
|
||||||
CREATE TABLE place_boundingbox (
|
CREATE TABLE place_boundingbox (
|
||||||
place_id INTEGER,
|
place_id BIGINT,
|
||||||
minlat float,
|
minlat float,
|
||||||
maxlat float,
|
maxlat float,
|
||||||
minlon float,
|
minlon float,
|
||||||
@ -172,7 +172,7 @@ drop table IF EXISTS reverse_cache;
|
|||||||
CREATE TABLE reverse_cache (
|
CREATE TABLE reverse_cache (
|
||||||
latlonzoomid integer,
|
latlonzoomid integer,
|
||||||
country_code varchar(2),
|
country_code varchar(2),
|
||||||
place_id INTEGER
|
place_id BIGINT
|
||||||
);
|
);
|
||||||
GRANT SELECT on reverse_cache to "www-data" ;
|
GRANT SELECT on reverse_cache to "www-data" ;
|
||||||
GRANT INSERT on reverse_cache to "www-data" ;
|
GRANT INSERT on reverse_cache to "www-data" ;
|
||||||
@ -192,7 +192,7 @@ CREATE INDEX idx_country_geometry ON country USING GIST (geometry);
|
|||||||
|
|
||||||
drop table placex;
|
drop table placex;
|
||||||
CREATE TABLE placex (
|
CREATE TABLE placex (
|
||||||
place_id INTEGER NOT NULL,
|
place_id BIGINT NOT NULL,
|
||||||
partition integer,
|
partition integer,
|
||||||
osm_type char(1),
|
osm_type char(1),
|
||||||
osm_id INTEGER,
|
osm_id INTEGER,
|
||||||
@ -206,8 +206,8 @@ CREATE TABLE placex (
|
|||||||
postcode TEXT,
|
postcode TEXT,
|
||||||
country_code varchar(2),
|
country_code varchar(2),
|
||||||
extratags HSTORE,
|
extratags HSTORE,
|
||||||
parent_place_id INTEGER,
|
parent_place_id BIGINT,
|
||||||
linked_place_id INTEGER,
|
linked_place_id BIGINT,
|
||||||
rank_address INTEGER,
|
rank_address INTEGER,
|
||||||
rank_search INTEGER,
|
rank_search INTEGER,
|
||||||
importance FLOAT,
|
importance FLOAT,
|
||||||
|
@ -424,7 +424,7 @@
|
|||||||
2 => STDERR
|
2 => STDERR
|
||||||
);
|
);
|
||||||
$ahPipes = null;
|
$ahPipes = null;
|
||||||
$hProcess = proc_open($sCMD, $aDescriptors, $ahPipes);
|
$hProcess = @proc_open($sCMD, $aDescriptors, $ahPipes);
|
||||||
if (!is_resource($hProcess)) fail('unable to start pgsql');
|
if (!is_resource($hProcess)) fail('unable to start pgsql');
|
||||||
|
|
||||||
while(strlen($sScript))
|
while(strlen($sScript))
|
||||||
|
Loading…
Reference in New Issue
Block a user