- Timestamp:
- 2021-04-19T21:45:13+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r17800 r17801 26 26 import org.openstreetmap.josm.data.osm.IRelationMember; 27 27 import org.openstreetmap.josm.data.osm.IWay; 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 29 30 import org.openstreetmap.josm.data.osm.OsmUtils; … … 208 209 } 209 210 210 private <T extends IPrimitive> void doVisit(T parent, IntSupplier counter, IntFunction<IPrimitive> getter) {211 private void doVisit(IPrimitive parent) { 211 212 // If e.parent is already set to the first matching referrer. 212 213 // We skip any following referrer injected into the visitor. … … 215 216 if (!left.matches(e.withPrimitive(parent))) 216 217 return; 217 int count = counter.getAsInt(); 218 int count = parent instanceof IWay<?> 219 ? ((IWay<?>) parent).getNodesCount() 220 : ((IRelation<?>) parent).getMembersCount(); 218 221 if (link.getConditions().isEmpty()) { 219 222 // index is not needed, we can avoid the sequential search below … … 225 228 int step = firstAndLastOnly() ? count - 1 : 1; 226 229 for (int i = 0; i < count; i += step) { 227 if (getter.apply(i).equals(e.osm) 230 IPrimitive o = parent instanceof IWay<?> 231 ? ((IWay<?>) parent).getNode(i) 232 : ((IRelation<?>) parent).getMember(i).getMember(); 233 if (Objects.equals(o, e.osm) 228 234 && link.matches(e.withParentAndIndexAndLinkContext(parent, i, count))) { 229 235 e.parent = parent; … … 241 247 @Override 242 248 public void visit(IWay<?> w) { 243 doVisit(w , w::getNodesCount, w::getNode);249 doVisit(w); 244 250 } 245 251 246 252 @Override 247 253 public void visit(IRelation<?> r) { 248 doVisit(r , r::getMembersCount, i -> r.getMember(i).getMember());254 doVisit(r); 249 255 } 250 256 }
Note:
See TracChangeset
for help on using the changeset viewer.