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
Object query hits javascript error TypeError: t.bounds is undefined #1156
Comments
|
Surely when looking for enclosing objects it's entirely normal for none of the nodes to be in the visible area? Certainly we wouldn't want to filter out those results, just not try and draw the bbox or something. |
Yes, http://www.openstreetmap.org/way/33832747 is pretty huge, and if you're on zoomlevel 15, it just happens, that you're inside the area, but none of the nodes are in the bbox provided in the Overpass query. That's pretty much what |
|
Well exactly - every time I click somewhere in London the "England" polygon will doubtless enclose it but without any nodes being in the bbox so why do we not see this all the time? |
|
Well, the overpass query only restricts the ways' output via Conditions for this issue to occur seem to be:
Edit: I did a cross check using the following queries: [timeout:5][out:json];is_in(39.6163,-74.5054)->.a;way(pivot.a);
out tags geom(39,-76,41,-74);relation(pivot.a);out tags bb;(bbox was set large enough for way 33832747 to fit in) [timeout:5][out:json];is_in(39.6163,-74.5054)->.a;way(pivot.a);
out tags geom;relation(pivot.a);out tags bb;Result: I would assume, as long as there's some geometry available there will be also a |
|
Would it be OK if I try to 'fix' the specific case mentioned above on the map? (I am the one who started the question on help.openstreetmap.org referenced above.) What I want to do is create a new multipolygon relation with one role=outer member - way 33832747, move the name and boundary tags from that way to the new relation, and remove area=yes from the way. If I understand the above, that should allow 'enclosing features' to work within the Pinelands National Reserve. I understand this could make it harder to fix the underlying cause, so I don't want to do it without approval. But right now this affects a large part of Southern New Jersey where I do mapping. |
|
Followup: I tried the above change to Way 33832747 on the map but it didn't help with 'enclosing features'. I still get an empty list in the browser, and TypeError. So I undid my change, putting everything back the way it was. |
|
@ljb279 : under normal circumstances, transforming the area from a way to a relation would indeed work around the Javascript error. However, as the area creation on overpass-api.de lags behind a few weeks (see status page: no area updates since 2016-02-11), your changes were not reflected on Overpass API at any time - the query was still using the old areas, hence returning way 33832747 without |
|
So the root problem is that, for enclosing features defined by a way, we ask overpass for a geometry clipped to the current view: Now normally that returns a bounding box as well as the clipped geometry, and I assumed that was the full bounding box, but it turns out it is the bounding box of the clipped geometry. That causes two problem - firstly this exception if the geometry is completely clipped away so that there is nothing left and hence no bounding box and secondly it means we are sorting features incorrectly because we use the bounding boxes to sort them by size. |
|
At least in the documentation I could not find an explicit hint how
I assume that only those nodes which are produced by @drolbr : Roland, can you please comment on this one? Am I missing something here or is this all works as designed? Maybe adding another [timeout:5][out:json];is_in(39.6163,-74.5054)->.a;way(pivot.a);
out tags geom(39.59927344095099,-74.5391035079956,39.633324269501465,-74.4717264175415);
out bb ids;relation(pivot.a);out tags bb;This returns an additional way with id and unclipped {
"type": "way",
"id": 33832747,
"bounds": {
"minlat": 39.1919712,
"minlon": -75.0191372,
"maxlat": 40.1129889,
"maxlon": -74.2086371
}Of course there's also the option to have ways behave like relations via |
|
Yes doing separate outputs for bounds and geom works, but then it needs to be merged client side. I'm trying to make that work at the moment... |
|
Thanks for the quick fix! I didn't look at the code in detail, but I assume it also handles multiple, possibly contradicting [timeout:5][out:json];is_in(39.6163,-74.5054)->.a;way(pivot.a);
out tags bb;out ids geom(39.2,-74.5,41,-74);relation(pivot.a);out tags bb;{
"type": "way",
"id": 33832747,
"bounds": {
"minlat": 39.1919712,
"minlon": -75.0191372,
"maxlat": 40.1129889,
"maxlon": -74.2086371
},
"tags": {
"area": "yes",
"boundary": "national_park",
"name": "Pinelands National Reserve",
"website": "http://www.nps.gov/pine/",
"wikipedia": "en:New Jersey Pinelands National Reserve"
}
},
{
"type": "way",
"id": 33832747,
"bounds": {
"minlat": 39.5259208,
"minlon": -74.5065613,
"maxlat": 40.1129889,
"maxlon": -74.2086371
},
"geometry": [
null, |
|
Hmm that's a good point... |
|
Fixed in 6e154d4. |
|
Thanks, that looks better now! There's one thing I noticed with the current version on osm.org. Wasn't there some red bbox shown on the map when hovering over each entry in the enclosing feature list? That feature was quite handy to get a rough idea about the actual size of an enclosing feature. For ways, there are still some nodes shown (as long as thery're inside the bbox), for relations, I don't see the red bbox on the map anymore. Was the feature possibly removed in a different commit or is it some kind of side effect of this issue? Apologies if my memory is playing tricks on me here and that feature never existed in the first place. |
|
I think that's only for features where we have a geometry isn't it? |
|
Yes - eg http://www.openstreetmap.org/query?lat=51.76596&lon=-0.00648 where the first entry highlights the outline but the others are outside the viewport so don't. |
|
Well relations won't have a geometry, because we only ask for a bounding box there. |
|
yes, sorry. you're right... I think we can close this topic, I really had overpass turbo in mind. Thanks again for the patience! |
|
I just want to add that this ("enclosing features" query) is working really well for me now. Thanks for the effort fixing it. |

For full details and some background infos, please refer to this post: https://help.openstreetmap.org/questions/48088/what-makes-a-closed-way-show-up-as-an-enclosing-feature-with-query-features
That's where the issue was initially reported.
How to reproduce:
Issues:
TypeError: t.bounds is undefinedFurther analysis:
Upon calling the
queryfeature above, the following Overpass API is getting executed in background:Overpass result:
To display a list of enclosing features on the UI, they're initially sorted by their respective size. This is implemented in the following piece of Javascript code. Due to the missing
boundselement in the Overpass API result for way 3383274, we hit a Javascript error.The text was updated successfully, but these errors were encountered: