Ejemplo n.º 1
0
        /**
         * Neighbors Integer
         *
         * Returns all neighbors' hash integers clockwise from north around to northwest
         * 7 0 1
         * 6 x 2
         * 5 4 3
         * @param {long} hashInt
         * @param {int} bitDepth
         * @returns {EncodeInt'd neighborHashIntList|long[]}
         */
        public static long[] NeighborsInt(long hashInt, int bitDepth = 52)
        {
            var lonlat = DecodeInt(hashInt, bitDepth);
            var coords = new GeohashDecodeResult
            {
                Coordinates = lonlat.Coordinates,
                Error       = new Coordinates
                {
                    Lat = lonlat.Error.Lat * 2,
                    Lon = lonlat.Error.Lon * 2
                }
            };

            return(new[]
            {
                EncodeNeighborInt(1, 0, coords, bitDepth),
                EncodeNeighborInt(1, 1, coords, bitDepth),
                EncodeNeighborInt(0, 1, coords, bitDepth),
                EncodeNeighborInt(-1, 1, coords, bitDepth),
                EncodeNeighborInt(-1, 0, coords, bitDepth),
                EncodeNeighborInt(-1, -1, coords, bitDepth),
                EncodeNeighborInt(0, -1, coords, bitDepth),
                EncodeNeighborInt(1, -1, coords, bitDepth)
            });
        }
Ejemplo n.º 2
0
        /**
         * Neighbors
         *
         * Returns all neighbors' hashstrings clockwise from north around to northwest
         * 7 0 1
         * 6 x 2
         * 5 4 3
         * @param {string} hashString
         * @returns {encoded neighborHashList|string[]}
         */
        public static string[] Neighbors(string hashString)
        {
            var hashstringLength = hashString.Count();
            var lonlat           = Decode(hashString);
            var coords           = new GeohashDecodeResult
            {
                Coordinates = lonlat.Coordinates,
                Error       = new Coordinates
                {
                    Lat = lonlat.Error.Lat * 2,
                    Lon = lonlat.Error.Lon * 2
                }
            };

            return(new[]
            {
                EncodeNeighbor(hashstringLength, 1, 0, coords),
                EncodeNeighbor(hashstringLength, 1, 1, coords),
                EncodeNeighbor(hashstringLength, 0, 1, coords),
                EncodeNeighbor(hashstringLength, -1, 1, coords),
                EncodeNeighbor(hashstringLength, -1, 0, coords),
                EncodeNeighbor(hashstringLength, -1, -1, coords),
                EncodeNeighbor(hashstringLength, 0, -1, coords),
                EncodeNeighbor(hashstringLength, 1, -1, coords)
            });
        }
Ejemplo n.º 3
0
        public static long EncodeNeighborInt(int neighborLatDir, int neighborLonDir, GeohashDecodeResult coords, int bitDepth)
        {
            var neighborLat = coords.Coordinates.Lat + neighborLatDir * coords.Error.Lat;
            var neighborLon = coords.Coordinates.Lon + neighborLonDir * coords.Error.Lon;

            return(EncodeInt(neighborLat, neighborLon, bitDepth));
        }
Ejemplo n.º 4
0
        public static string EncodeNeighbor(int hashstringLength, int neighborLatDir, int neighborLonDir,
                                            GeohashDecodeResult coords)
        {
            var neighborLat = coords.Coordinates.Lat + neighborLatDir * coords.Error.Lat;
            var neighborLon = coords.Coordinates.Lon + neighborLonDir * coords.Error.Lon;

            return(Encode(neighborLat, neighborLon, hashstringLength));
        }
Ejemplo n.º 5
0
        /**
         * Neighbors Integer
         *
         * Returns all neighbors' hash integers clockwise from north around to northwest
         * 7 0 1
         * 6 x 2
         * 5 4 3
         * @param {long} hashInt
         * @param {int} bitDepth
         * @returns {EncodeInt'd neighborHashIntList|long[]}
         */
        public static long[] NeighborsInt(long hashInt, int bitDepth = 52)
        {
            var lonlat = DecodeInt(hashInt, bitDepth);
            var coords = new GeohashDecodeResult
            {
                Coordinates = lonlat.Coordinates,
                Error = new Coordinates
                {
                    Lat = lonlat.Error.Lat*2,
                    Lon = lonlat.Error.Lon*2
                }
            };

            return new[]
            {
                EncodeNeighborInt(1, 0, coords, bitDepth),
                EncodeNeighborInt(1, 1, coords, bitDepth),
                EncodeNeighborInt(0, 1, coords, bitDepth),
                EncodeNeighborInt(-1, 1, coords, bitDepth),
                EncodeNeighborInt(-1, 0, coords, bitDepth),
                EncodeNeighborInt(-1, -1, coords, bitDepth),
                EncodeNeighborInt(0, -1, coords, bitDepth),
                EncodeNeighborInt(1, -1, coords, bitDepth)
            };
        }
Ejemplo n.º 6
0
        /**
         * Neighbors
         *
         * Returns all neighbors' hashstrings clockwise from north around to northwest
         * 7 0 1
         * 6 x 2
         * 5 4 3
         * @param {string} hashString
         * @returns {encoded neighborHashList|string[]}
         */
        public static string[] Neighbors(string hashString)
        {
            var hashstringLength = hashString.Count();

            var lonlat = Decode(hashString);

            var coords = new GeohashDecodeResult
            {
                Coordinates = lonlat.Coordinates,
                Error = new Coordinates
                {
                    Lat = lonlat.Error.Lat*2,
                    Lon = lonlat.Error.Lon*2
                }

            };

            return new[]
            {
                EncodeNeighbor(hashstringLength, 1, 0, coords),
                EncodeNeighbor(hashstringLength, 1, 1, coords),
                EncodeNeighbor(hashstringLength, 0, 1, coords),
                EncodeNeighbor(hashstringLength, -1, 1, coords),
                EncodeNeighbor(hashstringLength, -1, 0, coords),
                EncodeNeighbor(hashstringLength, -1, -1, coords),
                EncodeNeighbor(hashstringLength, 0, -1, coords),
                EncodeNeighbor(hashstringLength, 1, -1, coords)
            };
        }
Ejemplo n.º 7
0
 public static long EncodeNeighborInt(int neighborLatDir, int neighborLonDir, GeohashDecodeResult coords, int bitDepth)
 {
     var neighborLat = coords.Coordinates.Lat + neighborLatDir*coords.Error.Lat;
     var neighborLon = coords.Coordinates.Lon + neighborLonDir*coords.Error.Lon;
     return EncodeInt(neighborLat, neighborLon, bitDepth);
 }
Ejemplo n.º 8
0
 public static string EncodeNeighbor(int hashstringLength, int neighborLatDir, int neighborLonDir, GeohashDecodeResult coords)
 {
     var neighborLat = coords.Coordinates.Lat + neighborLatDir*coords.Error.Lat;
     var neighborLon = coords.Coordinates.Lon + neighborLonDir*coords.Error.Lon;
     return Encode(neighborLat, neighborLon, hashstringLength);
 }