public ConfiguredSpaceFillingCurveSettingsCache(Config config)
        {
            this._maxBits = config.Get(SpatialIndexSettings.SpaceFillingCurveMaxBits);
            Dictionary <CoordinateReferenceSystem, EnvelopeSettings> env = EnvelopeSettings.EnvelopeSettingsFromConfig(config);

            foreach (KeyValuePair <CoordinateReferenceSystem, EnvelopeSettings> entry in env.SetOfKeyValuePairs())
            {
                CoordinateReferenceSystem crs = entry.Key;
                _settings[crs] = SpaceFillingCurveSettingsFactory.FromConfig(this._maxBits, entry.Value);
            }
        }
Beispiel #2
0
        internal static Dictionary <CoordinateReferenceSystem, EnvelopeSettings> EnvelopeSettingsFromConfig(Config config)
        {
            Dictionary <CoordinateReferenceSystem, EnvelopeSettings> env = new Dictionary <CoordinateReferenceSystem, EnvelopeSettings>();

            foreach (KeyValuePair <string, ConfigValue> entry in config.ConfigValues.SetOfKeyValuePairs())
            {
                string key   = entry.Key;
                string value = entry.Value.ToString();
                if (key.StartsWith(SPATIAL_SETTING_PREFIX, StringComparison.Ordinal))
                {
                    string[] fields = key.Replace(SPATIAL_SETTING_PREFIX, "").Split("\\.", true);
                    if (fields.Length != 3)
                    {
                        throw new System.ArgumentException("Invalid spatial config settings, expected three fields after '" + SPATIAL_SETTING_PREFIX + "': " + key);
                    }
                    else
                    {
                        CoordinateReferenceSystem crs = CoordinateReferenceSystem.byName(fields[0]);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                        EnvelopeSettings envelopeSettings = env.computeIfAbsent(crs, EnvelopeSettings::new);
                        int index = "xyz".IndexOf(fields[1].ToLower(), StringComparison.Ordinal);
                        if (index < 0)
                        {
                            throw new System.ArgumentException("Invalid spatial coordinate key (should be one of 'x', 'y' or 'z'): " + fields[1]);
                        }
                        if (index >= crs.Dimension)
                        {
                            throw new System.ArgumentException("Invalid spatial coordinate key for " + crs.Dimension + "D: " + fields[1]);
                        }
                        switch (fields[2].ToLower())
                        {
                        case "min":
                            envelopeSettings._min[index] = double.Parse(value);
                            break;

                        case "max":
                            envelopeSettings._max[index] = double.Parse(value);
                            break;

                        default:
                            throw new System.ArgumentException("Invalid spatial coordinate range key (should be one of 'max' or 'min'): " + fields[2]);
                        }
                    }
                }
            }
            return(env);
        }
Beispiel #3
0
 /// <summary>
 /// This method builds the default index configuration object for the specified CRS and other config options.
 /// Currently we only support a SingleSpaceFillingCurveSettings which is the best option for cartesian, but
 /// not necessarily the best for geographic coordinate systems.
 /// </summary>
 internal static SpaceFillingCurveSettings FromConfig(int maxBits, EnvelopeSettings envelopeSettings)
 {
     // Currently we support only one type of index, but in future we could support different types for different CRS
     return(new SpaceFillingCurveSettings.SettingsFromConfig(envelopeSettings.Crs.Dimension, maxBits, envelopeSettings.AsEnvelope()));
 }