diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
index 3ab46fc..51c1de5 100644
|
a
|
b
|
public class MapCSSStyleSource extends StyleSource {
|
| 58 | 58 | public final List<MapCSSRule> rules = new ArrayList<>(); |
| 59 | 59 | // rule indices, filtered by primitive type |
| 60 | 60 | public final MapCSSRuleIndex nodeRules = new MapCSSRuleIndex(); // nodes |
| 61 | | public final MapCSSRuleIndex wayRules = new MapCSSRuleIndex(); // ways without tag area=no |
| 62 | | public final MapCSSRuleIndex wayNoAreaRules = new MapCSSRuleIndex(); // ways with tag area=no |
| | 61 | public final MapCSSRuleIndex wayRules = new MapCSSRuleIndex(); // ways |
| | 62 | /** |
| | 63 | * Ways which are considered as line. |
| | 64 | * @see GeneralSelector#isLineAccordingToMapCSS(Way) |
| | 65 | */ |
| | 66 | public final MapCSSRuleIndex wayLineRules = new MapCSSRuleIndex(); |
| | 67 | /** |
| | 68 | * Ways which are considered as area. |
| | 69 | * @see GeneralSelector#isAreaAccordingToMapCSS(Way) |
| | 70 | */ |
| | 71 | public final MapCSSRuleIndex wayAreaRules = new MapCSSRuleIndex(); |
| 63 | 72 | public final MapCSSRuleIndex relationRules = new MapCSSRuleIndex(); // relations that are not multipolygon relations |
| 64 | 73 | public final MapCSSRuleIndex multipolygonRules = new MapCSSRuleIndex(); // multipolygon relations |
| 65 | 74 | public final MapCSSRuleIndex canvasRules = new MapCSSRuleIndex(); // rules to apply canvas properties |
| … |
… |
public class MapCSSStyleSource extends StyleSource {
|
| 184 | 193 | rules.clear(); |
| 185 | 194 | nodeRules.clear(); |
| 186 | 195 | wayRules.clear(); |
| 187 | | wayNoAreaRules.clear(); |
| | 196 | wayLineRules.clear(); |
| | 197 | wayAreaRules.clear(); |
| 188 | 198 | relationRules.clear(); |
| 189 | 199 | multipolygonRules.clear(); |
| 190 | 200 | canvasRules.clear(); |
| … |
… |
public class MapCSSStyleSource extends StyleSource {
|
| 231 | 241 | nodeRules.add(optRule); |
| 232 | 242 | break; |
| 233 | 243 | case "way": |
| 234 | | wayNoAreaRules.add(optRule); |
| 235 | 244 | wayRules.add(optRule); |
| | 245 | wayLineRules.add(optRule); |
| | 246 | wayAreaRules.add(optRule); |
| | 247 | break; |
| | 248 | case "line": |
| | 249 | wayLineRules.add(optRule); |
| 236 | 250 | break; |
| 237 | 251 | case "area": |
| 238 | | wayRules.add(optRule); |
| | 252 | wayAreaRules.add(optRule); |
| 239 | 253 | multipolygonRules.add(optRule); |
| 240 | 254 | break; |
| 241 | 255 | case "relation": |
| … |
… |
public class MapCSSStyleSource extends StyleSource {
|
| 245 | 259 | case "*": |
| 246 | 260 | nodeRules.add(optRule); |
| 247 | 261 | wayRules.add(optRule); |
| 248 | | wayNoAreaRules.add(optRule); |
| | 262 | wayLineRules.add(optRule); |
| | 263 | wayAreaRules.add(optRule); |
| 249 | 264 | relationRules.add(optRule); |
| 250 | 265 | multipolygonRules.add(optRule); |
| 251 | 266 | break; |
| … |
… |
public class MapCSSStyleSource extends StyleSource {
|
| 263 | 278 | } |
| 264 | 279 | nodeRules.initIndex(); |
| 265 | 280 | wayRules.initIndex(); |
| 266 | | wayNoAreaRules.initIndex(); |
| | 281 | wayLineRules.initIndex(); |
| | 282 | wayAreaRules.initIndex(); |
| 267 | 283 | relationRules.initIndex(); |
| 268 | 284 | multipolygonRules.initIndex(); |
| 269 | 285 | canvasRules.initIndex(); |
| … |
… |
public class MapCSSStyleSource extends StyleSource {
|
| 358 | 374 | |
| 359 | 375 | @Override |
| 360 | 376 | public void apply(MultiCascade mc, OsmPrimitive osm, double scale, OsmPrimitive multipolyOuterWay, boolean pretendWayIsClosed) { |
| 361 | | Environment env = new Environment(osm, mc, null, this); |
| 362 | | MapCSSRuleIndex matchingRuleIndex; |
| | 377 | final Environment env = new Environment(osm, mc, null, this); |
| | 378 | final MapCSSRuleIndex matchingRuleIndex; |
| 363 | 379 | if (osm instanceof Node) { |
| 364 | 380 | matchingRuleIndex = nodeRules; |
| 365 | 381 | } else if (osm instanceof Way) { |
| 366 | | if (osm.isKeyFalse("area")) { |
| 367 | | matchingRuleIndex = wayNoAreaRules; |
| | 382 | if (GeneralSelector.isLineAccordingToMapCSS((Way) osm)) { |
| | 383 | matchingRuleIndex = wayLineRules; |
| | 384 | } else if (GeneralSelector.isAreaAccordingToMapCSS((Way) osm)) { |
| | 385 | matchingRuleIndex = wayAreaRules; |
| 368 | 386 | } else { |
| 369 | 387 | matchingRuleIndex = wayRules; |
| 370 | 388 | } |
diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
index 18e687e..a9db6be 100644
|
a
|
b
|
public interface Selector {
|
| 443 | 443 | public GeneralSelector(String base, Pair<Integer, Integer> zoom, List<Condition> conds, String subpart) { |
| 444 | 444 | super(base, zoom, conds, subpart); |
| 445 | 445 | } |
| | 446 | |
| | 447 | /** |
| | 448 | * Determines whether the way is an area according to the MapCSS standard, i.e., |
| | 449 | * "A way where the start and finish nodes are the same node, or area=yes has been set." |
| | 450 | */ |
| | 451 | public static boolean isAreaAccordingToMapCSS(Way w) { |
| | 452 | return w.isClosed() || w.isKeyTrue("area"); |
| | 453 | } |
| | 454 | |
| | 455 | /** |
| | 456 | * Determines whether the way is an line according to the MapCSS standard, i.e., |
| | 457 | * "A way where the start and finish nodes are not the same node, or area=no has been set." |
| | 458 | */ |
| | 459 | public static boolean isLineAccordingToMapCSS(Way w) { |
| | 460 | return !w.isClosed() || w.isKeyFalse("area"); |
| | 461 | } |
| 446 | 462 | |
| 447 | 463 | public boolean matchesBase(OsmPrimitiveType type) { |
| 448 | 464 | if ("*".equals(base)) { |
| … |
… |
public interface Selector {
|
| 450 | 466 | } else if (OsmPrimitiveType.NODE.equals(type)) { |
| 451 | 467 | return "node".equals(base); |
| 452 | 468 | } else if (OsmPrimitiveType.WAY.equals(type)) { |
| 453 | | return "way".equals(base) || "area".equals(base); |
| | 469 | return "way".equals(base) || "area".equals(base) || "line".equals(base); |
| 454 | 470 | } else if (OsmPrimitiveType.RELATION.equals(type)) { |
| 455 | 471 | return "area".equals(base) || "relation".equals(base) || "canvas".equals(base); |
| 456 | 472 | } |
| … |
… |
public interface Selector {
|
| 467 | 483 | } else if ("canvas".equals(base)) { |
| 468 | 484 | return p.get("#canvas") != null; |
| 469 | 485 | } |
| | 486 | } else if (p instanceof Way && "area".equals(base)) { |
| | 487 | return isAreaAccordingToMapCSS((Way) p); |
| | 488 | } else if (p instanceof Way && "line".equals(base)) { |
| | 489 | return isLineAccordingToMapCSS((Way) p); |
| 470 | 490 | } |
| 471 | 491 | return true; |
| 472 | 492 | } |