示例#1
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);
        }