pR fixes 3
This commit is contained in:
parent
4bdbc170c9
commit
a3d66bedd7
6 changed files with 37 additions and 36 deletions
|
@ -152,7 +152,7 @@ public class BinaryMapAddressReaderAdapter {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 0:
|
case 0:
|
||||||
if (region.enName == null || region.enName.length() == 0) {
|
if (region.enName == null || region.enName.length() == 0) {
|
||||||
region.enName = region.name == null ? "" : TransliterationHelper.getInstance().transliterate(region.name);
|
region.enName = region.name == null ? "" : TransliterationHelper.transliterate(region.name);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case OsmandOdb.OsmAndAddressIndex.NAME_FIELD_NUMBER:
|
case OsmandOdb.OsmAndAddressIndex.NAME_FIELD_NUMBER:
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package net.osmand.util;
|
package net.osmand.util;
|
||||||
|
|
||||||
import com.atilika.kuromoji.ipadic.Token;
|
|
||||||
import com.atilika.kuromoji.ipadic.Tokenizer;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.atilika.kuromoji.ipadic.Token;
|
||||||
|
import com.atilika.kuromoji.ipadic.Tokenizer;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.sf.junidecode.Junidecode;
|
import net.sf.junidecode.Junidecode;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -17,7 +19,7 @@ public class TransliterationHelper {
|
||||||
public final static String DEFAULT = "default";
|
public final static String DEFAULT = "default";
|
||||||
public final static String JAPAN = "Japan";
|
public final static String JAPAN = "Japan";
|
||||||
|
|
||||||
private static String country = DEFAULT;
|
private static String countryName = DEFAULT;
|
||||||
|
|
||||||
private static Tokenizer tokenizer;
|
private static Tokenizer tokenizer;
|
||||||
|
|
||||||
|
@ -26,41 +28,26 @@ public class TransliterationHelper {
|
||||||
private TransliterationHelper() {
|
private TransliterationHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
public static void setCountryName(String countryName) {
|
||||||
try {
|
if (!countryName.equals(TransliterationHelper.countryName)) {
|
||||||
instance = new TransliterationHelper();
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.debug(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TransliterationHelper getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCountry(String countryName) {
|
|
||||||
if (!countryName.equals(country)) {
|
|
||||||
switch (countryName) {
|
switch (countryName) {
|
||||||
case "Japan": {
|
case "Japan": {
|
||||||
country = JAPAN;
|
TransliterationHelper.countryName = JAPAN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
country = DEFAULT;
|
TransliterationHelper.countryName = DEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCountry() {
|
public static String getCountryName() {
|
||||||
return country;
|
return countryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String transliterate(String text) {
|
public static String transliterate(String text) {
|
||||||
if (tokenizer == null) {
|
switch (countryName) {
|
||||||
tokenizer = new Tokenizer();
|
|
||||||
}
|
|
||||||
switch (country) {
|
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
return Junidecode.unidecode(text);
|
return Junidecode.unidecode(text);
|
||||||
case JAPAN:
|
case JAPAN:
|
||||||
|
@ -71,6 +58,10 @@ public class TransliterationHelper {
|
||||||
|
|
||||||
private static String japanese2Romaji(String text) {
|
private static String japanese2Romaji(String text) {
|
||||||
|
|
||||||
|
if (tokenizer == null) {
|
||||||
|
tokenizer = new Tokenizer();
|
||||||
|
}
|
||||||
|
|
||||||
boolean capitalizeWords = true;
|
boolean capitalizeWords = true;
|
||||||
|
|
||||||
List<Token> tokens = tokenizer.tokenize(text);
|
List<Token> tokens = tokenizer.tokenize(text);
|
||||||
|
|
|
@ -66,6 +66,12 @@ android {
|
||||||
warningsAsErrors false
|
warningsAsErrors false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude '/META-INF/CONTRIBUTORS.md'
|
||||||
|
exclude '/META-INF/LICENSE.md'
|
||||||
|
exclude '/META-INF/NOTICE.md'
|
||||||
|
}
|
||||||
|
|
||||||
// This is from OsmAndCore_android.aar - for some reason it's not inherited
|
// This is from OsmAndCore_android.aar - for some reason it's not inherited
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
// Don't compress any embedded resources
|
// Don't compress any embedded resources
|
||||||
|
@ -391,7 +397,7 @@ dependencies {
|
||||||
implementation 'com.moparisthebest:junidecode:0.1.1'
|
implementation 'com.moparisthebest:junidecode:0.1.1'
|
||||||
implementation 'org.immutables:gson:2.5.0'
|
implementation 'org.immutables:gson:2.5.0'
|
||||||
implementation 'com.vividsolutions:jts-core:1.14.0'
|
implementation 'com.vividsolutions:jts-core:1.14.0'
|
||||||
|
implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
// JS core
|
// JS core
|
||||||
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
|
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'
|
||||||
|
|
|
@ -524,5 +524,4 @@ public class AndroidUtils {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.osmand.plus.render;
|
package net.osmand.plus.render;
|
||||||
|
|
||||||
|
|
||||||
import static net.osmand.util.TransliterationHelper.setCountry;
|
import static net.osmand.util.TransliterationHelper.setCountryName;
|
||||||
|
|
||||||
import gnu.trove.iterator.TIntObjectIterator;
|
import gnu.trove.iterator.TIntObjectIterator;
|
||||||
import gnu.trove.list.TLongList;
|
import gnu.trove.list.TLongList;
|
||||||
|
@ -303,14 +303,12 @@ public class MapRenderRepositories {
|
||||||
if(library == null) {
|
if(library == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String countryInView = "";
|
||||||
boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get();
|
boolean useLive = context.getSettings().USE_OSM_LIVE_FOR_ROUTING.get();
|
||||||
for (String mapName : files.keySet()) {
|
for (String mapName : files.keySet()) {
|
||||||
BinaryMapIndexReader fr = files.get(mapName);
|
BinaryMapIndexReader fr = files.get(mapName);
|
||||||
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
|
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
|
||||||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
|
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
|
||||||
if (!Algorithms.isEmpty(fr.getCountryName())) {
|
|
||||||
TransliterationHelper.setCountry(fr.getCountryName());
|
|
||||||
}
|
|
||||||
if (!nativeFiles.contains(mapName)) {
|
if (!nativeFiles.contains(mapName)) {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
nativeFiles.add(mapName);
|
nativeFiles.add(mapName);
|
||||||
|
@ -319,8 +317,13 @@ public class MapRenderRepositories {
|
||||||
}
|
}
|
||||||
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
if (fr.getCountryName().equals("Japan")) {
|
||||||
|
countryInView = fr.getCountryName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setCountryName(countryInView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c,
|
private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c,
|
||||||
|
@ -536,6 +539,7 @@ public class MapRenderRepositories {
|
||||||
}
|
}
|
||||||
MapIndex mi = null;
|
MapIndex mi = null;
|
||||||
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
|
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
|
||||||
|
String countryInView = "";
|
||||||
for (BinaryMapIndexReader c : files.values()) {
|
for (BinaryMapIndexReader c : files.values()) {
|
||||||
boolean basemap = c.isBasemap();
|
boolean basemap = c.isBasemap();
|
||||||
searchRequest.clearSearchResults();
|
searchRequest.clearSearchResults();
|
||||||
|
@ -546,13 +550,15 @@ public class MapRenderRepositories {
|
||||||
res = new ArrayList<BinaryMapDataObject>();
|
res = new ArrayList<BinaryMapDataObject>();
|
||||||
log.debug("Search failed " + c.getRegionNames(), e); //$NON-NLS-1$
|
log.debug("Search failed " + c.getRegionNames(), e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (res.size() > 0) {
|
if(res.size() > 0) {
|
||||||
TransliterationHelper.setCountry(c.getCountryName());
|
|
||||||
if(basemap) {
|
if(basemap) {
|
||||||
renderedState |= 1;
|
renderedState |= 1;
|
||||||
} else {
|
} else {
|
||||||
renderedState |= 2;
|
renderedState |= 2;
|
||||||
}
|
}
|
||||||
|
if (c.getCountryName().equals("Japan")) {
|
||||||
|
countryInView = c.getCountryName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (BinaryMapDataObject r : res) {
|
for (BinaryMapDataObject r : res) {
|
||||||
if (checkForDuplicateObjectIds && !basemap) {
|
if (checkForDuplicateObjectIds && !basemap) {
|
||||||
|
@ -592,6 +598,7 @@ public class MapRenderRepositories {
|
||||||
land[0] = true;
|
land[0] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setCountryName(countryInView);
|
||||||
return mi;
|
return mi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class TextRenderer {
|
public class TextRenderer {
|
||||||
|
|
||||||
public final static Log LOG = PlatformUtil.getLog(TextRenderer.class);
|
|
||||||
|
|
||||||
private Paint paintText;
|
private Paint paintText;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private Paint paintIcon;
|
private Paint paintIcon;
|
||||||
|
|
Loading…
Reference in a new issue