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 SummaryFields Modifier and Type Field Description protected static OsmSpeedLimitDefaultsGLOBAL_SPEED_LIMIT_DEFAULTSstore the global railway defaults as fall back optionprotected static Map<String,OsmSpeedLimitDefaults>speedLimitDefaultsByCountryCodestore all defaults per country by ISO2 code
 - 
Constructor SummaryConstructors Constructor Description OsmSpeedLimitDefaultsByCountry()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static OsmSpeedLimitDefaultscreate()Factory method to create global defaults only.static OsmSpeedLimitDefaultscreate(String countryName)Factory method to create speed limits for a particular country.protected static OsmSpeedLimitDefaultsgetDefaultsByCountryISO2(String countryISO2)collect the (original) speed limit defaults (outside,inside urban areas) for a given country ISO2 codeprotected static OsmSpeedLimitDefaultsgetDefaultsByCountryName(String countryName)collect the (original) speed limit defaults (outside,inside urban areas) for a given country namestatic OsmSpeedLimitDefaultsCategorygetGlobalNonUrbanHighwayDefaults()collect the (original) highway-non-urban speed limit defaultsstatic OsmSpeedLimitDefaultsCategorygetGlobalRailwayDefaults()collect the (original) railway speed limit defaultsstatic OsmSpeedLimitDefaultsCategorygetGlobalUrbanHighwayDefaults()collect the (original) highway-urban speed limit defaultsprotected static doublegetSpeedLimitByHighwayType(OsmSpeedLimitDefaults countryDefaults, boolean outside, String type)Collect the speed limit based on the highway type, e.g.protected static voidpopulateAustralianSpeedLimits()Populate the defaults for Australiaprotected static voidpopulateCountrySpecificHighwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country.protected static voidpopulateCountrySpecificRailwayDefaultSpeedLimits(InputStreamReader inputReader, String fullCountryName)The speed limit defaults are parsed as CSV format and overwrite the global defaults for this country.protected static voidpopulateCountrySpecificSpeedLimits()Populate the country specific defaults for highway/railway types for supported countriesprotected static voidpopulateDefaultRailwaySpeedLimits(OsmSpeedLimitDefaultsCategory toPopulate)Populate the defaults for railway types for given country (or global).protected static voidpopulateDefaultWaterwaySpeedLimits(OsmSpeedLimitDefaultsCategory speedLimitsToPopulate)Populate the defaults for waterway types for given country (or global).protected static voidpopulateGlobalDefaultHighwaySpeedLimits()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 voidpopulateGlobalDefaultRailwaySpeedLimits()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 voidpopulateGlobalDefaultWaterwaySpeedLimits()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 voidpopulateGlobalSpeedLimits()populate the global defaults for highway/railway typesprotected static voidsetDefaultsByCountry(OsmSpeedLimitDefaults countrySpeedLimits)Register speed limits for a specific countryprotected static voidsetGlobalHighwaySpeedLimitDefaults(String type, double urbanSpeedLimit, double nonUrbanSpeedLimit)Set global defaults for highwaysprotected static voidsetGlobalRailwaySpeedLimitDefaults(String type, double speedLimit)Set global defaults for railways
 
- 
- 
- 
Field Detail- 
GLOBAL_SPEED_LIMIT_DEFAULTSprotected static final OsmSpeedLimitDefaults GLOBAL_SPEED_LIMIT_DEFAULTS store the global railway defaults as fall back option
 - 
speedLimitDefaultsByCountryCodeprotected static Map<String,OsmSpeedLimitDefaults> speedLimitDefaultsByCountryCode store all defaults per country by ISO2 code
 
- 
 - 
Method Detail- 
populateGlobalSpeedLimitsprotected static void populateGlobalSpeedLimits() throws PlanItExceptionpopulate the global defaults for highway/railway types- Throws:
- PlanItException- thrown if error
 
 - 
populateCountrySpecificSpeedLimitsprotected static void populateCountrySpecificSpeedLimits() throws PlanItExceptionPopulate the country specific defaults for highway/railway types for supported countries- Throws:
- PlanItException- thrown if error
 
 - 
populateCountrySpecificRailwayDefaultSpeedLimitsprotected 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 from
- fullCountryName- these defaults relate to
 
 - 
populateCountrySpecificHighwayDefaultSpeedLimitsprotected 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 from
- fullCountryName- these defaults relate to
 
 - 
setGlobalHighwaySpeedLimitDefaultsprotected static void setGlobalHighwaySpeedLimitDefaults(String type, double urbanSpeedLimit, double nonUrbanSpeedLimit) Set global defaults for highways- Parameters:
- type- of highway
- urbanSpeedLimit- urban limit
- nonUrbanSpeedLimit- non-urban limit
 
 - 
setGlobalRailwaySpeedLimitDefaultsprotected static void setGlobalRailwaySpeedLimitDefaults(String type, double speedLimit) Set global defaults for railways- Parameters:
- type- of railway
- speedLimit- to use
 
 - 
populateGlobalDefaultHighwaySpeedLimitsprotected 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
 - 
populateDefaultRailwaySpeedLimitsprotected static void populateDefaultRailwaySpeedLimits(OsmSpeedLimitDefaultsCategory toPopulate) Populate the defaults for railway types for given country (or global). Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_RAILWAY_SPEEDLIMIT_KMHas the default for all modes. This can overwritten by the user if required- Parameters:
- toPopulate- to populate
 
 - 
populateDefaultWaterwaySpeedLimitsprotected static void populateDefaultWaterwaySpeedLimits(OsmSpeedLimitDefaultsCategory speedLimitsToPopulate) Populate the defaults for waterway types for given country (or global). Currently, we set theOsmSpeedLimitDefaults.GLOBAL_DEFAULT_WATERWAY_SPEEDLIMIT_KMHas the default for all modes. This can overwritten by the user if required- Parameters:
- speedLimitsToPopulate- to populate
 
 - 
populateGlobalDefaultRailwaySpeedLimitsprotected 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_KMHas the default for all modes. This can overwritten by the user if required
 - 
populateGlobalDefaultWaterwaySpeedLimitsprotected 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_KMHas the default for all modes. This can overwritten by the user if required
 - 
populateAustralianSpeedLimitsprotected static void populateAustralianSpeedLimits() Populate the defaults for Australia
 - 
getSpeedLimitByHighwayTypeprotected 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 use
- outside- indicates to use urban or non-urban defaults
- type- highway type value
- Returns:
- speed limit inside urban area for this type
 
 - 
setDefaultsByCountryprotected static void setDefaultsByCountry(OsmSpeedLimitDefaults countrySpeedLimits) Register speed limits for a specific country- Parameters:
- countrySpeedLimits- speed limits by highway type
 
 - 
getDefaultsByCountryNameprotected 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
 
 - 
getDefaultsByCountryISO2protected 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
 
 - 
createpublic static OsmSpeedLimitDefaults create() Factory method to create global defaults only.- Returns:
- created defaults
 
 - 
createpublic 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
 
 - 
getGlobalUrbanHighwayDefaultspublic static OsmSpeedLimitDefaultsCategory getGlobalUrbanHighwayDefaults() collect the (original) highway-urban speed limit defaults- Returns:
- global speed limit defaults
 
 - 
getGlobalNonUrbanHighwayDefaultspublic static OsmSpeedLimitDefaultsCategory getGlobalNonUrbanHighwayDefaults() collect the (original) highway-non-urban speed limit defaults- Returns:
- global speed limit defaults
 
 - 
getGlobalRailwayDefaultspublic static OsmSpeedLimitDefaultsCategory getGlobalRailwayDefaults() collect the (original) railway speed limit defaults- Returns:
- global speed limit defaults
 
 
- 
 
-