Пример #1
0
    StyleProviderImpl(const StyleSheet& stylesheet, StringTable& stringTable) :
        stringTable(stringTable),
        filters(),
        gradients()
    {
        filters.nodes.reserve(24);
        filters.ways.reserve(24);
        filters.areas.reserve(24);
        filters.relations.reserve(24);
        filters.canvases.reserve(24);

        for (const Rule& rule : stylesheet.rules) {
            for (const Selector& selector : rule.selectors) {
                for (const std::string& name : selector.names) {
                    FilterMap* filtersPtr = nullptr;
                    if (name == "node") filtersPtr = &filters.nodes;
                    else if (name == "way") filtersPtr = &filters.ways;
                    else if (name == "area") filtersPtr = &filters.areas;
                    else if (name == "relation") filtersPtr = &filters.relations;
                    else if (name == "canvas") filtersPtr = &filters.canvases;
                    else
                        std::domain_error("Unexpected selector name:" + name);

                    Filter filter = Filter();
                    filter.conditions.reserve(selector.conditions.size());
                    for (const Condition& condition : selector.conditions) {
                        ConditionType c;
                        if (condition.operation == "") c.type = OpType::Exists;
                        else if (condition.operation == "=") c.type = OpType::Equals;
                        else if (condition.operation == "!=") c.type = OpType::NotEquals;
                        else
                            std::domain_error("Unexpected condition operation:" + condition.operation);

                        c.key = stringTable.getId(condition.key);
                        c.value = stringTable.getId(condition.value);
                        filter.conditions.push_back(c);
                    }

                    filter.declarations.reserve(rule.declarations.size());
                    for (auto i = 0; i < rule.declarations.size(); ++i) {
                        Declaration declaration = rule.declarations[i];
                        uint32_t key = stringTable.getId(declaration.key);

                        if (utymap::utils::GradientUtils::isGradient(declaration.value))
                            addGradient(declaration.value);

                        filter.declarations[key] = Style::value_type(new StyleDeclaration(key, declaration.value));
                    }

                    std::sort(filter.conditions.begin(), filter.conditions.end(),
                        [](const ConditionType& c1, const ConditionType& c2) { return c1.key > c2.key; });
                    for (int i = selector.zoom.start; i <= selector.zoom.end; ++i) {
                        (*filtersPtr)[i].push_back(filter);
                    }
                }
            }
        }
    }
Пример #2
0
 QuadKeyBuilderImpl(GeoStore& geoStore, StringTable& stringTable) :
     geoStore_(geoStore),
     stringTable_(stringTable),
     builderKeyId_(stringTable.getId(BuilderKeyName)),
     builderFactory_()
 {
 }
Пример #3
0
ElementStore::ElementStore(StringTable& stringTable) :
    clipKeyId_(stringTable.getId(ClipKey)),
    skipKeyId_(stringTable.getId(SkipKey)),
    sizeKeyId_(stringTable.getId(SizeKey))
{
}