Skip to content

Commit

Permalink
POI: deal with equal sign in tag values (mapsforge#1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinez Casanova, Juan authored and devemux86 committed Jan 21, 2022
1 parent 4f6ba56 commit e2342b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2015-2019 devemux86
* Copyright 2017-2018 Gustl22
* Copyright 2019 Kamil Donoval
* Copyright 2022 Juanjo-MC
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand Down Expand Up @@ -576,11 +577,11 @@ private void processWay(Way way) {
Map<String, String> stringToTags(String tagsmapstring) {
String[] sb = tagsmapstring.split("\\r");
Map<String, String> map = new HashMap<>();
for (String key : sb) {
if (key.contains("=")) {
String[] set = key.split("=");
if (set.length == 2)
map.put(set[0], set[1]);
for (String set : sb) {
if (set.indexOf(org.mapsforge.core.model.Tag.KEY_VALUE_SEPARATOR) > -1) {
String key = set.split(String.valueOf(org.mapsforge.core.model.Tag.KEY_VALUE_SEPARATOR))[0];
String value = set.substring(key.length() + 1);
map.put(key, value);
}
}
return map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2015-2017 devemux86
* Copyright 2017 Gustl22
* Copyright 2022 Juanjo-MC
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand All @@ -20,11 +21,7 @@
import org.mapsforge.core.model.Tag;
import org.mapsforge.core.util.LatLongUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;

/**
* Abstract implementation for the {@link PoiPersistenceManager} interface. This implementation
Expand Down Expand Up @@ -126,10 +123,9 @@ protected static Set<Tag> stringToTags(String data) {
String[] split = data.split("\r");
for (String s : split) {
if (s.indexOf(Tag.KEY_VALUE_SEPARATOR) > -1) {
String[] keyValue = s.split(String.valueOf(Tag.KEY_VALUE_SEPARATOR));
if (keyValue.length == 2) {
tags.add(new Tag(keyValue[0], keyValue[1]));
}
String key = s.split(String.valueOf(Tag.KEY_VALUE_SEPARATOR))[0];
String value = s.substring(key.length() + 1);
tags.add(new Tag(key, value));
}
}
return tags;
Expand Down

0 comments on commit e2342b8

Please sign in to comment.