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

Last change on this file since 26832 was 26802, checked in by zverik, 13 years ago

"mischief managed"

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