Skip to content

Commit

Permalink
Use TemplateLibrary.generateI18N for street names
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesj committed Feb 12, 2015
1 parent 9f25cb2 commit a608107
Showing 1 changed file with 4 additions and 14 deletions.
Expand Up @@ -17,6 +17,8 @@ the License, or (at your option) any later version.

import java.util.HashMap;
import java.util.Map;

import org.opentripplanner.graph_builder.impl.osm.TemplateLibrary;
import org.opentripplanner.util.I18NString;
import org.opentripplanner.util.NonLocalizedString;
import org.opentripplanner.util.TranslatedString;
Expand Down Expand Up @@ -147,7 +149,7 @@ public Boolean isTag(String tag, String value) {
*/
public I18NString getAssumedName() {
if (_tags.containsKey("name"))
return TranslatedString.getI18NString(getTagsByPrefix("name", true));
return TranslatedString.getI18NString(TemplateLibrary.generateI18N("{name}", this));

if (_tags.containsKey("otp:route_name"))
return new NonLocalizedString(_tags.get("otp:route_name"));
Expand All @@ -165,23 +167,11 @@ public I18NString getAssumedName() {
}

public Map<String, String> getTagsByPrefix(String prefix) {
return getTagsByPrefix(prefix, false);
}

private Map<String, String> getTagsByPrefix(String prefix, boolean removePrefix) {
Map<String, String> out = new HashMap<String, String>();
for (Map.Entry<String, String> entry : _tags.entrySet()) {
String k = entry.getKey();
if (k.equals(prefix) || k.startsWith(prefix + ":")) {
if (removePrefix){
if (k.equals(prefix)){
out.put(null, entry.getValue());
} else{
out.put(k.replaceFirst(prefix + ":", ""), entry.getValue());
}
} else {
out.put(k, entry.getValue());
}
out.put(k, entry.getValue());
}
}

Expand Down

0 comments on commit a608107

Please sign in to comment.