private Dictionary <string, string> _parameters; // any extra parameters. #endregion #region Constructors /// <summary> /// Creates a new instance of Parameters /// </summary> public ProjectionInfo() { _geographicInfo = new GeographicInfo(); _unit = new LinearUnit(); _parameters = new Dictionary <string, string>(); _scaleFactor = 1; // if not specified, default to 1 }
/// <summary> /// Attempts to parse known parameters from the set of proj4 parameters /// </summary> /// <param name="proj4string"></param> public void ReadProj4String(string proj4string) { string[] paramList = proj4string.Split('+'); foreach (string s in paramList) { if (s == "") { continue; } if (s == "no_defs") { continue; } string[] temp = s.Split('='); string name = temp[0].Trim(); string value = ""; if (temp.Length > 1) { value = temp[1]; if (value != null) { value = value.Trim(); } } if (_parameters.ContainsKey(name)) { // some "+to" parameters exist... but I'm not sure what to do with them // asside from the fact that they seem to specify a second projection? } else { _parameters.Add(name, value); } } GeographicInfo.ReadProj4Parameters(_parameters); if (_parameters.ContainsKey("x_0")) { _falseEasting = double.Parse(_parameters["x_0"]); } if (_parameters.ContainsKey("y_0")) { _falseNorthing = double.Parse(_parameters["y_0"]); } if (_parameters.ContainsKey("k")) { _scaleFactor = double.Parse(_parameters["k"]); } if (_parameters.ContainsKey("k_0")) { _scaleFactor = double.Parse(_parameters["k_0"]); } if (_parameters.ContainsKey("lat_0")) { _latitudeOfOrigin = double.Parse(_parameters["lat_0"]); } if (_parameters.ContainsKey("lat_1")) { _standardParallel1 = double.Parse(_parameters["lat_1"]); } if (_parameters.ContainsKey("lat_ts")) { _standardParallel1 = double.Parse(_parameters["lat_ts"]); } if (_parameters.ContainsKey("lat_2")) { _standardParallel2 = double.Parse(_parameters["lat_2"]); } if (_parameters.ContainsKey("lon_0")) { _centralMeridian = double.Parse(_parameters["lon_0"]); } if (_parameters.ContainsKey("south")) { _south = true; } if (_parameters.ContainsKey("zone")) { _zone = int.Parse(_parameters["zone"]); } if (_parameters.ContainsKey("geoc")) { _geoc = bool.Parse(_parameters["geoc"]) && (GeographicInfo.Datum.Spheroid.EccentricitySquared() != 0); } if (_parameters.ContainsKey("over")) { _over = bool.Parse(_parameters["over"]); } if (_parameters.ContainsKey("proj")) { _transform = TransformManager.DefaultTransformManager.GetProj4(_parameters["proj"]); _transform.Init(this); //switch (_transform.ProjectionName) //{ // case ProjectionNames.North_Polar_Stereographic: // case ProjectionNames.South_Polar_Stereographic: // if (_standardParallel1 != null) // { // _scaleFactor = Proj.CalScaleFactorFromStandardParallel((double)_standardParallel1); // _standardParallel1 = null; // } // break; //} } UpdateParam(); }