示例#1
0
        int GeohashDecodeToLongLatType(GeoHashBits hash, double[] xy)
        {
            GeoHashArea area = new GeoHashArea();

            if (GeohashDecodeType(hash, area) == 0)
            {
                return(0);
            }
            return(GeohashDecodeAreaToLongLat(area, xy));
        }
示例#2
0
 int GeohashDecodeAreaToLongLat(GeoHashArea area, double[] xy)
 {
     xy[0] = (area.Longitude.Min + area.Longitude.Max) / 2;
     xy[1] = (area.Latitude.Min + area.Latitude.Max) / 2;
     return(1);
 }
示例#3
0
 int GeohashDecodeType(GeoHashBits hash, GeoHashArea area)
 {
     GeoHashRange[] r = new GeoHashRange[2];
     GeohashGetCoordRange(ref r[0], ref r[1]);
     return(GeohashDecode(r[0], r[1], hash, area));
 }
示例#4
0
 int GeohashDecodeWgs84(GeoHashBits hash, GeoHashArea area)
 {
     return(GeohashDecodeType(hash, area));
 }
示例#5
0
        int GeohashDecode(GeoHashRange longRange, GeoHashRange latRange, GeoHashBits hash, GeoHashArea area)
        {
            if (Hashiszero(hash) || Rangeiszero(latRange) ||
                Rangeiszero(longRange))
            {
                return(0);
            }

            area.Hash = hash;
            ushort step    = hash.Step;
            ulong  hashSep = Deinterleave64(hash.Bits); /* hash = [LAT][LONG] */

            double latScale  = latRange.Max - latRange.Min;
            double longScale = longRange.Max - longRange.Min;

            ulong ilato = hashSep;       /* get lat part of deinterleaved hash */
            ulong ilono = hashSep >> 32; /* shift over to get long part of hash */

            /* divide by 2**step.
             * Then, for 0-1 coordinate, multiply times scale and add
             * to the min to get the absolute coordinate. */
            area.Latitude.Min =
                latRange.Min + (ilato * 1.0 / (1ul << step)) * latScale;
            area.Latitude.Max =
                latRange.Min + ((ilato + 1) * 1.0 / (1ul << step)) * latScale;
            area.Longitude.Min =
                longRange.Min + (ilono * 1.0 / (1ul << step)) * longScale;
            area.Longitude.Max =
                longRange.Min + ((ilono + 1) * 1.0 / (1ul << step)) * longScale;

            return(1);
        }