public Map<Store, Double> findStoresByAddress(Address searchAddress, double distance) { Map<Store, Double> matchingStores = new HashMap<Store, Double>(); for (Store store : readAllStores()) { Double storeDistance = findStoreDistance(store, Integer.parseInt(searchAddress.getPostalCode())); if (storeDistance != null && storeDistance <= distance) { matchingStores.put(store, storeDistance); } } return matchingStores; }
protected boolean addressesContentsAreEqual(Address address1, Address address2) { return address1 != null && address2 != null && Objects.equals(address2.getAddressLine1(), address1.getAddressLine1()) && Objects.equals(address2.getAddressLine2(), address1.getAddressLine2()) && Objects.equals(address2.getCity(), address1.getCity()) && Objects.equals(address2.getStateProvinceRegion(), address1.getStateProvinceRegion()) && Objects.equals(address2.getPostalCode(), address1.getPostalCode()) && Objects.equals(address2.getIsoCountryAlpha2(), address1.getIsoCountryAlpha2()) && Objects.equals(address2.getIsoCountrySubdivision(), address1.getIsoCountrySubdivision()); } }
Double postalCodeRate = lookupPostalCodeRate(itemPostalCodeTaxRateMap, address.getPostalCode()); if (postalCodeRate != null) { return BigDecimal.valueOf(postalCodeRate);
Address address = fulfillmentGroup.getAddress(); if (address != null) { Double postalCodeRate = lookupPostalCodeRate(fulfillmentGroupPostalCodeTaxRateMap, address.getPostalCode()); if (postalCodeRate != null) { return BigDecimal.valueOf(postalCodeRate);
.addressCityLocality(fgAddress.getCity()) .addressStateRegion(stateAbbr) .addressPostalCode(fgAddress.getPostalCode()) .addressCountryCode(countryAbbr) .addressPhone(phone)
.addressCityLocality(billAddress.getCity()) .addressStateRegion(stateAbbr) .addressPostalCode(billAddress.getPostalCode()) .addressCountryCode(countryAbbr) .addressPhone(phone)
dest.setIsoCountrySubdivision(orig.getIsoCountrySubdivision()); dest.setStateProvinceRegion(orig.getStateProvinceRegion()); dest.setPostalCode(orig.getPostalCode()); dest.setZipFour(orig.getZipFour()); dest.setCountry(orig.getCountry());
add = add + "\n" + obj.getCountryCode(); add = add + "\n" + obj.getAdminArea(); add = add + "\n" + obj.getPostalCode(); add = add + "\n" + obj.getSubAdminArea(); add = add + "\n" + obj.getLocality();
add = add + "\n" + obj.getCountryCode(); add = add + "\n" + obj.getAdminArea(); add = add + "\n" + obj.getPostalCode(); add = add + "\n" + obj.getSubAdminArea(); add = add + "\n" + obj.getLocality();
Geocoder geocoder = new Geocoder(this, Locale.ENGLISH); List<Address> addresses = null; try { addresses = geocoder.getFromLocation(latitude, longitude, 3); } catch (IOException ex) { //Handle IOException } for (int i = 0; i < addresses.size(); i++) { Address address = addresses.get(i); if (address.getPostalCode() != null) String zipCode = address.getPostalCode(); }
final Geocoder gcd = new Geocoder(getApplicationContext()); List<Address> addresses = gcd.getFromLocation(latitude, longitude, 10); for (Address address : addresses) { if(address.getLocality()!=null && address.getPostalCode()!=null){ Log.d(address.getLocality()); Log.d(address.getPostalCode(); break; } }
List<Address> addressList = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); StringBuilder stringBuilder = new StringBuilder(); if (addressList.size() > 0) { Address address = addressList.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) { stringBuilder.append(address.getAddressLine(i)).append("\n"); stringBuilder.append(address.getLocality()).append("\n"); stringBuilder.append(address.getPostalCode()).append("\n"); stringBuilder.append(address.getCountryName()).append("\n"); } addressString = stringBuilder.toString(); }
Address address=getAddressListFromLatLong(YOUR LATITUDE, YOUR LONGITUDE); String country=address.getCountryName(); String address1=address.getAddressLine(1); Strin address2=address.getAddressLine(2); String postalCode=address.getPostalCode(); public static List<Address> getAddressListFromLatLong(double lat, double lng) { geocoder = new Geocoder(YOUR ACTIVITY.this); List<Address> list = null; try { list = geocoder.getFromLocation(lat, lng, 10); //10 is for results, you can use 1 if you want 1 result only. } catch (Throwable e) { e.printStackTrace(); } return list; }
double latitude = location.getLatitude(); double longitude = location.getLongitude(); Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName());
Geocoder geocoder = new Geocoder(context, Locale.getDefault()); String result = null; try { List<Address> addressList = geocoder.getFromLocation( latitude, longitude, 1); //use your lat, long value here if (addressList != null && addressList.size() > 0) { Address address = addressList.get(0); StringBuilder sb = new StringBuilder(); for (int i = 0; i < address.getMaxAddressLineIndex(); i++){ sb.append(address.getAddressLine(i)).append("\n"); } sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); result = sb.toString(); } } catch (IOException e) { Log.e(TAG, "Unable connect to Geocoder", e); }
Geocoder geocoder = new Geocoder(getActivity(),Locale.ENGLISH); StringBuilder stringBuilder = new StringBuilder(); List<Address> addressList; try { addressList = geocoder.getFromLocation(Latitude, Longitude, 1); if (addressList.size() > 0) { Address address = addressList.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) { stringBuilder.append(address.getAddressLine(i)).append("\n"); stringBuilder.append(address.getLocality()).append("\n"); stringBuilder.append(address.getPostalCode()).append("\n"); stringBuilder.append(address.getCountryName()).append("\n"); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
double latitude = location.getLatitude(); double longitude = location.getLongitude(); Geocoder gc = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); StringBuilder sb = new StringBuilder(); if (addresses.size() > 0) { Address address = addresses.get(0); for (int i = 0; i < address.getMaxAddressLineIndex(); i++) sb.append(address.getAddressLine(i)).append("\n"); sb.append(address.getLocality()).append("\n"); sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName()); }
private void validateCustomerDataInAddress(Address address) throws OrderValidationException { if(StringUtils.isEmpty(address.getFirstName()) || StringUtils.isEmpty(address.getLastName())) { throw new OrderValidationException("Provided address does not contain First and/or Last names"); } if(StringUtils.isEmpty(address.getAddressLine1())){ throw new OrderValidationException("Provided address does not contain address lines"); } if(StringUtils.isEmpty(address.getPostalCode()) || StringUtils.isEmpty(address.getCity())) { throw new OrderValidationException("Provided address does not contain postal code and/or city"); } if(address.getIsoCountryAlpha2() == null) { throw new OrderValidationException("Provided address does not contain valid country code"); } }
GeoPoint location = new GeoPoint(lat, lon); if (location != null) { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = geocoder.getFromLocation(location.getLatitudeE6()/1E6, location.getLongitudeE6()/1E6, 1); if (addresses.size() > 0) { Address resultAddress = addresses.get(0); String locality = resultAddress.getLocality(); String sublocality = resultAddress.getSubLocality(); String postalcode = resultAddress.getPostalCode(); String country = resultAddress.getCountryName(); String adminarea = resultAddress.getSubAdminArea(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public AddressDto createDto(final Address address, final boolean embed, final boolean link) { return AddressDto.builder() .addressLine1(address.getAddressLine1()) .addressLine2(address.getAddressLine2()) .addressLine3(address.getAddressLine3()) .firstName(address.getFirstName()) .lastName(address.getLastName()) .city(address.getCity()) .postalCode(address.getPostalCode()) .companyName(address.getCompanyName()) .countryCode(Optional.ofNullable(address.getIsoCountryAlpha2()).map(ISOCountry::getAlpha2).orElse(null)) .countrySubdivisionCode(address.getIsoCountrySubdivision()) .email(address.getEmailAddress()) .phone(Optional.ofNullable(address.getPhonePrimary()).map(phoneNumberFormat::format).orElse(null)) .build(); }