Exemplo n.º 1
0
        private (Location startLocation, Location endLocation) GetOriginAndDestination()
        {
            var client     = ClientCreator.Create();
            var startModel = new GeoCoderModel()
            {
                Address = "杭州市西湖区浙大路38号",
            };
            var startRequest = new GeoCoderRequest(startModel);
            var startTask    = client.ExecuteAsync(startRequest);

            var endModel = new GeoCoderModel()
            {
                Address = "浙江省杭州市拱墅区环城北路318号",
            };
            var endRequest = new GeoCoderRequest(endModel);
            var endTask    = client.ExecuteAsync(endRequest);

            Task.WaitAll(startTask, endTask);

            var startResponse = startTask.Result;
            var endResponse   = endTask.Result;

            var startPoint = startResponse.Result.Location;
            var endPoint   = endResponse.Result.Location;

            return(startPoint, endPoint);
        }
Exemplo n.º 2
0
        public void Test()
        {
            var baiduClient = ClientCreator.Create();
            var model       = new GeoCoderReverseModel()
            {
                Location = "39.915,116.404"
            };
            var req  = new GeoCoderReverseRequest(model);
            var resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
        }
Exemplo n.º 3
0
        public void Test()
        {
            var baiduClient = ClientCreator.Create();
            var model       = new GeoCoderModel()
            {
                Address = "杭州市西湖区浙大路38号",
            };
            var req  = new GeoCoderRequest(model);
            var resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
        }
Exemplo n.º 4
0
        public void Test()
        {
            var client = ClientCreator.Create();
            var model  = new IPModel()
            {
                //IP = "183.134.216.113"
            };
            var req  = new IPLocationRequest(model);
            var resp = client.Execute(req);

            resp.Address.ShouldNotBeNull();
            resp.Content.ShouldNotBeNull();
        }
Exemplo n.º 5
0
        public void Test()
        {
            var baiduClient = ClientCreator.Create();
            var detailMode  = new PlaceDetailModel()
            {
                Uid = "d5101afd619d12c7f423100e",
            };

            var req = new PlaceDetailRequest(detailMode);
            PlaceDetailResponse resp = baiduClient.Execute(req);

            resp.Result.ShouldNotBeNull();
        }
Exemplo n.º 6
0
        public void ExecuteRectangeSearch()
        {
            var baiduClient   = ClientCreator.Create();
            var rectangeModel = new PlaceRectangeModel
            {
                Query  = "银行",
                Bounds = "39.915,116.404,39.975,116.414"
            };
            var req = new PlaceSearchRequest <PlaceRectangeModel>(rectangeModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
        }
Exemplo n.º 7
0
        public void Test()
        {
            var client = ClientCreator.Create();
            var model  = new PlaceSuggestionModel()
            {
                Query  = "浙江大学",
                Region = "杭州"
            };
            var req = new PlaceSuggestionRequest(model);
            var res = client.Execute(req);

            res.Status.ShouldBe(0);
            res.Result.ShouldNotBeNull();
        }
Exemplo n.º 8
0
        public void Test()
        {
            var client = ClientCreator.Create();

            var model = new CoordTransfModel
            {
                Coords = "114.21892734521,29.575429778924"
            };

            var req  = new CoordTransformRequest(model);
            var resp = client.Execute(req);

            resp.Status.ShouldBe(0);
        }
Exemplo n.º 9
0
        public void ExecuteCircumSearch()
        {
            var baiduClient = ClientCreator.Create();
            var circumModel = new PlaceCircumModel
            {
                Query    = "银行",
                Location = "39.915,116.404",
                Radius   = "2000"
            };
            var req = new PlaceSearchRequest <PlaceCircumModel>(circumModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
        }
Exemplo n.º 10
0
        public void ExecuteRegionSearch()
        {
            var baiduClient = ClientCreator.Create();
            var regionModel = new PlaceRegionModel
            {
                Query  = "ATM机",
                Tag    = "银行",
                Region = "杭州"
            };
            var req = new PlaceSearchRequest <PlaceRegionModel>(regionModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
            resp.Results.Count.ShouldBe(10);
        }
Exemplo n.º 11
0
        public void PublicTest()
        {
            var originAndDestionation = GetOriginAndDestination();
            var startPoint            = originAndDestionation.startLocation;
            var endPoint = originAndDestionation.endLocation;

            var model = new PublicPlanModel()
            {
                Origin      = $"{startPoint.Lat},{startPoint.Lng}",
                Destination = $"{endPoint.Lat},{endPoint.Lng}"
            };

            var req    = new PublicPlanRequest(model);
            var client = ClientCreator.Create();
            var result = client.Execute(req);

            result.Status.ShouldBe(0);
        }