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

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

update to JOSM 18173

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