import subprocess
import random
import base64
+import sys
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
@step(u'the (named )?place (node|way|area)s')
def import_place_table_nodes(step, named, osmtype):
- """Insert a list of nodes into the placex table.
- Expects a table where columns are named in the same way as placex.
+ """Insert a list of nodes into the place table.
+ Expects a table where columns are named in the same way as place.
"""
cur = world.conn.cursor()
cur.execute('ALTER TABLE place DISABLE TRIGGER place_before_insert')
if not members:
members = None
- cur.execute("""INSERT INTO planet_osm_rels
- (id, way_off, rel_off, parts, members, tags, pending)
- VALUES (%s, %s, %s, %s, %s, %s, false)""",
+ cur.execute("""INSERT INTO planet_osm_rels
+ (id, way_off, rel_off, parts, members, tags)
+ VALUES (%s, %s, %s, %s, %s, %s)""",
(line['id'], len(parts['n']), len(parts['n']) + len(parts['w']),
parts['n'] + parts['w'] + parts['r'], members, tags))
world.conn.commit()
tags = None
nodes = [int(x.strip()) for x in line['nodes'].split(',')]
- cur.execute("""INSERT INTO planet_osm_ways
- (id, nodes, tags, pending)
- VALUES (%s, %s, %s, false)""",
+ cur.execute("""INSERT INTO planet_osm_ways (id, nodes, tags)
+ VALUES (%s, %s, %s)""",
(line['id'], nodes, tags))
world.conn.commit()
""" Runs the actual indexing. """
world.run_nominatim_script('setup', 'create-functions', 'create-partition-functions')
cur = world.conn.cursor()
+ #world.db_dump_table('place')
cur.execute("""insert into placex (osm_type, osm_id, class, type, name, admin_level,
housenumber, street, addr_place, isin, postcode, country_code, extratags,
- geometry) select * from place""")
+ geometry) select * from place where not (class='place' and type='houses' and osm_type='W')""")
+ cur.execute("""select insert_osmline (osm_id, housenumber, street, addr_place, postcode, country_code, geometry) from place where class='place' and type='houses' and osm_type='W'""")
world.conn.commit()
world.run_nominatim_script('setup', 'index', 'index-noanalyse')
#world.db_dump_table('placex')
-
+ #world.db_dump_table('location_property_osmline')
@step(u'updating place (node|way|area)s')
def update_place_table_nodes(step, osmtype):
- """ Replace a geometry in place by reinsertion and reindex database.
- """
+ """ Replace a geometry in place by reinsertion and reindex database."""
world.run_nominatim_script('setup', 'create-functions', 'create-partition-functions', 'enable-diff-updates')
if osmtype == 'node':
_insert_place_table_nodes(step.hashes, False)
(outp, err) = proc.communicate()
assert (proc.returncode == 0), "query.php failed with message: %s" % err
world.page = outp
- world.response_format = 'json'
+ world.response_format = 'json'
+ world.request_type = 'search'
world.returncode = 200