Esempio n. 1
0
def website_search_request(context, fmt, query, addr):
    params = {}
    if query:
        params['q'] = query
    if addr is not None:
        params['addressdetails'] = '1'

    outp, status = send_api_query('search', params, fmt, context)

    context.response = SearchResponse(outp, fmt or 'json', status)
Esempio n. 2
0
def query_cmd(context, query, dups):
    """ Query directly via PHP script.
    """
    cmd = ['/usr/bin/env', 'php']
    cmd.append(os.path.join(context.nominatim.build_dir, 'utils', 'query.php'))
    if query:
        cmd.extend(['--search', query])
    # add more parameters in table form
    if context.table:
        for h in context.table.headings:
            value = context.table[0][h].strip()
            if value:
                cmd.extend(('--' + h, value))

    if dups:
        cmd.extend(('--dedupe', '0'))

    outp, err = run_script(cmd, cwd=context.nominatim.build_dir)

    context.response = SearchResponse(outp, 'json')
Esempio n. 3
0
def query_cmd(context, query, dups):
    """ Query directly via PHP script.
    """
    cmd = ['/usr/bin/env', 'php']
    cmd.append(context.nominatim.src_dir  / 'lib-php' / 'admin' / 'query.php')
    if query:
        cmd.extend(['--search', query])
    # add more parameters in table form
    if context.table:
        for h in context.table.headings:
            value = context.table[0][h].strip()
            if value:
                cmd.extend(('--' + h, value))

    if dups:
        cmd.extend(('--dedupe', '0'))

    outp, err = run_script(cmd, cwd=context.nominatim.website_dir.name,
                           env=context.nominatim.test_env)

    context.response = SearchResponse(outp, 'json')
Esempio n. 4
0
def website_lookup_request(context, fmt, query):
    params = {'osm_ids': query}
    outp, status = send_api_query('lookup', params, fmt, context)

    context.response = SearchResponse(outp, fmt or 'xml', status)