Exemple #1
0
        public StatisticalAreaClassification WhatRegions(LatLong pt)
        {
            if (Locations.TryGetValue(pt, out var area))
            {
                return(area);
            }


            // else work out where fits
            var clas = new StatisticalAreaClassification(pt);

            foreach (var setpair in SASets)
            {
                (bool found, StatAreaLocation loc) = InFeatureSet(pt, setpair.Value);

                if (!found)
                {
                    (found, loc) = NearestBoundingBox(pt, setpair.Value);
                }

                if (found)
                {
                    clas.Regions.Add(setpair.Key, loc);

                    if (!SANames.TryGetValue(setpair.Key, out var outer))
                    {
                        outer = new Dictionary <long, string>();
                        SANames.Add(setpair.Key, outer);
                    }

                    if (!outer.ContainsKey(loc.Id))
                    {
                        outer.Add(loc.Id, loc.Name);
                    }
                }
                else
                {
                    //   Console.WriteLine($"Still Missed {setpair.Key}\t{pt.Lat}, {pt.Lon}");
                }
            }

            return(clas);
        }
Exemple #2
0
        public void Merge(SADictionary src)
        {
            foreach (var kvp in src.SANames)
            {
                if (!SANames.TryGetValue(kvp.Key, out var outer))
                {
                    outer = new Dictionary <long, string>();
                    SANames.Add(kvp.Key, outer);
                }

                foreach (var ivp in kvp.Value)
                {
                    outer[ivp.Key] = ivp.Value;
                }
            }

            foreach (var kvp in src.Locations)
            {
                if (!Locations.ContainsKey(kvp.Key))
                {
                    Locations.Add(kvp.Key, new StatisticalAreaClassification(kvp.Value));
                }
            }
        }