Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Wikidata value causes crash #140

Closed
mattficke opened this issue Mar 27, 2018 · 3 comments
Closed

Null Wikidata value causes crash #140

mattficke opened this issue Mar 27, 2018 · 3 comments
Labels

Comments

@mattficke
Copy link

Original report found on StackOverflow: https://stackoverflow.com/questions/49426512/mapbox-geocoding-keyword-issue/

A query for nayar to the Mapbox geocoding API returns a response (pasted in the details tag below) which includes a feature that has a wikidata property of null. This seems to cause MapboxGeocoder.swift to crash.

This is the feature, found in the context array of the fifth result:

{
  "id": "place.13751392024658340",
  "wikidata": null,
  "text": "Njarackal"
}

It's unclear at the moment why the Wikidata property is null (usually the property is just omitted), but it looks like the assertion that the property starts with Q can't handle a null value.

{
"type": "FeatureCollection",
"query": [
"nayar"
],
"features": [
{
"id": "region.3653",
"type": "Feature",
"place_type": [
"region"
],
"relevance": 1,
"properties": {
"short_code": "MX-NAY",
"wikidata": "Q79920"
},
"text": "Nayarit",
"place_name": "Nayarit, Mexico",
"bbox": [
-106.787641,
20.603419,
-103.721015,
23.08448
],
"center": [
-104.871929,
21.844327
],
"geometry": {
"type": "Point",
"coordinates": [
-104.871929,
21.844327
]
},
"context": [
{
"id": "country.3124",
"short_code": "mx",
"wikidata": "Q96",
"text": "Mexico"
}
]
},
{
"id": "locality.7614208079466220",
"type": "Feature",
"place_type": [
"locality"
],
"relevance": 1,
"properties": {},
"text": "Nayarambalam",
"place_name": "Nayarambalam, Parur, Ernakulam, Kerala, India",
"bbox": [
76.1994210007976,
10.0433100091989,
76.2448449638604,
10.089088483634
],
"center": [
76.218382,
10.0471
],
"geometry": {
"type": "Point",
"coordinates": [
76.218382,
10.0471
]
},
"context": [
{
"id": "place.11417127351396900",
"wikidata": "Q3595582",
"text": "Parur"
},
{
"id": "district.2166058119450144",
"wikidata": "Q1356097",
"text": "Ernakulam"
},
{
"id": "region.26058",
"short_code": "IN-KL",
"wikidata": "Q1186",
"text": "Kerala"
},
{
"id": "country.3146",
"short_code": "in",
"wikidata": "Q668",
"text": "India"
}
]
},
{
"id": "poi.12045385002171630",
"type": "Feature",
"place_type": [
"poi"
],
"relevance": 1,
"properties": {
"landmark": true,
"tel": "(971) 888-4897",
"category": "restaurant",
"address": "5919 SE Foster Rd",
"maki": "restaurant"
},
"text": "Nayar Taqueria",
"place_name": "Nayar Taqueria, 5919 SE Foster Rd, Portland, Oregon 97206, United States",
"center": [
-122.60226,
45.492501
],
"geometry": {
"type": "Point",
"coordinates": [
-122.60226,
45.492501
]
},
"context": [
{
"id": "neighborhood.2104183",
"text": "Foster-Powell"
},
{
"id": "postcode.12407780345674310",
"text": "97206"
},
{
"id": "place.10052003640326360",
"wikidata": "Q6106",
"text": "Portland"
},
{
"id": "region.226438",
"short_code": "US-OR",
"wikidata": "Q824",
"text": "Oregon"
},
{
"id": "country.3145",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "place.16940807755466220",
"type": "Feature",
"place_type": [
"place"
],
"relevance": 1,
"properties": {},
"text": "Nayarambalam",
"place_name": "Nayarambalam, Kerala, India",
"bbox": [
76.195002655335,
10.0342420777563,
76.2494053976574,
10.0778606929352
],
"center": [
76.234294,
10.055683
],
"geometry": {
"type": "Point",
"coordinates": [
76.234294,
10.055683
]
},
"context": [
{
"id": "district.2166058119450144",
"wikidata": "Q1356097",
"text": "Ernakulam"
},
{
"id": "region.26058",
"short_code": "IN-KL",
"wikidata": "Q1186",
"text": "Kerala"
},
{
"id": "country.3146",
"short_code": "in",
"wikidata": "Q668",
"text": "India"
}
]
},
{
"id": "locality.14996912098466220",
"type": "Feature",
"place_type": [
"locality"
],
"relevance": 1,
"properties": {},
"text": "Nayarambalam",
"place_name": "Nayarambalam, Njarackal, Ernakulam, Kerala, India",
"bbox": [
76.19871384,
10.04440797,
76.22578584,
10.06871301
],
"center": [
76.212953,
10.056965
],
"geometry": {
"type": "Point",
"coordinates": [
76.212953,
10.056965
]
},
"context": [
{
"id": "place.13751392024658340",
"wikidata": null,
"text": "Njarackal"
},
{
"id": "district.2166058119450144",
"wikidata": "Q1356097",
"text": "Ernakulam"
},
{
"id": "region.26058",
"short_code": "IN-KL",
"wikidata": "Q1186",
"text": "Kerala"
},
{
"id": "country.3146",
"short_code": "in",
"wikidata": "Q668",
"text": "India"
}
]
}
],
"attribution": "NOTICE: © 2017 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained."
}
@1ec5
Copy link
Contributor

1ec5 commented Mar 27, 2018

/cc @bsudekum @coxchapman @frederoni

@1ec5 1ec5 added the bug label Mar 27, 2018
@frederoni
Copy link
Contributor

I can't find any issues with the null handling but searching for "nayara" returns a placemark with a leading whitespace (" Q10116") which triggers an assertion.

Fixed in #141

@coxchapman
Copy link

@frederoni I had a repeated crash this weekend with the number "531" -- 51 was fine, as was 541 -- only 531.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants