Skip to content
Browse files

Added support for the '*' layer identifier.

  • Loading branch information...
1 parent 827cb18 commit 9235d513021ed569a292a8b2c31d3a66a88dc3a2 @beelsebob committed Apr 29, 2012
View
2 OSPParserGenerator/main.m
@@ -79,7 +79,7 @@ int main (int argc, const char * argv[])
@"OSPMapCSSRule ::= (<OSPMapCSSSelector> ',')+ <OSPMapCSSDeclaration>+ | <OSPMapCSSImport>;"
@"OSPMapCSSImport ::= '@import' 'url' '(' 'String' ')' 'Identifier';"
@"OSPMapCSSSelector ::= (<OSPMapCSSSubselector> '>'?)+ <OSPMapCSSLayerIdentifier>?;"
- @"OSPMapCSSLayerIdentifier ::= '::' 'Identifier';"
+ @"OSPMapCSSLayerIdentifier ::= '::' 'Identifier' | '::' '*';"
@"OSPMapCSSSubselector ::= <OSPMapCSSObject> 'Whitespace' | <OSPMapCSSObject> <OSPMapCSSZoom>? <OSPMapCSSTest>* <OSPMapCSSClass>*;"
@"OSPMapCSSZoom ::= '|z' <range>;"
@"range ::= 'Number' | 'Number' '-' 'Number' | 'Number' '-' | '-' 'Number';"
View
30 OpenStreetPad/Model/MapCSS/OSPMapCSSRuleset.m
@@ -93,12 +93,40 @@ - (NSDictionary *)applyToObject:(OSPAPIObject *)object atZoom:(float)zoom
if (nil == currentStyle)
{
- [styles setObject:[style mutableCopy] forKey:layerIdentifier];
+ if ([layerIdentifier isEqualToString:@"*"])
+ {
+ [styles setObject:[style mutableCopy] forKey:layerIdentifier];
+ }
+ else
+ {
+ currentStyle = [[styles objectForKey:@"*"] mutableCopy];
+ if (nil == currentStyle)
+ {
+ currentStyle = [style mutableCopy];
+ }
+ else
+ {
+ [currentStyle addEntriesFromDictionary:style];
+ }
+ [styles setObject:currentStyle forKey:layerIdentifier];
+ }
}
else
{
[currentStyle addEntriesFromDictionary:style];
}
+
+ if ([layerIdentifier isEqualToString:@"*"])
+ {
+ for (NSString *existingLayerIdentifier in styles)
+ {
+ if (![existingLayerIdentifier isEqualToString:@"*"])
+ {
+ currentStyle = [styles objectForKey:existingLayerIdentifier];
+ [currentStyle addEntriesFromDictionary:style];
+ }
+ }
+ }
}
if (stop)
View
10 OpenStreetPad/Model/MapCSS/OSPMapCSSSelector.m
@@ -57,7 +57,15 @@ - (id)initWithSyntaxTree:(CPSyntaxTree *)syntaxTree
}
[self setSubselectors:realSubselectors];
NSArray *maybeLayerIdentifier = [[syntaxTree children] objectAtIndex:1];
- [self setLayerIdentifier:[maybeLayerIdentifier count] > 0 ? [[[[maybeLayerIdentifier objectAtIndex:0] children] objectAtIndex:1] identifier] : @"default"];
+ if ([maybeLayerIdentifier count] > 0)
+ {
+ id identifier = [[[maybeLayerIdentifier objectAtIndex:0] children] objectAtIndex:1];
+ [self setLayerIdentifier:[identifier isKindOfClass:[CPKeywordToken class]] ? @"*": [identifier identifier]];
+ }
+ else
+ {
+ [self setLayerIdentifier:@"default"];
+ }
}
return self;
View
16 OpenStreetPad/OSPMapCSSParser.m
@@ -24,6 +24,7 @@ @implementation OSPMapCSSParser
BOOL inTest;
BOOL inStyle;
BOOL justTokenisedObject;
+ BOOL justTokenisedDoubleColon;
BOOL inRange;
}
@@ -72,6 +73,11 @@ - (BOOL)tokeniser:(CPTokeniser *)tokeniser shouldConsumeToken:(CPToken *)token
{
inTest = NO;
}
+ else if ([name isEqualToString:@","])
+ {
+ inTest = NO;
+ inStyle = NO;
+ }
else if ([name isEqualToString:@":"])
{
inStyle = !inTest;
@@ -134,13 +140,19 @@ - (NSArray *)tokeniser:(CPTokeniser *)tokeniser willProduceToken:(CPToken *)toke
{
return [NSArray array];
}
-
+
if ([name isEqualToString:@"node"] || [name isEqualToString:@"way" ] || [name isEqualToString:@"relation"] ||
- [name isEqualToString:@"area"] || [name isEqualToString:@"line"] || [name isEqualToString:@"canvas"] || [name isEqualToString:@"*"])
+ [name isEqualToString:@"area"] || [name isEqualToString:@"line"] || [name isEqualToString:@"canvas"] || ([name isEqualToString:@"*"] && !justTokenisedDoubleColon))
{
justTokenisedObject = YES;
}
+ justTokenisedDoubleColon = NO;
+ if ([name isEqualToString:@"::"])
+ {
+ justTokenisedDoubleColon = YES;
+ }
+
return [NSArray arrayWithObject:token];
}
View
BIN OpenStreetPad/parser.osp
Binary file not shown.
View
45 OpenStreetPad/slow.mcs
@@ -1,6 +1,6 @@
-//meta {
-// title: "Osmosnimki mapcss stylesheet"; /* title shown in the menu */
-//}
+meta {
+ title: "Osmosnimki mapcss stylesheet"; /* title shown in the menu */
+}
/*
@@ -21,46 +21,19 @@ canvas {
default-lines: false;
}
-way {
- linejoin: miter;
- linecap: none;
- casing-linecap:none;
-}
-way::centerline {
- linejoin: miter;
- linecap: none;
- casing-linecap:none;
-}
-way::ticks {
- linejoin: miter;
- linecap: none;
- casing-linecap:none;
-}
-way::label {
- linejoin: miter;
- linecap: none;
- casing-linecap:none;
-}
-way::lable {
- linejoin: miter;
- linecap: none;
- casing-linecap:none;
-}
-
-
-/*area {
+area {
fill-opacity: 0.0001;
-}*/
+}
-/*way:closed, relation[type=multipolygon] {
+way:closed, relation[type=multipolygon] {
fill-opacity: 1.0;
-}*/
+}
-/**::* {
+*::* {
text-halo-color: white;
text-anchor-horizontal: center;
text-anchor-vertical: center;
-}*/
+}

0 comments on commit 9235d51

Please sign in to comment.
Something went wrong with that request. Please try again.