File tree Expand file tree Collapse file tree 3 files changed +75
-2
lines changed
main/java/com/protomaps/basemap
test/java/com/protomaps/basemap/names Expand file tree Collapse file tree 3 files changed +75
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public String description() {
101
101
102
102
@ Override
103
103
public String version () {
104
- return "3.7.1 " ;
104
+ return "4.0.0-alpha.0 " ;
105
105
}
106
106
107
107
@ Override
Original file line number Diff line number Diff line change 6
6
import com .protomaps .basemap .text .TextEngine ;
7
7
import java .text .NumberFormat ;
8
8
import java .text .ParsePosition ;
9
+ import java .util .HashSet ;
9
10
import java .util .Map ;
11
+ import java .util .Set ;
12
+ import java .util .stream .Stream ;
10
13
11
14
public class OsmNames {
12
15
13
16
private OsmNames () {}
14
17
18
+ private static final String [] ALLOWED_LANGS = new String []{
19
+ "ar" , // Arabic
20
+ "cs" , // Czech
21
+ "bg" , // Bulgarian
22
+ "da" , // Danish
23
+ "de" , // German
24
+ "el" , // Greek
25
+ "en" , // English
26
+ "es" , // Spanish
27
+ "et" , // Estonian
28
+ "fa" , // Persian
29
+ "fi" , // Finnish
30
+ "fr" , // French
31
+ "ga" , // Irish
32
+ "he" , // Hebrew
33
+ "hi" , // Hindi
34
+ "hr" , // Croatian
35
+ "hu" , // Hungarian
36
+ "id" , // Indonesian
37
+ "it" , // Italian
38
+ "ja" , // Japanese
39
+ "ko" , // Korean
40
+ "lt" , // Lithuanian
41
+ "lv" , // Latvian
42
+ "ne" , // Nepali
43
+ "nl" , // Dutch
44
+ "no" , // Norwegian
45
+ "mr" , // Marathi
46
+ "mt" , // Maltese
47
+ "pl" , // Polish
48
+ "pt" , // Portuguese
49
+ "ro" , // Romanian
50
+ "ru" , // Russian
51
+ "sk" , // Slovak
52
+ "sl" , // Slovenian
53
+ "sv" , // Swedish
54
+ "tr" , // Turkish
55
+ "uk" , // Ukrainian
56
+ "ur" , // Urdu
57
+ "vi" , // Vietnamese
58
+ "zh" , // Chinese (General)
59
+ "zh-Hans" , // Chinese (Simplified)
60
+ "zh-Hant" // Chinese (Traditional)
61
+ };
62
+
63
+ private static final Set <String > ALLOWED_LANG_SET =
64
+ new HashSet <>(Stream .of (ALLOWED_LANGS ).map (s -> "name:" + s ).toList ());
65
+
66
+ public static boolean isAllowed (String osmKey ) {
67
+ return ALLOWED_LANG_SET .contains (osmKey );
68
+ }
69
+
15
70
public static FeatureCollector .Feature setOsmNames (FeatureCollector .Feature feature , SourceFeature sf ,
16
71
int minZoom ) {
17
72
FontRegistry fontRegistry = FontRegistry .getInstance ();
@@ -31,7 +86,7 @@ public static FeatureCollector.Feature setOsmNames(FeatureCollector.Feature feat
31
86
feature .setAttrWithMinzoom ("pmap:pgf:name" , encodedValue , minZoom );
32
87
}
33
88
34
- if (key . startsWith ( "name:" )) {
89
+ if (isAllowed ( key )) {
35
90
feature .setAttrWithMinzoom (key , value , minZoom );
36
91
37
92
if (fontRegistry .getScripts ().contains (script )) {
Original file line number Diff line number Diff line change
1
+ package com .protomaps .basemap .names ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
4
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
5
+
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ class OsmNamesTest {
9
+ @ Test
10
+ void checkNames () {
11
+ assertTrue (OsmNames .isAllowed ("name:en" ));
12
+ assertTrue (OsmNames .isAllowed ("name:nl" ));
13
+ assertTrue (OsmNames .isAllowed ("name:zh" ));
14
+ assertTrue (OsmNames .isAllowed ("name:zh-Hans" ));
15
+ assertTrue (OsmNames .isAllowed ("name:zh-Hant" ));
16
+ assertFalse (OsmNames .isAllowed ("name:dk" ));
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments