Example #1
0
        public async System.Threading.Tasks.Task Should_Get_Hashes_For_PolygonAsync()
        {
            var hasher = new Geohasher();

            var geometryFactory = new GeometryFactory();

            var p1 = new Coordinate()
            {
                X = 9.612350463867186, Y = 52.31141727938367
            };
            var p2 = new Coordinate()
            {
                X = 9.914474487304686, Y = 52.31141727938367
            };
            var p3 = new Coordinate()
            {
                X = 9.914474487304686, Y = 52.42252295423907
            };
            var p4 = new Coordinate()
            {
                X = 9.612350463867186, Y = 52.42252295423907
            };

            var polygon = geometryFactory.CreatePolygon(new[] { p1, p2, p3, p4, p1 });

            var result = await hasher.GetHashesAsync(polygon, 6);

            Assert.AreEqual(486, result.Count);
        }
Example #2
0
        public static Task <List <string> > GenerateCoveringGeohashes(this Geohasher hasher, GeoJsonPolygon <GeoJson2DGeographicCoordinates> polygon, int precision = 4)
        {
            var outerRing = new NetTopologySuite.Geometries.LinearRing(
                (from coord in polygon.Coordinates.Exterior.Positions
                 select new NetTopologySuite.Geometries.Coordinate(coord.Latitude, coord.Longitude)).ToArray()
                );
            var p = new NetTopologySuite.Geometries.Polygon(outerRing);

            return(hasher.GetHashesAsync(p, precision, Mode.Intersect));
        }
Example #3
0
        public async System.Threading.Tasks.Task Should_Get_Hashes_For_PolygonAsync_IntersectMode()
        {
            var hasher = new Geohasher();

            var geometryFactory = new GeometryFactory();

            var progess = new Progress <HashingProgress>();

            progess.ProgressChanged += (e, hp) =>
            {
                Debug.WriteLine($"Processed: {hp.HashesProcessed}, Queued: {hp.QueueSize}, Running Since: {hp.RunningSince}");
            };

            Polygon polygon = GetTestPolygon(geometryFactory);

            var result = await hasher.GetHashesAsync(polygon, 4, mode : Mode.Intersect, progress : progess);

            Assert.AreEqual(183, result.Count);
        }
Example #4
0
        private void btnGenerateGeohash_Click(object sender, EventArgs e)
        {
            var hasher = new Geohasher();

            var     geometryFactory = new GeometryFactory();
            Polygon polygon         = GetTestPolygon(geometryFactory);

            List <string> res = hasher.GetHashesAsync(polygon).Result;

            MessageBox.Show(res[0], "Test1");


            //Task<List<string>> inner_polygon = Should_Get_Hashes_For_PolygonAsync_LongRunning();
            //List<string> inner_polygon_Loaded =  inner_polygon.Result;

            //string[] arr_result = inner_polygon_Loaded.ToArray();
            //MessageBox.Show(arr_result[0], "sss");
            int a = 3;
        }
Example #5
0
        public async System.Threading.Tasks.Task <List <string> > Should_Get_Hashes_For_PolygonAsync_LongRunning()
        {
            var hasher = new Geohasher();

            var geometryFactory = new GeometryFactory();

            var progess = new Progress <HashingProgress>();

            progess.ProgressChanged += (e, hp) =>
            {
                Debug.WriteLine($"Processed: {hp.HashesProcessed}, Queued: {hp.QueueSize}, Running Since: {hp.RunningSince}");
            };

            Polygon polygon = GetTestPolygon(geometryFactory);

//            var result = await hasher.GetHashesAsync(polygon, 4, mode: Mode.Contains, progress: progess);
            var result = await hasher.GetHashesAsync(polygon, 1, mode : Mode.Contains);

            //var result = await hasher.GetHashesAsync(polygon, 4, mode: Mode.Contains);

            return(result);
            //Assert.AreEqual(112, result.Count);
        }