pR cleanup
This commit is contained in:
parent
c60b1e3f2c
commit
0de10e76ee
11 changed files with 72 additions and 321 deletions
|
@ -435,7 +435,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
dataObject.setEnName(stringTable.get(dataObject.getEnName(false).charAt(0)));
|
||||
}
|
||||
if(dataObject.getName().length() > 0 && dataObject.getName("en").length() == 0){
|
||||
dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName()));
|
||||
dataObject.setEnName(TransliterationHelper.transliterate(dataObject.getName()));
|
||||
}
|
||||
if(dataObject.getOperator() != null && dataObject.getOperator().length() > 0){
|
||||
dataObject.setOperator(stringTable.get(dataObject.getOperator().charAt(0)));
|
||||
|
@ -547,7 +547,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
case 0:
|
||||
dataObject.setReferencesToRoutes(req.cacheTypes.toArray());
|
||||
if(dataObject.getName("en").length() == 0){
|
||||
dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName()));
|
||||
dataObject.setEnName(TransliterationHelper.transliterate(dataObject.getName()));
|
||||
}
|
||||
return dataObject;
|
||||
case OsmandOdb.TransportStop.ROUTES_FIELD_NUMBER :
|
||||
|
@ -611,7 +611,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
switch (tag) {
|
||||
case 0:
|
||||
if (dataObject.getName("en").length() == 0) {
|
||||
dataObject.setEnName(TransliterationHelper.getInstance().transliterate(dataObject.getName()));
|
||||
dataObject.setEnName(TransliterationHelper.transliterate(dataObject.getName()));
|
||||
}
|
||||
if (x != 0 || y != 0) {
|
||||
dataObject.setLocation(BinaryMapIndexReader.TRANSPORT_STOP_ZOOM, x, y);
|
||||
|
|
|
@ -261,7 +261,7 @@ public class RouteDataObject {
|
|||
}
|
||||
String nmDef = names.get(region.nameTypeRule);
|
||||
if(transliterate && nmDef != null && nmDef.length() > 0) {
|
||||
return TransliterationHelper.getInstance().transliterate(nmDef);
|
||||
return TransliterationHelper.transliterate(nmDef);
|
||||
}
|
||||
return nmDef;
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public class RouteDataObject {
|
|||
}
|
||||
String refDefault = names.get(region.refTypeRule);
|
||||
if(transliterate && refDefault != null && refDefault.length() > 0) {
|
||||
return TransliterationHelper.getInstance().transliterate(refDefault);
|
||||
return TransliterationHelper.transliterate(refDefault);
|
||||
}
|
||||
return refDefault;
|
||||
}
|
||||
|
@ -358,13 +358,13 @@ public class RouteDataObject {
|
|||
int k = kt[i];
|
||||
if(region.routeEncodingRules.size() > k) {
|
||||
if(!Algorithms.isEmpty(lang) && destinationTagLangFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k));
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||
}
|
||||
if(destinationTagFB.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k));
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||
}
|
||||
if(!Algorithms.isEmpty(lang) && destinationTagLang.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(names.get(k)) : names.get(k));
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(names.get(k)) : names.get(k));
|
||||
}
|
||||
if(destinationTagDefault.equals(region.routeEncodingRules.get(k).getTag())) {
|
||||
destinationDefault = names.get(k);
|
||||
|
@ -372,7 +372,7 @@ public class RouteDataObject {
|
|||
}
|
||||
}
|
||||
if(destinationDefault != null) {
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.getInstance().transliterate(destinationDefault) : destinationDefault);
|
||||
return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault);
|
||||
}
|
||||
}
|
||||
return "".equals(destRef) ? null : destRef;
|
||||
|
|
|
@ -28,8 +28,6 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
|
||||
public static final byte WAY_MODULO_REMAINDER = 1;
|
||||
|
||||
private int obfCountryLang = 0;
|
||||
|
||||
|
||||
protected String name = null;
|
||||
protected String enName = null;
|
||||
|
@ -184,8 +182,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
return nm;
|
||||
}
|
||||
if (transliterate) {
|
||||
return TransliterationHelper.getInstance().transliterate(getName());
|
||||
// return Junidecode.unidecode(getName());
|
||||
return TransliterationHelper.transliterate(getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -197,8 +194,7 @@ public abstract class MapObject implements Comparable<MapObject> {
|
|||
if (!Algorithms.isEmpty(enName)) {
|
||||
return this.enName;
|
||||
} else if (!Algorithms.isEmpty(getName()) && transliterate) {
|
||||
return TransliterationHelper.getInstance().transliterate(getName());
|
||||
// return Junidecode.unidecode(getName());
|
||||
return TransliterationHelper.transliterate(getName());
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -39,7 +39,17 @@ public class TransliterationHelper {
|
|||
}
|
||||
|
||||
public static void setCountry(String countryName) {
|
||||
TransliterationHelper.country = countryName;
|
||||
if (!countryName.equals(country)) {
|
||||
switch (countryName) {
|
||||
case "Japan": {
|
||||
country = JAPAN;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
country = DEFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCountry() {
|
||||
|
|
|
@ -416,7 +416,6 @@ dependencies {
|
|||
implementation('com.github.HITGIF:TextFieldBoxes:1.3.5') {
|
||||
exclude group: 'com.android.support'
|
||||
}
|
||||
implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
||||
}
|
||||
if(analytics) {
|
||||
println "Apply GMS plugin"
|
||||
|
|
|
@ -43,7 +43,6 @@ import android.view.inputmethod.InputMethodManager;
|
|||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.lang.Character.UnicodeBlock;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
|
||||
|
@ -526,13 +525,4 @@ public class AndroidUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static boolean checkIfKana(String string) {
|
||||
boolean isKana = false;
|
||||
for (char c : string.toCharArray()) {
|
||||
isKana = UnicodeBlock.of(c) == UnicodeBlock.KATAKANA;
|
||||
}
|
||||
return isKana;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,225 +0,0 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import com.atilika.kuromoji.ipadic.Token;
|
||||
import com.atilika.kuromoji.ipadic.Tokenizer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CustomTransliterationHelper {
|
||||
|
||||
public static String japanese2Romaji(String input) {
|
||||
|
||||
boolean capitalizeWords = true;
|
||||
|
||||
Tokenizer tokenizer = new Tokenizer();
|
||||
List<Token> tokens = tokenizer.tokenize(input);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
KanaToRomaji kanaToRomaji = new KanaToRomaji();
|
||||
String lastTokenToMerge = "";
|
||||
for (Token token : tokens) {
|
||||
String type = token.getAllFeaturesArray()[1];
|
||||
|
||||
if (token.getAllFeaturesArray()[0].equals("記号")) {
|
||||
buffer.append(token.getSurface());
|
||||
continue;
|
||||
}
|
||||
switch (token.getAllFeaturesArray()[1]) {
|
||||
case "数":
|
||||
case "アルファベット":
|
||||
case "サ変接続":
|
||||
buffer.append(token.getSurface());
|
||||
continue;
|
||||
default:
|
||||
String lastFeature = token.getAllFeaturesArray()[8];
|
||||
if (lastFeature.equals("*")) {
|
||||
buffer.append(token.getSurface());
|
||||
} else {
|
||||
String romaji = kanaToRomaji.convert(token.getAllFeaturesArray()[8]);
|
||||
if (lastFeature.endsWith("ッ")) {
|
||||
lastTokenToMerge = lastFeature;
|
||||
continue;
|
||||
} else {
|
||||
lastTokenToMerge = "";
|
||||
}
|
||||
|
||||
if (capitalizeWords) {
|
||||
buffer.append(romaji.substring(0, 1).toUpperCase());
|
||||
buffer.append(romaji.substring(1));
|
||||
} else {
|
||||
// Convert foreign katakana words to uppercase
|
||||
if (token.getSurface()
|
||||
.equals(token.getPronunciation())) // detect katakana
|
||||
{
|
||||
romaji = romaji.toUpperCase();
|
||||
}
|
||||
buffer.append(romaji);
|
||||
}
|
||||
}
|
||||
}
|
||||
buffer.append(" ");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
public static boolean isCharFromCJK(final char c) {
|
||||
return (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HIRAGANA)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.KATAKANA)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS)
|
||||
|| (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(japanese2Romaji("川名本町"));
|
||||
System.out.println(japanese2Romaji("明岸寺"));
|
||||
System.out.println(japanese2Romaji("つきしま"));
|
||||
|
||||
}
|
||||
|
||||
private static class KanaToRomaji {
|
||||
|
||||
Map<String, String> m = new HashMap<String, String>();
|
||||
|
||||
// Constructor
|
||||
public KanaToRomaji() {
|
||||
m.put("ア", "a");
|
||||
m.put("イ", "i");
|
||||
m.put("ウ", "u");
|
||||
m.put("エ", "e");
|
||||
m.put("オ", "o");
|
||||
m.put("カ", "ka");
|
||||
m.put("キ", "ki");
|
||||
m.put("ク", "ku");
|
||||
m.put("ケ", "ke");
|
||||
m.put("コ", "ko");
|
||||
m.put("サ", "sa");
|
||||
m.put("シ", "shi");
|
||||
m.put("ス", "su");
|
||||
m.put("セ", "se");
|
||||
m.put("ソ", "so");
|
||||
m.put("タ", "ta");
|
||||
m.put("チ", "chi");
|
||||
m.put("ツ", "tsu");
|
||||
m.put("テ", "te");
|
||||
m.put("ト", "to");
|
||||
m.put("ナ", "na");
|
||||
m.put("ニ", "ni");
|
||||
m.put("ヌ", "nu");
|
||||
m.put("ネ", "ne");
|
||||
m.put("ノ", "no");
|
||||
m.put("ハ", "ha");
|
||||
m.put("ヒ", "hi");
|
||||
m.put("フ", "fu");
|
||||
m.put("ヘ", "he");
|
||||
m.put("ホ", "ho");
|
||||
m.put("マ", "ma");
|
||||
m.put("ミ", "mi");
|
||||
m.put("ム", "mu");
|
||||
m.put("メ", "me");
|
||||
m.put("モ", "mo");
|
||||
m.put("ヤ", "ya");
|
||||
m.put("ユ", "yu");
|
||||
m.put("ヨ", "yo");
|
||||
m.put("ラ", "ra");
|
||||
m.put("リ", "ri");
|
||||
m.put("ル", "ru");
|
||||
m.put("レ", "re");
|
||||
m.put("ロ", "ro");
|
||||
m.put("ワ", "wa");
|
||||
m.put("ヲ", "wo");
|
||||
m.put("ン", "n");
|
||||
m.put("ガ", "ga");
|
||||
m.put("ギ", "gi");
|
||||
m.put("グ", "gu");
|
||||
m.put("ゲ", "ge");
|
||||
m.put("ゴ", "go");
|
||||
m.put("ザ", "za");
|
||||
m.put("ジ", "ji");
|
||||
m.put("ズ", "zu");
|
||||
m.put("ゼ", "ze");
|
||||
m.put("ゾ", "zo");
|
||||
m.put("ダ", "da");
|
||||
m.put("ヂ", "ji");
|
||||
m.put("ヅ", "zu");
|
||||
m.put("デ", "de");
|
||||
m.put("ド", "do");
|
||||
m.put("バ", "ba");
|
||||
m.put("ビ", "bi");
|
||||
m.put("ブ", "bu");
|
||||
m.put("ベ", "be");
|
||||
m.put("ボ", "bo");
|
||||
m.put("パ", "pa");
|
||||
m.put("ピ", "pi");
|
||||
m.put("プ", "pu");
|
||||
m.put("ペ", "pe");
|
||||
m.put("ポ", "po");
|
||||
m.put("キャ", "kya");
|
||||
m.put("キュ", "kyu");
|
||||
m.put("キョ", "kyo");
|
||||
m.put("シャ", "sha");
|
||||
m.put("シュ", "shu");
|
||||
m.put("ショ", "sho");
|
||||
m.put("チャ", "cha");
|
||||
m.put("チュ", "chu");
|
||||
m.put("チョ", "cho");
|
||||
m.put("ニャ", "nya");
|
||||
m.put("ニュ", "nyu");
|
||||
m.put("ニョ", "nyo");
|
||||
m.put("ヒャ", "hya");
|
||||
m.put("ヒュ", "hyu");
|
||||
m.put("ヒョ", "hyo");
|
||||
m.put("リャ", "rya");
|
||||
m.put("リュ", "ryu");
|
||||
m.put("リョ", "ryo");
|
||||
m.put("ギャ", "gya");
|
||||
m.put("ギュ", "gyu");
|
||||
m.put("ギョ", "gyo");
|
||||
m.put("ジャ", "ja");
|
||||
m.put("ジュ", "ju");
|
||||
m.put("ジョ", "jo");
|
||||
m.put("ティ", "ti");
|
||||
m.put("ディ", "di");
|
||||
m.put("ツィ", "tsi");
|
||||
m.put("ヂャ", "dya");
|
||||
m.put("ヂュ", "dyu");
|
||||
m.put("ヂョ", "dyo");
|
||||
m.put("ビャ", "bya");
|
||||
m.put("ビュ", "byu");
|
||||
m.put("ビョ", "byo");
|
||||
m.put("ピャ", "pya");
|
||||
m.put("ピュ", "pyu");
|
||||
m.put("ピョ", "pyo");
|
||||
m.put("ー", "-");
|
||||
}
|
||||
|
||||
public String convert(String s) {
|
||||
StringBuilder t = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i <= s.length() - 2) {
|
||||
if (m.containsKey(s.substring(i, i + 2))) {
|
||||
t.append(m.get(s.substring(i, i + 2)));
|
||||
i++;
|
||||
} else if (m.containsKey(s.substring(i, i + 1))) {
|
||||
t.append(m.get(s.substring(i, i + 1)));
|
||||
} else if (s.charAt(i) == 'ッ') {
|
||||
t.append(m.get(s.substring(i + 1, i + 2)).charAt(0));
|
||||
} else {
|
||||
t.append(s.charAt(i));
|
||||
}
|
||||
} else {
|
||||
if (m.containsKey(s.substring(i, i + 1))) {
|
||||
t.append(m.get(s.substring(i, i + 1)));
|
||||
} else {
|
||||
t.append(s.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return t.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -137,7 +137,7 @@ public class NominatimPoiFilter extends PoiUIFilter {
|
|||
a.setId(Long.parseLong(parser.getAttributeValue("", "place_id"))); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String name = parser.getAttributeValue("", "display_name"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
a.setName(name);
|
||||
a.setEnName(TransliterationHelper.getInstance().transliterate(getName()));
|
||||
a.setEnName(TransliterationHelper.transliterate(getName()));
|
||||
a.setSubType(parser.getAttributeValue("", "type")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
PoiType pt = poiTypes.getPoiTypeByKey(a.getSubType());
|
||||
a.setType(pt != null ? pt.getCategory() : poiTypes.getOtherPoiCategory());
|
||||
|
@ -153,7 +153,7 @@ public class NominatimPoiFilter extends PoiUIFilter {
|
|||
String name = parser.getText();
|
||||
if (name != null) {
|
||||
a.setName(name);
|
||||
a.setEnName(TransliterationHelper.getInstance().transliterate(getName()));
|
||||
a.setEnName(TransliterationHelper.transliterate(getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,8 +308,8 @@ public class MapRenderRepositories {
|
|||
BinaryMapIndexReader fr = files.get(mapName);
|
||||
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
|
||||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
|
||||
if(!Algorithms.isEmpty(fr.getCountryName())) {
|
||||
setCountryForTransliterationMethod(fr.getCountryName());
|
||||
if (!Algorithms.isEmpty(fr.getCountryName())) {
|
||||
TransliterationHelper.setCountry(fr.getCountryName());
|
||||
}
|
||||
if (!nativeFiles.contains(mapName)) {
|
||||
long time = System.currentTimeMillis();
|
||||
|
@ -546,9 +546,8 @@ public class MapRenderRepositories {
|
|||
res = new ArrayList<BinaryMapDataObject>();
|
||||
log.debug("Search failed " + c.getRegionNames(), e); //$NON-NLS-1$
|
||||
}
|
||||
if(res.size() > 0) {
|
||||
log.debug("Country name:" + c.getCountryName());
|
||||
setCountryForTransliterationMethod(c.getCountryName());
|
||||
if (res.size() > 0) {
|
||||
TransliterationHelper.setCountry(c.getCountryName());
|
||||
if(basemap) {
|
||||
renderedState |= 1;
|
||||
} else {
|
||||
|
@ -596,20 +595,6 @@ public class MapRenderRepositories {
|
|||
return mi;
|
||||
}
|
||||
|
||||
private void setCountryForTransliterationMethod(String countryName) {
|
||||
if(!countryName.equals(TransliterationHelper.getCountry())) {
|
||||
switch (countryName) {
|
||||
case "Japan": {
|
||||
setCountry(countryName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
setCountry(TransliterationHelper.DEFAULT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLatLonBox(QuadRect box) {
|
||||
if (box.top > 90) {
|
||||
box.top = 85.5f;
|
||||
|
|
|
@ -241,11 +241,9 @@ public class TextRenderer {
|
|||
TextDrawInfo text = rc.textToDraw.get(i);
|
||||
if (text.text != null && text.text.length() > 0) {
|
||||
if (preferredLocale.length() > 0) {
|
||||
text.text = TransliterationHelper.getInstance().transliterate(text.text);
|
||||
text.text = TransliterationHelper.transliterate(text.text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sest text size before finding intersection (it is used there)
|
||||
float textSize = text.textSize * rc.textScale ;
|
||||
paintText.setTextSize(textSize);
|
||||
|
|
|
@ -45,11 +45,9 @@ public class AsyncLoadingThread extends Thread {
|
|||
if (req instanceof TileLoadDownloadRequest) {
|
||||
TileLoadDownloadRequest r = (TileLoadDownloadRequest) req;
|
||||
tileLoaded |= resourceManger.hasRequestedTile(r);
|
||||
|
||||
} else if (req instanceof MapLoadRequest) {
|
||||
if (!mapLoaded) {
|
||||
MapLoadRequest r = (MapLoadRequest) req;
|
||||
|
||||
resourceManger.getRenderer().loadMap(r.tileBox, resourceManger.getMapTileDownloader());
|
||||
mapLoaded = !resourceManger.getRenderer().wasInterrupted();
|
||||
if (r.mapLoadedListener != null) {
|
||||
|
|
Loading…
Reference in a new issue