Package org.goplanit.osm.defaults
Class OsmSpeedLimitDefaultsByCountry
- java.lang.Object
-
- org.goplanit.osm.defaults.OsmSpeedLimitDefaultsByCountry
-
public class OsmSpeedLimitDefaultsByCountry extends Object
Convenience class for quickly collecting the speed limits for various countries, where possible based on https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Maxspeed (highway types)Note that a distinction is made between inside or outside a place, which refers to the road being inside or outside an urban area. this significantly impacts the speed limit.
Unfortunately, the link cannot judge if it is inside or outside. So, we leave it to the user of this class to indicate which of the two values should be used (if there are two available).
Note 1: railway speed limits are not known in OSM, so we use a global default for all types, which the user may override if required. Also no distinction is made between inside or outside an urban area.
- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected static OsmSpeedLimitDefaults
GLOBAL_SPEED_LIMIT_DEFAULTS
store the global railway defaults as fall back optionprotected static Map<String,OsmSpeedLimitDefaults>
speedLimitDefaultsByCountryCode
store all defaults per country by ISO2 code
-
Constructor Summary
Constructors Constructor Description OsmSpeedLimitDefaultsByCountry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OsmSpeedLimitDefaults
create()
Factory method to create global defaults only.static OsmSpeedLimitDefaults
create(String countryName)
Factory method to create speed limits for a particular country.protected static OsmSpeedLimitDefaults
getDefaultsByCountryISO2(String countryISO2)
collect the (original) speed limit defaults (outside,inside urban areas) for a given country ISO2 codeprotected static OsmSpeedLimitDefaults
getDefaultsByCountryName(String countryName)
collect the (original) speed limit defaults (outside,inside urban areas) for a given country namestatic OsmSpeedLimitDefaultsCategory
getGlobalNonUrbanHighwayDefaults()
collect the (original) highway-non-urban speed limit defaultsstatic OsmSpeedLimitDefaultsCategory
getGlobalRailwayDefaults()
collect the (original) railway speed limit defaultsstatic OsmSpeedLimitDefaultsCategory
getGlobalUrbanHighwayDefaults()
collect the (original) highway-urban speed limit defaultsprotected static double
getSpeedLimitByHighwayType(OsmSpeedLimitDefaults countryDefaults, boolean outside, String type)
Collect the speed limit based on the highway type, e.g.protected static void
populateAustralianSpeedLimits()
Populate the defaults for Australiaprotected static void
populateCountrySpecificHighwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)
The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country.protected static void
populateCountrySpecificRailwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)
The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country.protected static void
populateCountrySpecificSpeedLimits()
Populate the country specific defaults for highway/railway types for supported countriesprotected static void
populateDefaultRailwaySpeedLimits(OsmSpeedLimitDefaultsCategory toPopulate)
Populate the defaults for railway types for given country (or global).protected static void
populateDefaultWaterwaySpeedLimits(OsmSpeedLimitDefaultsCategory speedLimitsToPopulate)
Populate the defaults for waterway types for given country (or global).protected static void
populateGlobalDefaultHighwaySpeedLimits()
Populate the global defaults for highway types in case the country is not available, or in case the road type for that country is not availableprotected static void
populateGlobalDefaultRailwaySpeedLimits()
populate the global defaults for railway types in case the country is not available, or in case the railway type for that country is not available.protected static void
populateGlobalDefaultWaterwaySpeedLimits()
populate the global defaults for waterway types in case the country is not available, or in case the waterway type for that country is not available.protected static void
populateGlobalSpeedLimits()
populate the global defaults for highway/railway typesprotected static void
setDefaultsByCountry(OsmSpeedLimitDefaults countrySpeedLimits)
Register speed limits for a specific countryprotected static void
setGlobalHighwaySpeedLimitDefaults(String type, double urbanSpeedLimit, double nonUrbanSpeedLimit)
Set global defaults for highwaysprotected static void
setGlobalRailwaySpeedLimitDefaults(String type, double speedLimit)
Set global defaults for railways
-
-
-
Field Detail
-
GLOBAL_SPEED_LIMIT_DEFAULTS
protected static final OsmSpeedLimitDefaults GLOBAL_SPEED_LIMIT_DEFAULTS
store the global railway defaults as fall back option
-
speedLimitDefaultsByCountryCode
protected static Map<String,OsmSpeedLimitDefaults> speedLimitDefaultsByCountryCode
store all defaults per country by ISO2 code
-
-
Method Detail
-
populateGlobalSpeedLimits
protected static void populateGlobalSpeedLimits() throws PlanItException
populate the global defaults for highway/railway types- Throws:
PlanItException
- thrown if error
-
populateCountrySpecificSpeedLimits
protected static void populateCountrySpecificSpeedLimits() throws PlanItException
Populate the country specific defaults for highway/railway types for supported countries- Throws:
PlanItException
- thrown if error
-
populateCountrySpecificRailwayDefaultSpeedLimits
protected static void populateCountrySpecificRailwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)
The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country. If no explicit value is provided, we revert to the global defaults instead.- Parameters:
inputReader
- to extract speed limit defaults fromfullCountryName
- these defaults relate to
-
populateCountrySpecificHighwayDefaultSpeedLimits
protected static void populateCountrySpecificHighwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)
The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country. If no explicit value is provided, we revert to the global defaults instead.- Parameters:
inputReader
- to extract speed limit defaults fromfullCountryName
- these defaults relate to
-
setGlobalHighwaySpeedLimitDefaults
protected static void setGlobalHighwaySpeedLimitDefaults(String type, double urbanSpeedLimit, double nonUrbanSpeedLimit)
Set global defaults for highways- Parameters:
type
- of highwayurbanSpeedLimit
- urban limitnonUrbanSpeedLimit
- non-urban limit
-
setGlobalRailwaySpeedLimitDefaults
protected static void setGlobalRailwaySpeedLimitDefaults(String type, double speedLimit)
Set global defaults for railways- Parameters:
type
- of railwayspeedLimit
- to use
-
populateGlobalDefaultHighwaySpeedLimits
protected static void populateGlobalDefaultHighwaySpeedLimits()
Populate the global defaults for highway types in case the country is not available, or in case the road type for that country is not available
-
populateDefaultRailwaySpeedLimits
protected static void populateDefaultRailwaySpeedLimits(OsmSpeedLimitDefaultsCategory toPopulate)
Populate the defaults for railway types for given country (or global). Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_RAILWAY_SPEEDLIMIT_KMH
as the default for all modes. This can overwritten by the user if required- Parameters:
toPopulate
- to populate
-
populateDefaultWaterwaySpeedLimits
protected static void populateDefaultWaterwaySpeedLimits(OsmSpeedLimitDefaultsCategory speedLimitsToPopulate)
Populate the defaults for waterway types for given country (or global). Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_WATERWAY_SPEEDLIMIT_KMH
as the default for all modes. This can overwritten by the user if required- Parameters:
speedLimitsToPopulate
- to populate
-
populateGlobalDefaultRailwaySpeedLimits
protected static void populateGlobalDefaultRailwaySpeedLimits()
populate the global defaults for railway types in case the country is not available, or in case the railway type for that country is not available. Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_RAILWAY_SPEEDLIMIT_KMH
as the default for all modes. This can overwritten by the user if required
-
populateGlobalDefaultWaterwaySpeedLimits
protected static void populateGlobalDefaultWaterwaySpeedLimits()
populate the global defaults for waterway types in case the country is not available, or in case the waterway type for that country is not available. Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_WATERWAY_SPEEDLIMIT_KMH
as the default for all modes. This can overwritten by the user if required
-
populateAustralianSpeedLimits
protected static void populateAustralianSpeedLimits()
Populate the defaults for Australia
-
getSpeedLimitByHighwayType
protected static double getSpeedLimitByHighwayType(OsmSpeedLimitDefaults countryDefaults, boolean outside, String type)
Collect the speed limit based on the highway type, e.g. highway=type, inside an urban area. Speed limit is collected based on the chosen country. If either the country is not defined or the highway type is not available on the country's defaults, the global defaults will be used- Parameters:
countryDefaults
- to useoutside
- indicates to use urban or non-urban defaultstype
- highway type value- Returns:
- speed limit inside urban area for this type
-
setDefaultsByCountry
protected static void setDefaultsByCountry(OsmSpeedLimitDefaults countrySpeedLimits)
Register speed limits for a specific country- Parameters:
countrySpeedLimits
- speed limits by highway type
-
getDefaultsByCountryName
protected static OsmSpeedLimitDefaults getDefaultsByCountryName(String countryName)
collect the (original) speed limit defaults (outside,inside urban areas) for a given country name- Parameters:
countryName
- to collect for- Returns:
- speed limits, null if not presently available
-
getDefaultsByCountryISO2
protected static OsmSpeedLimitDefaults getDefaultsByCountryISO2(String countryISO2)
collect the (original) speed limit defaults (outside,inside urban areas) for a given country ISO2 code- Parameters:
countryISO2
- to collect for- Returns:
- speed limits, null if not presently available
-
create
public static OsmSpeedLimitDefaults create()
Factory method to create global defaults only.- Returns:
- created defaults
-
create
public static OsmSpeedLimitDefaults create(String countryName)
Factory method to create speed limits for a particular country. It will utilise this country's defaults. If not available, or particular road type's are not available it will revert to the globally set defaults- Parameters:
countryName
- to use- Returns:
- created defaults
-
getGlobalUrbanHighwayDefaults
public static OsmSpeedLimitDefaultsCategory getGlobalUrbanHighwayDefaults()
collect the (original) highway-urban speed limit defaults- Returns:
- global speed limit defaults
-
getGlobalNonUrbanHighwayDefaults
public static OsmSpeedLimitDefaultsCategory getGlobalNonUrbanHighwayDefaults()
collect the (original) highway-non-urban speed limit defaults- Returns:
- global speed limit defaults
-
getGlobalRailwayDefaults
public static OsmSpeedLimitDefaultsCategory getGlobalRailwayDefaults()
collect the (original) railway speed limit defaults- Returns:
- global speed limit defaults
-
-