1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package relcontext;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.data.osm.INode;
|
---|
5 | import org.openstreetmap.josm.data.osm.IRelation;
|
---|
6 | import org.openstreetmap.josm.data.osm.IWay;
|
---|
7 | import 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 | */
|
---|
14 | public 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 | }
|
---|