コード例 #1
0
        public List <BingMaps> SearchByLatLonList()
        {
            List <BingMaps> results = new List <BingMaps>();

            if (string.IsNullOrWhiteSpace(this.IncludeEntityTypes))
            {
                this.IncludeEntityTypes = "";
            }

            BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString());

            BingResult res = Bing.SearchByPoint(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.IncludeEntityTypes);

            if (res == null || res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1)
            {
                return(results);
            }

            foreach (Resource resource in res.resourceSets[0].resources)
            {
                BingMaps map = new BingMaps();
                MapBingMaps(map, resource);
                map.Lat = this.Lat;
                map.Lon = this.Lon;
                map.IncludeEntityTypes = this.IncludeEntityTypes;
                map.EstimatedTotal     = res.resourceSets[0].estimatedTotal;
                map.ResultStatus       = "OK";
                results.Add(map);
            }

            return(results);
        }
コード例 #2
0
        public BingMaps SearchByLatLonRead()
        {
            if (string.IsNullOrWhiteSpace(this.IncludeEntityTypes))
            {
                this.IncludeEntityTypes = "";
            }

            BingMapsHelper Bing = new BingMapsHelper(ServiceConfiguration["BingMapsKey"].ToString());


            //decimal.Round(decimal.Parse(this.Lat), 5, MidpointRounding.AwayFromZero).ToString();

            //decimal.Parse(this.Lat).ToString("#.#####");

            BingResult res = Bing.SearchByPoint(decimal.Parse(this.Lat).ToString(_decimalFormat), decimal.Parse(this.Lon).ToString(_decimalFormat), this.IncludeEntityTypes);

//            BingResult res = Bing.SearchByPoint(this.Lat.ToString(), this.Lon.ToString(), this.IncludeEntityTypes);

            if (res == null)
            {
                this.ResultStatus  = "Error";
                this.ResultMessage = "Failed to download and deserialize result";
            }

            if (res.resourceSets == null || res.resourceSets.Count() < 1 || res.resourceSets[0].resources == null || res.resourceSets[0].resources.Count() < 1)
            {
                this.ResultStatus  = "OK";
                this.ResultMessage = "No results";
            }

            Resource resource = res.resourceSets[0].resources[0];

            MapBingMaps(this, resource);
            this.EstimatedTotal = res.resourceSets[0].estimatedTotal;
            this.ResultStatus   = "OK";

            return(this);
        }