Modify

Opened 10 years ago

Closed 10 years ago

Last modified 10 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 by Aun Johnsen <lists@…>, 10 years ago

Cc: lists@… added

comment:2 by bastiK, 10 years ago

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 by naoliv, 10 years ago

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 by bastiK, 10 years ago

Cc: simon04 added

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

comment:5 by bastiK, 10 years ago

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 by naoliv, 10 years ago

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 10 years ago by naoliv (previous) (diff)

comment:7 by bastiK, 10 years ago

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 by Don-vip, 10 years ago

Milestone: 14.09

comment:9 by anonymous, 10 years ago

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 by bastiK, 10 years ago

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

in reply to:  9 comment:11 by skyper, 10 years ago

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 by aceman, 10 years ago

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 by bastiK, 10 years ago

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.