public GooglePlacesModel NearbySearch(string locationType, double latitude, double longitude, int radius)
        {
            //Init Model
            GooglePlacesModel model = new GooglePlacesModel();

            if(radius <= 0 || radius > 5000)
            {
                model.Status = "RADIUS_OUT_OF_RANGE";
                return model;
            }

            //generate API string
            string ApiUrl = GooglePlacesApiGenerator.NearbySearchApiString(latitude, longitude, radius, locationType);

            //Do request task + bind model
            HttpClient httpClient = new HttpClient();
            Task task = httpClient.GetAsync(ApiUrl).ContinueWith(taskResponse => {
                HttpResponseMessage response = taskResponse.Result;
                if (response.IsSuccessStatusCode)
                {
                    Task<GooglePlacesModel> readTask = response.Content.ReadAsAsync<GooglePlacesModel>();
                    readTask.Wait();
                    model = readTask.Result;
                }
                else
                {
                    model.Status = "UNSUCCESSFUL_STATUS_CODE";
                }
            });

            task.Wait();

            return model;
        }
        public CrimeLocationModel(GooglePlacesModel.PlaceModel placeModel, DataPoliceUkModel dataPoliceUkModel)
        {
            this.Location = new LocationModel(placeModel);
            this.Crimes = new List<CrimeModel>();

            foreach (var crimeReportModel in dataPoliceUkModel.CrimeModels)
            {
                this.Crimes.Add(new CrimeModel(crimeReportModel));
            }
            this.Badge = CreateCrimeLocationBadge(this.Crimes);
        }
Пример #3
0
 public LocationModel(GooglePlacesModel.PlaceModel placeModel)
 {
     this.Name = placeModel.Name;
     this.Latitude = placeModel.Geometry.Location.Latitude;
     this.Longitude = placeModel.Geometry.Location.Longitude;
 }