source: josm/trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java@ 2683

Last change on this file since 2683 was 2683, checked in by mjulius, 14 years ago

fixes #4149 - exception when undoing reversal of way with tag corrections

don't try to undo Command for a primitive that does not belong to a dataset

fixes issue with ChangeRelationMemberRoleCommand.undoCommand() doing nothing except resetting modified flag
don't reverse tags on way nodes when reversing way
reversing way now also reverses 'incline=*' tags

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.Locale;
7
8public class OsmUtils {
9
10 static ArrayList<String> TRUE_VALUES = new ArrayList<String>(Arrays
11 .asList(new String[] { "true", "yes", "1", "on" }));
12 static ArrayList<String> FALSE_VALUES = new ArrayList<String>(Arrays
13 .asList(new String[] { "false", "no", "0", "off" }));
14 static ArrayList<String> REVERSE_VALUES = new ArrayList<String>(Arrays
15 .asList(new String[] { "reverse", "-1" }));
16
17 public static final String trueval = "yes";
18 public static final String falseval = "no";
19 public static final String reverseval = "-1";
20
21 public static Boolean getOsmBoolean(String value) {
22 if(value == null) return null;
23 String lowerValue = value.toLowerCase(Locale.ENGLISH);
24 if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE;
25 if (FALSE_VALUES.contains(lowerValue)) return Boolean.FALSE;
26 return null;
27 }
28
29 public static String getNamedOsmBoolean(String value) {
30 Boolean res = getOsmBoolean(value);
31 return res == null ? value : (res ? trueval : falseval);
32 }
33
34 public static boolean isReversed(String value) {
35 return REVERSE_VALUES.contains(value);
36 }
37
38 public static boolean isTrue(String value) {
39 return TRUE_VALUES.contains(value);
40 }
41
42 public static boolean isFalse(String value) {
43 return FALSE_VALUES.contains(value);
44 }
45}
Note: See TracBrowser for help on using the repository browser.