source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java@ 35829

Last change on this file since 35829 was 35829, checked in by Don-vip, 3 years ago

update to JOSM 18173

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package relcontext;
3
4import org.openstreetmap.josm.data.osm.INode;
5import org.openstreetmap.josm.data.osm.IRelation;
6import org.openstreetmap.josm.data.osm.IWay;
7import org.openstreetmap.josm.data.osm.NameFormatterHook;
8
9/**
10 * Formatter hook for some tags that Dirk does not want to support.
11 *
12 * @author Zverik
13 */
14public class ExtraNameFormatHook implements NameFormatterHook {
15
16 @Override
17 public String checkRelationTypeName(IRelation<?> relation, String defaultName) {
18 return null;
19 }
20
21 @Override
22 public String checkFormat(INode node, String defaultName) {
23 return null;
24 }
25
26 @Override
27 public String checkFormat(IWay<?> way, String defaultName) {
28 if (way.get("place") != null && way.get("name") == null && way.get("place_name") != null)
29 return way.get("place_name") + " " + defaultName;
30 return null;
31 }
32
33 @Override
34 public String checkFormat(IRelation<?> relation, String defaultName) {
35 String type = relation.get("type");
36 if (type != null) {
37 String name = relation.get("destination");
38 if (type.equals("destination_sign") && name != null) {
39 if (relation.get("distance") != null) {
40 name += " " + relation.get("distance");
41 }
42 if (defaultName.indexOf('"') < 0)
43 return '"' + name + "\" " + defaultName;
44 else
45 return defaultName.replaceFirst("\".?+\"", '"'+name+'"');
46 }
47 }
48 return null;
49 }
50}
Note: See TracBrowser for help on using the repository browser.