Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10471 closed enhancement (fixed)

AND operator in MapCSS

Reported by: naoliv Owned by: team
Priority: normal Milestone: 14.09
Component: Core validator Version:
Keywords: mapcss Cc: lists@…, simon04

Description

Could we have some kind of AND operator in MapCSS?
We are trying to implement a test for ford=yes that is not tagged on a highway + waterway junction.

We have tried way[highway] > node[ford=yes] and way[waterway] > node[ford=yes] and a more complicated solution like

node[ford?] { set: .ford_not_on_waterway; set: .ford_not_on_highway; }
way[waterway] > node[ford?] { unset: .ford_not_on_waterway; }
way[highway] > node[ford?] { unset: .ford_not_on_highway; }
node.ford_not_on_waterway, node.ford_not_on_highway {
throwWarning: tr("ford should be on the node where highway and waterway intersect");
}

but without success.
Is there any way to implement an AND?

JOSM:

Repository Root: http://josm.openstreetmap.de/svn
Build-Date: 2014-09-02 01:36:00
Last Changed Author: Don-vip
Revision: 7485
Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
URL: http://josm.openstreetmap.de/svn/trunk
Last Changed Date: 2014-09-02 02:57:38 +0200 (Tue, 02 Sep 2014)
Last Changed Rev: 7485

Attachments (0)

Change History (13)

comment:1 Changed 5 years ago by Aun Johnsen <lists@…>

Cc: lists@… added

comment:2 Changed 5 years ago by bastiK

There is no colon after set and there is no unset command. Try this:

node[ford?] { set .ford_not_on_waterway; set .ford_not_on_highway; }
way[waterway] > node[ford?] { ford_not_on_waterway: none; }
way[highway] > node[ford?] { ford_not_on_highway: none; }
node.ford_not_on_waterway, node.ford_not_on_highway {
   throwWarning: tr("ford should be on the node where highway and waterway intersect");
}

(Look for errors on the console or make a mapstyle for for testing first and read the errors in the style dialog.)

comment:3 Changed 5 years ago by naoliv

With your code it gives:

ERROR: Cannot add MapCss rule: Cannot add instruction ford_not_on_waterway: null!
ERROR: Cannot add MapCss rule: Cannot add instruction ford_not_on_highway: null!

comment:4 Changed 5 years ago by bastiK

Cc: simon04 added

@Simon: Any idea why this doesn't work?

comment:5 Changed 5 years ago by bastiK

How about this?

way[waterway] > node[ford?] { set ford_on_waterway; }
way[highway] > node[ford?] { set ford_on_highway; }
node[ford?]!.ford_on_waterway, node[ford?]!.ford_on_highway {
    throwWarning: tr("ford should be on the node where highway and waterway intersect");
}

comment:6 Changed 5 years ago by naoliv

Now it's good!
And since we are here, is it interesting to incorporate this test in JOSM?

This test validates http://wiki.openstreetmap.org/wiki/Ford#Used_on_a_node

Last edited 5 years ago by naoliv (previous) (diff)

comment:7 Changed 5 years ago by bastiK

Resolution: fixed
Status: newclosed

In 7488/josm:

applied #10471 - new validator rule to check that ford=yes node is on highway and waterway (based on patch by naoliv)

comment:8 Changed 5 years ago by Don-vip

Milestone: 14.09

comment:9 Changed 5 years ago by anonymous

Does this cover cases where the ford isn't on the waterway way (in the ~middle of the river), but on some partial segment of the surrounding water area (either marked waterway=riverbank or water=*) ?
Also, what about ford=yes on a way instead of node?

It looks like this would show a warning that is incorrect.

But I like the idea of the test.

comment:10 Changed 5 years ago by bastiK

Please try lastest version and report anything that is not working as expected.

comment:11 in reply to:  9 Changed 5 years ago by skyper

Replying to anonymous:

Does this cover cases where the ford isn't on the waterway way (in the ~middle of the river), but on some partial segment of the surrounding water area (either marked waterway=riverbank or water=*) ?
Also, what about ford=yes on a way instead of node?

Thought new tagging is using ways instead of nodes like tunnel=* and bridge=*. Also need a test for ways and have to consider it on all both test as tagged twice (node + way) is an error.

It looks like this would show a warning that is incorrect.

But I like the idea of the test.

+1

comment:12 Changed 5 years ago by aceman

I had this in mind: https://www.openstreetmap.org/way/199709633 . I get no warning there, which is correct, but only because the test works only on nodes? So if the test gets extended to ways there should still be no warning because the ford way is over a water area.

comment:13 Changed 5 years ago by bastiK

Yes, it works only on nodes at the moment. Please provide a patch if you want it extended. (Or clearly describe what the check should validate at least.)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.