//TODO: add cases for URN codes public override bool Process(string input, out ICoordinateSystem output) { string[] prts = input.Split(':'); if (prts.Length == 2) { IKey key; long code; if (long.TryParse(prts[1], out code)) { key = new LongKey { Authority = prts[0], Code = code }; } else { key = new StringKey { Authority = prts[0], Code = prts[1] }; } if (_map.ContainsKey(key)) { output = _map[key]; return(true); } } try { if (string.IsNullOrEmpty(input)) { output = null; return(false); } output = CoordinateSystemFactory.CreateFromWkt(input); return(true); } catch { output = null; return(false); } }
public SridMapStrategy(int priority, ICoordinateSystemFactory csFactory, IEnumerable <ICoordinateSystem> systems) : base(priority, csFactory) { //_coordinateSystems = systems; foreach (ICoordinateSystem cs in systems) { IKey key; long code; if (long.TryParse(cs.AuthorityCode, out code)) { key = new LongKey { Authority = cs.Authority, Code = code }; } else { key = new StringKey { Authority = cs.Authority, Code = cs.AuthorityCode }; } if (!_map.ContainsKey(key)) { _map.Add(key, cs); } else if (!cs.EqualParams(_map[key])) { throw new ApplicationException(); } int csKey = HashCoordSystem(cs); if (!_hashMap.ContainsKey(csKey)) { _hashMap.Add(csKey, key); } else if (!cs.EqualParams(_map[_hashMap[csKey]])) { throw new ApplicationException(); } } }
public bool IsMatched(string key) { return(ShortKey?.Equals(key, StringComparison.OrdinalIgnoreCase) == true || LongKey?.Equals(key, StringComparison.OrdinalIgnoreCase) == true); }