support map provider and whether use map data proxy settings

This commit is contained in:
MaysWind
2023-06-04 14:39:20 +08:00
parent 2e54b62f60
commit 8cf7bf859b
10 changed files with 139 additions and 53 deletions
+26
View File
@@ -62,6 +62,11 @@ const (
InternalUuidGeneratorType string = "internal"
)
// Map provider types
const (
OpenStreetMapProvider string = "openstreetmap"
)
// Exchange rates data source types
const (
EuroCentralBankDataSource string = "euro_central_bank"
@@ -169,6 +174,10 @@ type Config struct {
// Data
EnableDataExport bool
// Map
MapProvider string
EnableMapDataFetchProxy bool
// Exchange Rates
ExchangeRatesDataSource string
ExchangeRatesRequestTimeout uint32
@@ -239,6 +248,12 @@ func LoadConfiguration(configFilePath string) (*Config, error) {
return nil, err
}
err = loadMapConfiguration(config, cfgFile, "map")
if err != nil {
return nil, err
}
err = loadExchangeRatesConfiguration(config, cfgFile, "exchange_rates")
if err != nil {
@@ -416,6 +431,17 @@ func loadDataConfiguration(config *Config, configFile *ini.File, sectionName str
return nil
}
func loadMapConfiguration(config *Config, configFile *ini.File, sectionName string) error {
if getConfigItemStringValue(configFile, sectionName, "map_provider") == OpenStreetMapProvider {
config.MapProvider = OpenStreetMapProvider
} else {
return errs.ErrInvalidMapProvider
}
config.EnableMapDataFetchProxy = getConfigItemBoolValue(configFile, sectionName, "map_data_fetch_proxy", false)
return nil
}
func loadExchangeRatesConfiguration(config *Config, configFile *ini.File, sectionName string) error {
if getConfigItemStringValue(configFile, sectionName, "data_source") == EuroCentralBankDataSource {
config.ExchangeRatesDataSource = EuroCentralBankDataSource