mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 18:38:49 +00:00
Navitia: Add house numbers to addresses.
This commit adds the house number behind the street name if available and gives a way to define other formats like in France where the house number comes before the street name.
This commit is contained in:
parent
8b2488e807
commit
42f9c21145
6 changed files with 47 additions and 1 deletions
|
@ -208,6 +208,19 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navitia always formats the address label in the French way.
|
||||||
|
* This method can be used to display addresses in a localized way.
|
||||||
|
* It defaults to putting the house number behind the street name.
|
||||||
|
*
|
||||||
|
* @param name The name of the address. Usually a street name.
|
||||||
|
* @param houseNumber The house number of the address.
|
||||||
|
* @return the localized name of the address location
|
||||||
|
*/
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return name + " " + houseNumber;
|
||||||
|
}
|
||||||
|
|
||||||
private Location parsePlace(JSONObject location, PlaceType placeType) throws IOException {
|
private Location parsePlace(JSONObject location, PlaceType placeType) throws IOException {
|
||||||
try {
|
try {
|
||||||
final LocationType type = getLocationType(placeType);
|
final LocationType type = getLocationType(placeType);
|
||||||
|
@ -216,7 +229,14 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
id = location.getString("id");
|
id = location.getString("id");
|
||||||
final JSONObject coord = location.getJSONObject("coord");
|
final JSONObject coord = location.getJSONObject("coord");
|
||||||
final Point point = parseCoord(coord);
|
final Point point = parseCoord(coord);
|
||||||
final String name = getLocationName(location.getString("name"));
|
final String placeName = location.getString("name");
|
||||||
|
String name;
|
||||||
|
if (placeType == PlaceType.ADDRESS) {
|
||||||
|
final String houseNumber = location.optString("house_number", "0");
|
||||||
|
name = houseNumber.equals("0") ? getAddressName(placeName, houseNumber) : placeName;
|
||||||
|
} else {
|
||||||
|
name = getLocationName(placeName);
|
||||||
|
}
|
||||||
String place = null;
|
String place = null;
|
||||||
if (location.has("administrative_regions")) {
|
if (location.has("administrative_regions")) {
|
||||||
JSONArray admin = location.getJSONArray("administrative_regions");
|
JSONArray admin = location.getJSONArray("administrative_regions");
|
||||||
|
|
|
@ -75,4 +75,9 @@ public class FranceNorthEastProvider extends AbstractNavitiaProvider {
|
||||||
throw new IllegalArgumentException("Unhandled product: " + product);
|
throw new IllegalArgumentException("Unhandled product: " + product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return houseNumber + " " + name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,4 +41,9 @@ public class FranceNorthWestProvider extends AbstractNavitiaProvider {
|
||||||
public String region() {
|
public String region() {
|
||||||
return API_REGION;
|
return API_REGION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return houseNumber + " " + name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,4 +76,9 @@ public class FranceSouthEastProvider extends AbstractNavitiaProvider {
|
||||||
return super.getLineStyle(network, product, code, color);
|
return super.getLineStyle(network, product, code, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return houseNumber + " " + name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,4 +76,9 @@ public class FranceSouthWestProvider extends AbstractNavitiaProvider {
|
||||||
return super.getLineStyle(network, product, code, color);
|
return super.getLineStyle(network, product, code, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return houseNumber + " " + name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,4 +89,10 @@ public class ParisProvider extends AbstractNavitiaProvider {
|
||||||
protected String getLocationName(String name) {
|
protected String getLocationName(String name) {
|
||||||
return WordUtils.capitalizeFully(name);
|
return WordUtils.capitalizeFully(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAddressName(final String name, final String houseNumber) {
|
||||||
|
return houseNumber + " " + name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue