Commit dfbb71a6 authored by Volker Krause's avatar Volker Krause
Browse files

Parse MapCSS selector classes

No semantics implemented for those yet though.
parent 55afdc5c
......@@ -105,9 +105,14 @@ area[shop=bakery] {
set mx:importance = 20;
}
// set class (not supported yet)
// set class
node[shop=bakery],
node[shop=pastry]
{
set .importantShops;
}
// class selectors
node.importantShops { color: "red"; }
way.importantShops|z20- { color: "green"; }
*.importantShops[access=no] { color: "blue"; }
......@@ -127,3 +127,18 @@ node[shop=pastry]
set .importantShops;
}
node.importantShops
{
color: "red";
}
way.importantShops|z20-
{
color: "green";
}
*.importantShops[access=no]
{
color: "blue";
}
......@@ -113,6 +113,7 @@ using namespace KOSMIndoorMap;
%type <selector> Selectors
%type <selector> Selector
%type <basicSelector> BasicSelector
%type <strRef> ClassSelector
%type <conditionHolder> Tests
%type <condition> Test
%type <zoomRange> ZoomRange
......@@ -186,22 +187,29 @@ Selector:
}}
;
// TODO incomplete: missing class
// TODO incomplete: missing pseudo-class
BasicSelector:
T_IDENT ZoomRange Tests {
T_IDENT[I] ClassSelector[C] ZoomRange[Z] Tests[T] {
$$ = new MapCSSBasicSelector;
$$->setObjectType($1.str, $1.len);
$$->setZoomRange($2.low, $2.high);
$$->setConditions($3);
$$->setClass($C.str, $C.len);
$$->setObjectType($I.str, $I.len);
$$->setZoomRange($Z.low, $Z.high);
$$->setConditions($T);
}
| T_STAR ZoomRange Tests {
| T_STAR ClassSelector[C] ZoomRange[Z] Tests[T] {
$$ = new MapCSSBasicSelector;
$$->objectType = MapCSSBasicSelector::Any;
$$->setZoomRange($2.low, $2.high);
$$->setConditions($3);
$$->setClass($C.str, $C.len);
$$->setZoomRange($Z.low, $Z.high);
$$->setConditions($T);
}
;
ClassSelector:
%empty { $$.str = nullptr; $$.len = 0; }
| T_DOT T_IDENT[I] { $$.str = $I.str; $$.len = $I.len; }
;
ZoomRange:
%empty { $$.low = 0; $$.high = 0; }
| T_ZOOM T_DOUBLE[Low] T_DASH T_DOUBLE[High] { $$.low = $Low; $$.high = $High; }
......
......@@ -112,6 +112,11 @@ void MapCSSBasicSelector::write(QIODevice *out) const
}
}
if (!m_class.isEmpty()) {
out->write(".");
out->write(m_class);
}
if (m_zoomLow > 0 || m_zoomHigh > 0) {
out->write("|z");
if (m_zoomLow == m_zoomHigh) {
......@@ -157,6 +162,13 @@ void MapCSSBasicSelector::setConditions(MapCSSConditionHolder *conds)
delete conds;
}
void MapCSSBasicSelector::setClass(const char *str, std::size_t len)
{
if (str) {
m_class = QByteArray(str, len);
}
}
void MapCSSChainedSelector::compile(const OSM::DataSet &dataSet)
{
......
......@@ -66,10 +66,12 @@ public:
void setObjectType(const char *str, std::size_t len);
void setZoomRange(int low, int high);
void setConditions(MapCSSConditionHolder *conds);
void setClass(const char *str, std::size_t len);
std::vector<std::unique_ptr<MapCSSCondition>> conditions;
OSM::TagKey m_areaKey;
OSM::TagKey m_typeKey;
QByteArray m_class;
int m_zoomLow = 0;
int m_zoomHigh = 0;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment