public void GeohashTest02()
        {
            var hash   = "u4ur9ec";
            var hasher = new GvtkGeohasher();
            var point  = hasher.Decode(hash);

            Assert.AreEqual(hash, hasher.Encode(point, 7));
        }
Ejemplo n.º 2
0
        private string DumpRedirectMap()
        {
            var b         = new StringBuilder();
            var delimiter = ";";
            var hasher    = new GvtkGeohasher();

            b.Append("from;to;p_from;p_to;edge;bb_from;bb_to");
            b.Append(Environment.NewLine);
            foreach (var kvp in RedirectMap
                     .ToList()                                                    // Avoid thread errors
                     .Where(kvp => kvp.Key != kvp.Value))
            {
                b.Append(kvp.Key + delimiter);
                b.Append(kvp.Value + delimiter);
                b.Append(hasher.Decode(kvp.Key).AsText() + delimiter);
                b.Append(hasher.Decode(kvp.Value).AsText() + delimiter);
                b.Append(new LineString(new Coordinate[] { hasher.Decode(kvp.Key).Coordinate, hasher.Decode(kvp.Value).Coordinate }).AsText() + delimiter);
                b.Append(hasher.BoundingBox(kvp.Key).AsText() + delimiter);
                b.Append(hasher.BoundingBox(kvp.Value).AsText() + delimiter);
                b.Append(Environment.NewLine);
            }
            return(b.ToString());
        }
Ejemplo n.º 3
0
        private WeatherHist SelectBestMatch(Point point, List <WeatherHist> matches)
        {
            WeatherHist match;

            if (!Settings.CalculateClosest)
            {
                match = matches.FirstOrDefault();
            }
            else if (Settings.CalculateClosest && matches.Count > 1)
            {
                match = matches.OrderBy(r => GeoHasher.Decode(r.Geohash).Distance(point)).First();
            }
            else
            {
                match = matches.FirstOrDefault();
            }

            return(match);
        }
Ejemplo n.º 4
0
        private string DumpDeadDogs()
        {
            var b         = new StringBuilder();
            var delimiter = ";";
            var hasher    = new GvtkGeohasher();

            b.Append("timestamp;dog;p;bb");
            b.Append(Environment.NewLine);
            foreach (var dog in DeadDogs)
            {
                var timestamp = Util.DateTimeFromEpoch(long.Parse(dog.Split('-')[0]));
                var dogHash   = dog.Split('-')[1];

                b.Append(dogHash + delimiter);
                b.Append(timestamp.ToString("u") + delimiter);
                b.Append(hasher.Decode(dogHash).AsText() + delimiter);
                b.Append(hasher.BoundingBox(dogHash).AsText() + delimiter);
                b.Append(Environment.NewLine);
            }

            return(b.ToString());
        }