File: taginfo_impl.hpp

package info (click to toggle)
osm2pgsql 0.92.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,420 kB
  • ctags: 1,429
  • sloc: cpp: 11,650; python: 543; sh: 98; makefile: 14
file content (65 lines) | stat: -rw-r--r-- 1,963 bytes parent folder | download | duplicates (2)
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
#ifndef TAGINFO_IMPL_HPP
#define TAGINFO_IMPL_HPP

#include "taginfo.hpp"
#include "osmtypes.hpp"
#include <string>
#include <vector>
#include <utility>

enum column_flags {
  FLAG_POLYGON = 1,   /* For polygon table */
  FLAG_LINEAR = 2,    /* For lines table */
  FLAG_NOCACHE = 4,   /* Optimisation: don't bother remembering this one */
  FLAG_DELETE = 8,    /* These tags should be simply deleted on sight */
  FLAG_NOCOLUMN = 16, /* objects without column but should be listed in database hstore column */
  FLAG_PHSTORE = 17,  /* same as FLAG_NOCOLUMN & FLAG_POLYGON to maintain compatibility */
  FLAG_INT_TYPE = 32, /* column value should be converted to integer */
  FLAG_REAL_TYPE = 64 /* column value should be converted to double */
};

struct taginfo {
    taginfo();
    taginfo(const taginfo &);

    ColumnType column_type() const {
        if (flags & FLAG_INT_TYPE) {
            return COLUMN_TYPE_INT;
        }
        if (flags & FLAG_REAL_TYPE) {
            return COLUMN_TYPE_REAL;
        }
        return COLUMN_TYPE_TEXT;
    }

    std::string name, type;
    unsigned flags;
};

struct export_list {
    export_list();

    void add(enum OsmType id, const taginfo &info);
    std::vector<taginfo> &get(enum OsmType id);
    const std::vector<taginfo> &get(enum OsmType id) const;

    columns_t normal_columns(OsmType id) const;

    int num_tables;
    std::vector<std::vector<taginfo> > exportList; /* Indexed by enum OsmType */
};

/* Parse a comma or whitespace delimited list of tags to apply to
 * a style file entry, returning the OR-ed set of flags.
 */
int parse_tag_flags(const char *flags, int lineno);

/* Parse an osm2pgsql "pgsql" backend format style file, putting
 * the results in the `exlist` argument.
 *
 * Returns 1 if the 'way_area' column should (implicitly) exist, or
 * 0 if it should be suppressed.
 */
int read_style_file( const std::string &filename, export_list *exlist );

#endif /* TAGINFO_IMPL_HPP */