Fixed getRegionName and improved osmlive filename recognition

This commit is contained in:
PaulStets 2017-10-17 16:15:44 +03:00
parent dd72744c44
commit 67cd31df93
2 changed files with 10 additions and 5 deletions

View file

@ -407,14 +407,18 @@ public class BinaryMapIndexReader {
}
String ls = rg.get(0);
if (ls.lastIndexOf('_') != -1) {
if (ls.matches(".*([0-9]+_*){3}\\.obf")) {
Pattern osmDiffDateEnding = Pattern.compile("_([0-9]+_*){3}\\.obf");
if (ls.matches("([a-zA-Z-]+_)+([0-9]+_){2}[0-9]+\\.obf")) {
Pattern osmDiffDateEnding = Pattern.compile("_([0-9]+_){2}[0-9]+\\.obf");
Matcher m = osmDiffDateEnding.matcher(ls);
if (m.find()) {
ls = ls.substring(0, m.start());
if (ls.lastIndexOf('_') != -1) {
return ls.substring(0, ls.lastIndexOf('_')).replace('_', ' ');
} else {
return ls;
}
}
return ls.substring(0, ls.lastIndexOf('_')).replace('_', ' ');
} else {
if (ls.contains(".")) {
ls = ls.substring(0, ls.indexOf("."));

View file

@ -587,7 +587,8 @@ public class SearchPhrase {
Iterator<BinaryMapIndexReader> it = indexes.iterator();
while (it.hasNext()) {
BinaryMapIndexReader r = it.next();
if (r.getFile().getName().matches(".*([0-9]+_*){3}\\.obf")) {
String filename = r.getFile().getName();
if (filename.matches("([a-zA-Z-]+_)+([0-9]+_){2}[0-9]+\\.obf")) {
String currRegionName = r.getRegionName();
if (result.containsKey(currRegionName)) {
result.get(currRegionName).add(r);