public IEnumerable <string> asearch_test(double lon, double lan) { var address = "منطقة اللاذقية" + "," + "اللاذقية"; // string s_address = "," + "اللاذقية"; var locationService = new GoogleLocationService(); // GoogleMaps.LocationServices.GoogleLocationService r = locationService.GetRegionFromLatLong(lat, lon); // LocationServices r = new GoogleMaps.LocationServices(); // r= locationService.GetRegionFromLatLong(lat, lon); var g = new GeocodingRequest(); var address_gps = g.Address = address; // g.Region = r.Name; g.Sensor = false; g.Language = "ar"; var response = new GeocodingService().GetResponse(g); var point = locationService.GetLatLongFromAddress(address); AddressData a = locationService.GetAddressFromLatLang(lon, lan); // Directions dir= locationService.GetDirections(point.Latitude, point.Longitude); var s = _ClassifyService.search_test(lon.ToString() + "," + lan.ToString()); //yield return response.Results[0].PlaceId; return(s); // yield return locationService.GetAddressFromLatLang(5 , lon).Address; // return "s"; // return _ClassifyService.search_test(town); }
public ActionResult Create(EnderecoViewModel end) { if (ModelState.IsValid) { var addr = end.ToEndereco(); var latlng = GeocodingService.obterCoordenadas(addr); addr.Latitude = latlng.Latitude; addr.Longitude = latlng.Longitude; var addrId = _enderecoService.SalvarEndereco(addr); var estacao = new Estacao { Endereco = _enderecoService.ObterPorId(addrId), Latitude = latlng.Latitude, Longitude = latlng.Longitude }; _estacaoService.SalvarEstacao(estacao); return(RedirectToAction("Index")); } else { return(View(end)); } }
static void README_QuickStart_Sample1() { //always need to use AIzaSyDyrcySjhH_JOpJ9461agf8vkyJbvkmD_k for requests. Do this in App_Start. GoogleSigned.AssignAllServices(new GoogleSigned("AIzaSyDyrcySjhH_JOpJ9461agf8vkyJbvkmD_k")); var request = new GeocodingRequest(); request.Address = "1600 Pennsylvania Ave NW, Washington, DC 20500"; var response = new GeocodingService().GetResponse(request); //The GeocodingService class submits the request to the API web service, and returns the //response strongly typed as a GeocodeResponse object which may contain zero, one or more results. //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); Console.WriteLine("Full Address: " + result.FormattedAddress); // "1600 Pennsylvania Ave NW, Washington, DC 20500, USA" Console.WriteLine("Latitude: " + result.Geometry.Location.Latitude); // 38.8976633 Console.WriteLine("Longitude: " + result.Geometry.Location.Longitude); // -77.0365739 Console.WriteLine(); } else { Console.WriteLine("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } }
public ActionResult <ExpandoObject> TestMaps() { //always need to use YOUR_API_KEY for requests. Do this in App_Start. //GoogleSigned.AssignAllServices(new GoogleSigned("AIzaSyBrQ-Pb3As0dKkt1iPsxL9IOr-Nfk3E1Cc")); var request = new GeocodingRequest(); request.Address = "San Isidro de El Guarco, Cartago"; var response = new GeocodingService().GetResponse(request); //The GeocodingService class submits the request to the API web service, and returns the //response strongly typed as a GeocodeResponse object which may contain zero, one or more results. dynamic data = new ExpandoObject(); //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); //Console.WriteLine("Full Address: " + result.FormattedAddress); // "1600 Pennsylvania Ave NW, Washington, DC 20500, USA" data.fullAddress = result.FormattedAddress; //Console.WriteLine("Latitude: " + result.Geometry.Location.Latitude); // 38.8976633 data.latitude = result.Geometry.Location.Latitude; //Console.WriteLine("Longitude: " + result.Geometry.Location.Longitude); // -77.0365739 data.longitude = result.Geometry.Location.Longitude; //Console.WriteLine(); return(data); } else { return(StatusCode(StatusCodes.Status409Conflict)); //Console.WriteLine("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } }
public void Geocode_With_AddressComponent_Locking() { var requestGB = new GeocodingRequest { Address = "Boston", Components = "country:GB" }; var requestUS = new GeocodingRequest { Address = "Boston", Components = "country:US" }; var responseGB = new GeocodingService(Credentials.None).Geocode(requestGB); var responseUS = new GeocodingService(Credentials.None).Geocode(requestUS); Assert.AreEqual(ServiceResponseStatus.Ok, responseGB.Status); Assert.AreEqual(ServiceResponseStatus.Ok, responseUS.Status); foreach (var r in responseGB.Results) { Assert.IsTrue(r.FormattedAddress.EndsWith("UK"), r.FormattedAddress + " <- Should be in UK"); } foreach (var r in responseUS.Results) { Assert.IsTrue(r.FormattedAddress.EndsWith("USA"), r.FormattedAddress + " <- Should be in USA"); } }
// the private function that does all the 'hard work' for querying address private string getAddressPartByType(string i_Address, AddressType i_AddressType) { string addressPart = string.Empty; var request = new GeocodingRequest(); request.Address = i_Address; request.Sensor = "false"; var response = GeocodingService.GetResponse(request); if (response.Status == ServiceResponseStatus.Ok) { var components = response.Results[0].Components; foreach (AddressComponent addressComponent in components) { foreach (AddressType addressType in addressComponent.Types) { if (addressType == i_AddressType) { addressPart = addressComponent.LongName; } } } } return(addressPart); }
public void GetGeocodingForCoordinates() { // expectations var expectedStatus = ServiceResponseStatus.Ok; var expectedResultCount = 9; var expectedTypes = new AddressType[] { AddressType.StreetAddress, AddressType.Locality, AddressType.PostalCode, AddressType.Sublocality, AddressType.AdministrativeAreaLevel2, AddressType.AdministrativeAreaLevel1, AddressType.Country, AddressType.Political }; var expectedFormattedAddress = "277 Bedford Ave, Brooklyn, NY 11211, USA"; var expectedComponentTypes = new AddressType[] { AddressType.StreetNumber, AddressType.Route, AddressType.Locality, AddressType.AdministrativeAreaLevel1, AddressType.AdministrativeAreaLevel2, AddressType.Sublocality, AddressType.Country, AddressType.PostalCode, AddressType.Political }; var expectedLatitude = 40.7142330m; var expectedLongitude = -73.9612910m; var expectedLocationType = LocationType.Rooftop; var expectedSouthwestLatitude = 40.7110854m; var expectedSouthwestLongitude = -73.9644386m; var expectedNortheastLatitude = 40.7173806m; var expectedNortheastLongitude = -73.9581434m; // test var request = new GeocodingRequest(); request.LatitudeLongitude = "40.714224,-73.961452"; request.Sensor = "false"; var response = GeocodingService.GetResponse(request); // asserts Assert.AreEqual(expectedStatus, response.Status, "Status"); Assert.AreEqual(expectedResultCount, response.Results.Length, "ResultCount"); Assert.IsTrue( expectedTypes.OrderBy(x => x).SequenceEqual( response.Results.SelectMany(y => y.Types).Distinct().OrderBy(z => z))); Assert.AreEqual(expectedFormattedAddress, response.Results.First().FormattedAddress, "FormattedAddress"); Assert.IsTrue( expectedComponentTypes.OrderBy(x => x).SequenceEqual( response.Results.First().Components.SelectMany(y => y.Types).Distinct().OrderBy(z => z)), "Types"); Assert.AreEqual(expectedLatitude, response.Results.First().Geometry.Location.Latitude, "Latitude"); Assert.AreEqual(expectedLongitude, response.Results.First().Geometry.Location.Longitude, "Longitude"); Assert.AreEqual(expectedLocationType, response.Results.First().Geometry.LocationType, "LocationType"); Assert.AreEqual(expectedSouthwestLatitude, response.Results.First().Geometry.Viewport.Southwest.Latitude, "Southwest.Latitude"); Assert.AreEqual(expectedSouthwestLongitude, response.Results.First().Geometry.Viewport.Southwest.Longitude, "Southwest.Longitude"); Assert.AreEqual(expectedNortheastLatitude, response.Results.First().Geometry.Viewport.Northeast.Latitude, "Northeast.Latitude"); Assert.AreEqual(expectedNortheastLongitude, response.Results.First().Geometry.Viewport.Northeast.Longitude, "Northeast.Longitude"); }
static void DoGeocodeRequest() { //always need to use YOUR_API_KEY for requests. Do this in App_Start. //GoogleSigned.AssignAllServices(new GoogleSigned("YOUR_API_KEY")); //commented out in the loop Console.WriteLine(); Console.WriteLine("Enter an address to geocode: "); string geocodeAddress = Console.ReadLine(); var request = new GeocodingRequest(); request.Address = geocodeAddress; var response = new GeocodingService().GetResponse(request); //The GeocodingService class submits the request to the API web service, and returns the //response strongly typed as a GeocodeResponse object which may contain zero, one or more results. //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); Console.WriteLine("Full Address: " + result.FormattedAddress); // "1600 Pennsylvania Ave NW, Washington, DC 20500, USA" Console.WriteLine("Latitude: " + result.Geometry.Location.Latitude); // 38.8976633 Console.WriteLine("Longitude: " + result.Geometry.Location.Longitude); // -77.0365739 Console.WriteLine(); } else { Console.WriteLine("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } }
protected virtual GeocodingGeometryLocation GetGeolocation(Item item) { var address = string.Format( "{0} {1}, {2}, {3}, {4}", item.Fields["Address"], item.Fields["Address2"], item.Fields["City"], item.Fields["State"], item.Fields["PostalCode"]); var geocoder = new GeocodingService(new NoAuthentication(), false); var result = geocoder.LookupByAddress(address); if (result.Status != GeocodingStatusCode.Ok || result.Results == null) { return(null); } var location = result.Results.FirstOrDefault(); if (location == null || location.Geometry == null || location.Geometry.Location == null) { return(null); } return(location.Geometry.Location); }
public static void Main(string[] args) { GeocodingService geoCodingService = new GeocodingService(); LocationInfo locationInfo = geoCodingService.Geocode("150 GRANDVIEW WAY MISSOULA MT"); PublicHousingAuthorityInfoService phaiService = new PublicHousingAuthorityInfoService(); PublicHousingAuthorityInfo info = phaiService.GetPublicHousingAuthorityInfo(locationInfo.City, locationInfo.State); //FairMarketRentService service = new FairMarketRentService(); //service.GetFairMarketRent("King County", "WA", 3); // Geocode an address // ... // Use this to get fair market value // ... //GeocodeGoogleAddress("150 GRANDVIEW WAY MISSOULA MT"); //Esri.ArcGISRuntime.Layers. /* * while(true) * { * HudServiceExample(); * } * */ //http://services.arcgis.com/VTyQ9soqVukalItT/ArcGIS/rest/services/MultiFamilyProperties/FeatureServer/0/query?where=LAT=46.815616+AND+LON=-114.02801&outFields=*1 }
public Game(int screenWidth, int screenHeight) : base(screenWidth, screenHeight, GraphicsMode.Default, "OpenTK Quick Start Sample") { touchDeltaCount = 5; touchXDeltas = new double[touchDeltaCount]; touchYDeltas = new double[touchDeltaCount]; pool = new MapPool(20, new int[] { screenWidth, screenHeight }); screenDimensions = new int[] { screenWidth, screenHeight }; GeocodingRequest req = new GeocodingRequest(); req.Address = "215 Keenan Hall Notre Dame, IN 46556"; req.Sensor = false; var resp = new GeocodingService().GetResponse(req); var result = resp.Results[0]; var loc = result.Geometry.Location; setLL(loc.Latitude, loc.Longitude); VSync = VSyncMode.On; Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(handleTouchDown); Mouse.ButtonUp += new EventHandler <MouseButtonEventArgs>(handleTouchUp); Mouse.WheelChanged += new EventHandler <MouseWheelEventArgs>(handleTouchZoom); Mouse.Move += new EventHandler <MouseMoveEventArgs>(handleTouchMove); }
public LocationDto GetLocalization(DataDto dto) { IConfigurationSection googleMapsSection = _configuration.GetSection("Integrations:Google"); var apiKey = googleMapsSection["ApiKey"]; GoogleSigned.AssignAllServices(new GoogleSigned(apiKey)); var request = new GeocodingRequest { Address = dto.Address }; var response = new GeocodingService().GetResponse(request); var result = response.Results.FirstOrDefault(); if (result != null) { return(new LocationDto { Latitude = result.Geometry.Location.Latitude, Longitude = result.Geometry.Location.Longitude }); } return(null); }
public string GetCoordinates(ref string longitude, ref string latitude, string addressFrom) { string google_api_key = System.Configuration.ConfigurationManager.AppSettings["google_api_key"]; try { GoogleSigned.AssignAllServices(new GoogleSigned(google_api_key)); var request = new GeocodingRequest(); request.Address = addressFrom; var response = new GeocodingService().GetResponse(request); //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); longitude = result.Geometry.Location.Longitude.ToString(); latitude = result.Geometry.Location.Latitude.ToString(); return("success"); } else { throw new System.ArgumentException(); } } catch (Exception ex) { string strError = ""; strError = "No Longitude/Latitude Found for " + addressFrom + ". Please enter a valid City, State."; return(strError); } }
public static Evenement GetCoordonnees(String adresse) { var request = new GeocodingRequest(); request.Address = adresse; var response = new GeocodingService().GetResponse(request); //The GeocodingService class submits the request to the API web service, and returns the //response strongly typed as a GeocodeResponse object which may contain zero, one or more results. Evenement depart = new Evenement(); depart.EVENT_NAME = "Point de départ"; //Assuming we received at least one result, let's get some of its properties: if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); depart.LATITUDE = result.Geometry.Location.Latitude; depart.LONGITUDE = result.Geometry.Location.Longitude; depart.ADRESSE = result.FormattedAddress; } else { depart.ADRESSE = String.Format("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } return(depart); }
public void CanLookupByAddress() { var service = new GeocodingService(new NoAuthentication(), false); var result = service.LookupByAddress("10801 Mastin Blvd, Overland Park, KS"); result.Results.Should().NotBeEmpty(); }
static LocationDetails GetLocationDetails(String postcode) { LocationDetails locationDetails = new LocationDetails(); GoogleSigned.AssignAllServices(new GoogleSigned("APIKEY")); // APIKEY van Google hier zetten var request = new GeocodingRequest(); request.Address = postcode; { var response = new GeocodingService().GetResponse(request); if (response.Status == ServiceResponseStatus.OverQueryLimit) { WriteLine("API Quotum Reached"); } if (response.Status == ServiceResponseStatus.Ok && response.Results.Count() > 0) { var result = response.Results.First(); if (result.AddressComponents.Length > 2) { locationDetails = new LocationDetails( result.AddressComponents[0].ShortName, result.AddressComponents[1].LongName, result.AddressComponents[2].LongName, result.Geometry.Location.Longitude, result.Geometry.Location.Latitude, result.PlaceId); Console.WriteLine("Postcode: " + result.AddressComponents[0].LongName + "plaats: " + result.AddressComponents[1].LongName + "regio: " + result.AddressComponents[2].LongName + "," + result.Geometry.Location.Longitude + ", " + result.Geometry.Location.Latitude, result.PlaceId); } else { locationDetails = new LocationDetails( result.AddressComponents[0].ShortName, result.AddressComponents[1].LongName, "", result.Geometry.Location.Longitude, result.Geometry.Location.Latitude, result.PlaceId); Console.WriteLine("Postcode: " + result.AddressComponents[0].LongName + "plaats: " + result.AddressComponents[1].LongName + "," + result.Geometry.Location.Longitude + ", " + result.Geometry.Location.Latitude, result.PlaceId); } } else { Console.WriteLine("Unable to geocode. Status={0} and ErrorMessage={1}", response.Status, response.ErrorMessage); } return(locationDetails); } }
public async Task CanQuerySingle() { GeocodingService.QuerySingle(Guid.NewGuid()).Should().BeEmpty(); var address = await GeocodingService.Geocode("1 Microsoft Way, Redmond, WA 98052, USA"); GeocodingService.QuerySingle(address.Key).Should().HaveCount(1); }
public static GeocodingWrp Geocoding(string address) { GeocodingService geSv = new GeocodingService(); JObject jObj = geSv.Geocoding(address); GeocodingWrp rslt = jObj.ToObject <GeocodingWrp>(); return(rslt); }
public static GeoDecodingServiceWrp GeoDecoding(LocationXY loc) { GeocodingService geSv = new GeocodingService(); JObject jObj = geSv.DeGeocoding(loc.ToString()); GeoDecodingServiceWrp rslt = jObj.ToObject <GeoDecodingServiceWrp>(); return(rslt); }
private static GeocodeResponse Geocoding(string address) { var req = new GeocodingRequest(); req.Address = address; req.Sensor = false; var response = new GeocodingService().GetResponse(req); return(response); }
public StartPage() { InitializeComponent(); map.Center = new LatLng(60.169212, 24.938788); map.DidFinishLoadingStyleCommand = new Command <MapStyle>(HandleStyleLoaded); geocodingService = new GeocodingService(); }
/// <summary> /// sends a geocode request and returns the response /// </summary> /// <param name="address"></param> /// <returns></returns> private GeocodingResponse geocodeRequest(string address) { var request = new GeocodingRequest(); request.Address = address; request.Sensor = "false"; return(GeocodingService.GetResponse(request)); //XmlDocument a = Geocode(addressSearchText.Text); //MessageBox.Show(a.ToString()); }
public ImportController(IEventRepository eventRepository, ILocationRepository locationRepository, IMapper mapper, Starter starter, GeocodingService geocodingService) { _eventRepository = eventRepository; _locationRepository = locationRepository; _mapper = mapper; _starter = starter; _geocodingService = geocodingService; }
private void searchButton_Click(object sender, RoutedEventArgs e) { var request = new GeocodingRequest(); request.Address = searchTextBox.Text; var response = new GeocodingService().GetResponse(request); if (response.Status == ServiceResponseStatus.Ok) { resultsTreeView.ItemsSource = response.Results.ToTree(); } }
public override IRow Transform(IRow row) { var request = new GeocodingRequest { Address = row[_input].ToString(), Sensor = false, Components = _componentFilter }; try { var response = new GeocodingService().GetResponse(request); switch (response.Status) { case ServiceResponseStatus.Ok: var first = response.Results.First(); foreach (var field in _output) { switch (field.Name.ToLower()) { case "lat": case "latitude": row[field] = first.Geometry.Location.Latitude; break; case "lon": case "long": case "longitude": row[field] = first.Geometry.Location.Longitude; break; case "address": case "formattedaddress": if (field.Equals(_input)) { break; } row[field] = first.FormattedAddress; Context.Info(first.FormattedAddress); break; } } break; default: Context.Error("Error from Google MAPS API: " + response.Status); break; } } catch (Exception ex) { Context.Error(ex.Message); } Increment(); return(row); }
public void Geocoding_Request_Signed_With_Private_Key() { var request = new GeocodingRequest { Address = "Stathern, UK" }; GoogleSigned.AssignAllServices(GetRealSigningInstance()); var response = new GeocodingService().GetResponse(request); Assert.AreEqual(ServiceResponseStatus.Ok, response.Status); }
public GeocodingServiceTests() { var mapperConfiguration = new MapperConfiguration(cfg => { cfg.AddProfile(new GeocodingMappingProfile()); }); _messageHandler = new TestableHttpMessageHandler(); _logMock = new Mock <ILogger>(); GeocodingService.Client = new HttpClient(_messageHandler) { BaseAddress = new Uri("https://fake.api.uri/") }; _service = new GeocodingService(_logMock.Object, mapperConfiguration.CreateMapper()); }
public void Funny_Polish_Address() { var request = new GeocodingRequest { Address = "AL. GRUNWALDZKA 141, Gdańsk, 80 - 264, POLAND" }; var response = new GeocodingService(Credentials.None).Geocode(request); Assert.AreEqual(ServiceResponseStatus.Ok, response.Status); Assert.AreEqual(LocationType.Rooftop, response.Results[0].Geometry.LocationType); Assert.AreEqual("Gdańsk", response.Results[0].Components[3].LongName); }
public void GeocodeResult_Has_BoundsProperty() { var request = new GeocodingRequest { Address = "Boston" }; var response = new GeocodingService(Credentials.None).Geocode(request); Assert.IsNotNull(response.Results[0].Geometry.Bounds); Assert.IsNotNull(response.Results[0].Geometry.Bounds.Southwest); Assert.IsNotNull(response.Results[0].Geometry.Bounds.Northeast); }
public point getPoint() { if (p == null) { var request = new GeocodingRequest(); request.Address = this.address + ", IN"; request.Sensor = false; var response = new GeocodingService().GetResponse(request); var result = response.Results.First(); p = new point(result.Geometry.Location.Longitude, result.Geometry.Location.Latitude); } return(p); }