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

4
1

I am working on a preset to apply to fuel stations. I want to use check boxes to enter data values for certain keys, for example,

<check key="fuel:gasoline_95" text="Gas 95" default="off" delete_if_empty="true"  />

What I would like is for the tag value to be set to "no" if the check box is unchecked and "yes" if the check box is checked. I tried removing the delete_if_empty="true" phrase but it had no effect at all. Neither did changing "true" to "false". The only behavior I observe is that the key doesn't appear if the box is left unchecked.

Is there a way to do this? Thanks....

asked 24 Oct '14, 03:10

AlaskaDave's gravatar image

AlaskaDave
5.4k76107164
accept rate: 16%

edited 24 Oct '14, 13:23

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


You need to change it as follows :

<check key="fuel:gasoline_95" text="Gas 95" default="off" value_on="yes" value_off="no"/>

The problem might be that you are not using the value_on and value_off. You can see the supported directives in the default preset file that comes along with JOSM. The default preset xml file is available at : http://josm.openstreetmap.de/svn/trunk/data/defaultpresets.xml Alternatively you can extract the defaultpresets.xml from the data folder in the JOSM JAR file.

I have written a Linux shell script to create the JOSM presets from text files a while back. You can find it here : https://github.com/primejyothi/JOSMPresetBuilder

Hope this helps.

permanent link

answered 26 Oct '14, 06:28

primej's gravatar image

primej
10614
accept rate: 100%

edited 26 Oct '14, 06:48

1

Yes, that works almost perfectly. I say that because in testing my new preset, I learned that there are not two states for a checkbox but three. Checked, unchecked and, for lack of a better term, cleared. When the preset is first called all boxes are a light blue color. If I clear the checkbox by clicking on it until the blue color changes to white, the resultant tag will be set to "no". If I tick it, the tag will be "yes", as expected. If I do nothing, that is I do not tick it and I do not clear it, the tag does not get applied to the selection at all.

(26 Oct '14, 07:37) AlaskaDave
1

To continue:

Cycling through the clicks on a first call of the preset, the first click turns the check mark on and sets the tag to "yes", the next click clears the check mark and sets the tag to "no, the next resets the blue color to the box and causes the tag to not appear at all.

At any rate, thanks for the great answer. I have adjusted my presets and they are working MUCH better than before. I have your preset builder already but haven't fooled with it enough to know if it will help me or hinder me as yet <g>

(26 Oct '14, 07:38) AlaskaDave

@AlaskaDave, you are welcome, glad that I could help you. Your comments made me curious and looked through the defaultpresets.xml and found that the option disable_off for check box controls whether the tag to be present or not. If you set disable_off to true, the tag will not show up when it is unset. Setting it to true will cause to go through the cycles you mentioned in your first comment.

(26 Oct '14, 07:58) primej

Actually, it seems that adding disable_off to the control prevents setting the tag to "no". You can either set it to "yes" or if you leave it unset, the tag doesn't get applied. Unless I'm not understanding you perfectly.

I like the ability to have a tag set to "no", e.g. , when there is no diesel fuel at a particular station. Before I could either set fuel:diesel to "yes" or say nothing about diesel at all. Thanks to your original answer, I can have it three ways.

Please strike the word "almost" from my first comment above. <g>

(26 Oct '14, 08:22) AlaskaDave

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:

×622
×11
×1

question asked: 24 Oct '14, 03:10

question was seen: 3,824 times

last updated: 26 Oct '14, 08:22

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