summaryrefslogtreecommitdiff
path: root/sources/master/selection.sql
blob: a93e676eccb653688e82167706577d26697c9a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- ============================================================================
--
--  Taginfo
--
--  selection.sql
--
--  This database contains a selection of often used tags etc.
--
--  It is used in the next taginfo run to create some statistics, maps, etc.
--  only for those selected data.
--
-- ============================================================================

.bail ON

-- ============================================================================

ATTACH DATABASE '__DIR__/db/taginfo-db.db'     AS db;
ATTACH DATABASE '__DIR__/wiki/taginfo-wiki.db' AS wiki;

-- ============================================================================

DROP TABLE IF EXISTS interesting_tags;
CREATE TABLE interesting_tags (
    key   TEXT,
    value TEXT
);

-- MIN_COUNT_TAGS setting: sources.master.min_count_tags
INSERT INTO interesting_tags (key, value)
    SELECT DISTINCT key, NULL FROM db.keys WHERE count_all > __MIN_COUNT_TAGS__
    UNION
    SELECT key, value FROM db.tags WHERE count_all > __MIN_COUNT_TAGS__;

DELETE FROM interesting_tags WHERE key IN ('created_by', 'ele', 'height', 'is_in', 'lanes', 'layer', 'maxspeed', 'name', 'ref', 'width') AND value IS NOT NULL;
DELETE FROM interesting_tags WHERE value IS NOT NULL AND key LIKE '%:%';
DELETE FROM interesting_tags WHERE value IS NOT NULL AND key LIKE 'fresno_%';

ANALYZE interesting_tags;

-- ============================================================================

DROP TABLE IF EXISTS frequent_tags;
CREATE TABLE frequent_tags (
    key   TEXT,
    value TEXT
);

-- MIN_COUNT_FOR_MAP setting: sources.master.min_count_for_map
INSERT INTO frequent_tags (key, value) SELECT key, value FROM db.tags WHERE count_all > __MIN_COUNT_FOR_MAP__;

ANALYZE frequent_tags;

-- ============================================================================

DROP TABLE IF EXISTS interesting_relation_types;
CREATE TABLE interesting_relation_types (
    rtype TEXT
);

-- MIN_COUNT_RELATIONS_PER_TYPE setting: sources.master.min_count_relations_per_type
INSERT INTO interesting_relation_types (rtype)
    SELECT value FROM db.tags WHERE key='type' AND count_relations > __MIN_COUNT_RELATIONS_PER_TYPE__;

ANALYZE interesting_relation_types;

-- ============================================================================