use of org.opentripplanner.util.LocalizedString in project OpenTripPlanner by opentripplanner.
the class StreetVertex method getIntersectionName.
/**
* Creates intersection name out of all outgoing names
*
* This can be:
* - name of the street if it is only 1
* - unnamedStreed (localized in requested language) if it doesn't have a name
* - corner of 0 and 1 (localized corner of zero and first street in the corner)
*
* @param locale Wanted locale
* @return already localized street names and non-localized corner of x and unnamedStreet
*/
public I18NString getIntersectionName(Locale locale) {
I18NString calculatedName = null;
// generate names for corners when no name was given
Set<String> uniqueNameSet = new HashSet<String>();
for (Edge e : getOutgoing()) {
if (e instanceof StreetEdge) {
uniqueNameSet.add(e.getName(locale));
}
}
List<String> uniqueNames = new ArrayList<String>(uniqueNameSet);
if (uniqueNames.size() > 1) {
calculatedName = new LocalizedString("corner", new String[] { uniqueNames.get(0), uniqueNames.get(1) });
} else if (uniqueNames.size() == 1) {
calculatedName = new NonLocalizedString(uniqueNames.get(0));
} else {
calculatedName = new LocalizedString("unnamedStreet", (String[]) null);
}
return calculatedName;
}
use of org.opentripplanner.util.LocalizedString in project OpenTripPlanner by opentripplanner.
the class NoteProperties method generateNote.
public T2<Alert, NoteMatcher> generateNote(OSMWithTags way) {
Alert note = new Alert();
// TODO: this could probably be made without patternMatch for {} since all notes (at least currently) have {note} as notePattern
if (patternMatcher.matcher(notePattern).matches()) {
// This gets language -> translation of notePattern and all tags (which can have translations name:en for example)
Map<String, String> noteText = TemplateLibrary.generateI18N(notePattern, way);
note.alertHeaderText = TranslatedString.getI18NString(noteText);
} else {
note.alertHeaderText = new LocalizedString(notePattern, way);
}
return new T2<>(note, noteMatcher);
}
use of org.opentripplanner.util.LocalizedString in project OpenTripPlanner by opentripplanner.
the class TestOpenStreetMapGraphBuilder method testLocalizedString.
@Test
public void testLocalizedString() {
LocalizedString localizedString = new LocalizedString("corner", new String[] { "first", "second" });
assertEquals("corner of first and second", localizedString.toString());
assertEquals("Kreuzung first mit second", localizedString.toString(new Locale("de")));
}
Aggregations