Support ziping text
This commit is contained in:
parent
0acbb5f5f5
commit
b3e01c3fca
2 changed files with 39 additions and 4 deletions
|
@ -5,12 +5,16 @@ import gnu.trove.list.array.TIntArrayList;
|
|||
import gnu.trove.map.hash.TIntLongHashMap;
|
||||
import gnu.trove.set.hash.TLongHashSet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
|
@ -701,6 +705,31 @@ public class BinaryMapPoiReaderAdapter {
|
|||
case OsmandOdb.OsmAndPoiBoxDataAtom.TEXTVALUES_FIELD_NUMBER :
|
||||
String str = codedIS.readString();
|
||||
if(textTags != null && !textTags.isEmpty()) {
|
||||
if(str.startsWith(" gz ")) {
|
||||
int ind = 4;
|
||||
byte[] bytes = new byte[str.length() - ind];
|
||||
for(int i = ind; i < str.length(); i++ ) {
|
||||
char ch = str.charAt(i) ;
|
||||
if(ch < 0 || ch >= 256) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if(ch >= 128) {
|
||||
bytes[i - ind] = (byte) (ch - 256);
|
||||
} else if(ch >= 0){
|
||||
bytes[i - ind] = (byte) ch;
|
||||
}
|
||||
|
||||
}
|
||||
GZIPInputStream gzn = new GZIPInputStream(new ByteArrayInputStream(
|
||||
bytes));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(gzn, "UTF-8"));
|
||||
StringBuilder bld = new StringBuilder();
|
||||
String s;
|
||||
while((s = br.readLine()) != null) {
|
||||
bld.append(s);
|
||||
}
|
||||
str = bld.toString();
|
||||
}
|
||||
am.setAdditionalInfo(textTags.poll(), str);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -315,7 +315,7 @@ public class MapRenderingTypes {
|
|||
if (name.equals("category")) { //$NON-NLS-1$
|
||||
parentCategory = parseCategoryFromXml(parser);
|
||||
} else if (name.equals("type")) {
|
||||
parseTypeFromXML(parser, parentCategory);
|
||||
parseAndRegisterTypeFromXML(parser, parentCategory);
|
||||
} else if (name.equals("routing_type")) {
|
||||
parseRouteTagFromXML(parser);
|
||||
} else if (name.equals("entity_convert")) {
|
||||
|
@ -347,12 +347,17 @@ public class MapRenderingTypes {
|
|||
protected void parseRouteTagFromXML(XmlPullParser parser) {
|
||||
}
|
||||
|
||||
protected MapRulType parseTypeFromXML(XmlPullParser parser, MapRulType parentCategory) {
|
||||
return parseBaseRuleType(parser, parentCategory, true);
|
||||
protected void parseAndRegisterTypeFromXML(XmlPullParser parser, MapRulType parentCategory) {
|
||||
parseBaseRuleType(parser, parentCategory, true);
|
||||
}
|
||||
|
||||
|
||||
protected MapRulType parseBaseRuleType(XmlPullParser parser, MapRulType parentCategory, boolean filterOnlyMap) {
|
||||
String tag = lc(parser.getAttributeValue("", "tag"));
|
||||
return parseBaseRuleType(parser, parentCategory, filterOnlyMap, tag);
|
||||
}
|
||||
|
||||
protected MapRulType parseBaseRuleType(XmlPullParser parser, MapRulType parentCategory, boolean filterOnlyMap,
|
||||
String tag) {
|
||||
String value = lc(parser.getAttributeValue("", "value"));
|
||||
String additional = parser.getAttributeValue("", "additional");
|
||||
if (value != null && value.length() == 0) { //$NON-NLS-1$
|
||||
|
@ -624,6 +629,7 @@ public class MapRenderingTypes {
|
|||
// creation of only section
|
||||
protected boolean onlyMap;
|
||||
protected boolean onlyPoi;
|
||||
protected boolean lang;
|
||||
|
||||
// Needed only for map rules
|
||||
protected int minzoom;
|
||||
|
|
Loading…
Reference in a new issue