Skip to content
Snippets Groups Projects
Commit a596eb22 authored by Dzmitry's avatar Dzmitry
Browse files

Now result.country doesn't fail f result is not in a country

In the sea for example
[Fix #1131]
parent 2e4f6a20
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,19 @@ module Geocoder::Result ...@@ -25,11 +25,19 @@ module Geocoder::Result
end end
def country def country
address_details['CountryName'] if address_details
address_details['CountryName']
else
""
end
end end
def country_code def country_code
address_details['CountryNameCode'] if address_details
address_details['CountryNameCode']
else
""
end
end end
def state def state
......
{
"response": {
"GeoObjectCollection": {
"metaDataProperty": {
"GeocoderResponseMetaData": {
"request": "32,43",
"found": "2",
"results": "10",
"Point": {
"pos": "32.000000 43.000000"
}
}
},
"featureMember": [
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"kind": "hydro",
"text": "Black Sea",
"precision": "other",
"AddressDetails": {
"Locality": {
"Premise": {
"PremiseName": "Black Sea"
}
}
}
}
},
"name": "Black Sea",
"boundedBy": {
"Envelope": {
"lowerCorner": "27.442409 40.908662",
"upperCorner": "41.777787 46.627275"
}
},
"Point": {
"pos": "34.188281 43.229215"
}
}
},
{
"GeoObject": {
"metaDataProperty": {
"GeocoderMetaData": {
"kind": "hydro",
"text": "Black Sea",
"precision": "other",
"AddressDetails": {
"Locality": {
"Premise": {
"PremiseName": "Black Sea"
}
}
}
}
},
"name": "Black Sea",
"boundedBy": {
"Envelope": {
"lowerCorner": "27.628351 40.908893",
"upperCorner": "41.777796 46.627999"
}
},
"Point": {
"pos": "33.383633 44.235582"
}
}
}
]
}
}
}
...@@ -14,4 +14,9 @@ class YandexTest < GeocoderTestCase ...@@ -14,4 +14,9 @@ class YandexTest < GeocoderTestCase
result.viewport result.viewport
end end
def test_yandex_empty_results
result = Geocoder.search('black sea').first
assert_equal "", result.country_code
assert_equal "", result.country
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment