NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

At this moment

AND NOT @isOneOf(highway, trunk, trunk_link, primary, primary_link, secondary, tertiary, pedestrian, residential, living_street, unclassified)

is used three times in my feature definition code, and I really want to replace it by reusable definition/variable/function. Is it possible?

asked 23 Sep '13, 12:29

Bulwersator's gravatar image

Bulwersator
468121625
accept rate: 14%

edited 23 Sep '13, 12:33


For now I use C preprocessor - I have a separate file called expand.c. I run gcc -E expand.c > test.txt, add two tabs at start of every line and copy it to file with rules.

My expand.c file looks like this:

/*
use
gcc -E expand.c > test.txt
to expand macros. Run regexp "^" to add tabs, than replace part of Biking.mrules
this hack is hilarious ugly, but better than editing expanded form of this stuff
*/

#define __cycleable (highway=cycleway OR cycleway=lane OR bicycle = yes OR bicycle = designated OR cycleway=opposite_lane)
#define __typical_road @isOneOf(highway, trunk, trunk_link, primary, primary_link, secondary, tertiary, pedestrian, residential, living_street, unclassified)
#define __no_surface_for_lane ((cycleway=lane OR segregated = yes) AND NOT cycleway:right = surface* AND NOT cycleway:left = surface*)
#define __paved_surface_for_lane ((cycleway=lane OR segregated = yes) AND (cycleway:right = "surface=paved" OR cycleway:left = "surface=paved"))
#define __separate_cycleway (highway=cycleway AND NOT segregated = no AND NOT foot = yes AND NOT foot = designated)
#define __segregated_cycleway ((highway=cycleway AND segregated = yes) OR (bicycle=designated AND segregated = yes) OR (cycleway = lane))
#define __proper_surface (surface = asphalt OR smoothness = excellent OR cycleway:right = "surface=asphalt" OR cycleway:left = "surface=asphalt")
#define __cycleway __separate_cycleway OR __segregated_cycleway

no_and_yes_bug : __cycleable AND bicycle=no
crossing_as_way_rather_than_node_bug : highway = crossing
no oneway for bicycle instead of opposite_lane : "oneway:bicycle" = "no" AND NOT cycleway=opposite_lane
no_surface_info : __cycleable AND (__no_surface_for_lane OR __paved_surface_for_lane OR (surface=paved OR (NOT (surface) AND NOT (tracktype)))) AND (NOT bicycle = yes OR NOT __typical_road)

proper cycleway : __cycleway AND __proper_surface
proper cycleway maybe with a bad surface : __cycleway
lame cycleway : ((bicycle=designated OR (highway=cycleway AND bicycle = yes)) AND NOT segregated = yes)
contraflow : cycleway=opposite_lane
bicycle allowed : (bicycle=yes) AND NOT __typical_road
dismount from bicycle : bicycle=dismount
unexpected cycling ban : bicycle=no //AND __typical_road
permanent link

answered 23 Sep '13, 15:23

Bulwersator's gravatar image

Bulwersator
468121625
accept rate: 14%

edited 23 Sep '13, 15:31

Alternatively you could use filepp which works as a pre-processor for regular text files.

(23 Sep '13, 18:00) scai ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×48

question asked: 23 Sep '13, 12:29

question was seen: 2,346 times

last updated: 23 Sep '13, 18:03

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum