当前位置: 首页>>代码示例>>C#>>正文


C# GeoCoordinate.ToGeoHash方法代码示例

本文整理汇总了C#中GeoCoordinate.ToGeoHash方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinate.ToGeoHash方法的具体用法?C# GeoCoordinate.ToGeoHash怎么用?C# GeoCoordinate.ToGeoHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeoCoordinate的用法示例。


在下文中一共展示了GeoCoordinate.ToGeoHash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToGeoHashTest2

        public void ToGeoHashTest2()
        {
            var geo01       = new GeoCoordinate(new Latitude(38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("dqcjr0bp7n74cjbuqqub", geo01hash.Value);
            Assert.AreEqual(2590713666U,            geo01hash32.Value);
            Assert.AreEqual(11127030471626460554UL, geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(3);
            var geo01rev32  = geo01hash.ToGeoCoordinate(3);
            var geo01rev64  = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
开发者ID:Vanaheimr,项目名称:Aegir,代码行数:30,代码来源:GeoPositionTests.cs

示例2: ToGeoHashTest3

        public void ToGeoHashTest3()
        {
            var geo01       = new GeoCoordinate(new Latitude(-38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("6314xp00e1ej140gw3hz", geo01hash.Value);
            Assert.AreEqual(817991144U,             geo01hash32.Value);
            Assert.AreEqual(3513245211907368736UL,  geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(3);
            var geo01rev32  = geo01hash.ToGeoCoordinate(3);
            var geo01rev64  = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
开发者ID:Vanaheimr,项目名称:Aegir,代码行数:30,代码来源:GeoPositionTests.cs

示例3: ToGeoHashTest1

        public void ToGeoHashTest1()
        {
            var geo01       = new GeoCoordinate(new Latitude(57.64911), new Longitude(10.40744));
            var geo01hash   = geo01.ToGeoHash(11);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("u4pruydqqvj",          geo01hash.Value);
            Assert.AreEqual(3793206966U,            geo01hash32.Value);
            Assert.AreEqual(16291699867698975045UL, geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(5);
            var geo01rev32  = geo01hash.ToGeoCoordinate(5);
            var geo01rev64  = geo01hash.ToGeoCoordinate(5);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
开发者ID:Vanaheimr,项目名称:Aegir,代码行数:30,代码来源:GeoPositionTests.cs


注:本文中的GeoCoordinate.ToGeoHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。