@Throws(JSONException::class) protected fun buildAndroidAddress(jResult: JSONObject): Address? { val gAddress = Address(mLocale) gAddress.setLatitude(jResult.getDouble("lat")) gAddress.setLongitude(jResult.getDouble("lng")) var addressIndex = 0 if (jResult.has("streetName")) { gAddress.setAddressLine(addressIndex++, jResult.getString("streetName")) gAddress.setThoroughfare(jResult.getString("streetName")) } if (jResult.has("zipCode")) { gAddress.setAddressLine(addressIndex++, jResult.getString("zipCode")) gAddress.setPostalCode(jResult.getString("zipCode")) } if (jResult.has("city")) { gAddress.setAddressLine(addressIndex++, jResult.getString("city")) gAddress.setLocality(jResult.getString("city")) } if (jResult.has("state")) { gAddress.setAdminArea(jResult.getString("state")) } if (jResult.has("country")) { gAddress.setAddressLine(addressIndex++, jResult.getString("country")) gAddress.setCountryName(jResult.getString("country")) } if (jResult.has("countrycode")) gAddress.setCountryCode(jResult.getString("countrycode")) return gAddress }
Build an Android Address object from the Gisgraphy address in JSON format .