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

Clicking on some measurements on the map result in an error #78

Open
Piiit opened this issue May 4, 2021 · 4 comments
Open

Clicking on some measurements on the map result in an error #78

Piiit opened this issue May 4, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Piiit
Copy link
Contributor

Piiit commented May 4, 2021

I logged in as a user that can access "Comune di Bolzano" data, then I clicked on "traffic" and the station as you see it in the screenshot:
Selection_051

The problem is that the detail view shows "loading..." forever. All data types in that station that have a gray dot work as expected.

Console output is as follows:

Uncaught (in promise) TypeError: station_data_json.data[stationType] is undefined
    setupFeatureClickPopup map.js:461
    e events.js:41
    dispatchEvent Target.js:101
    handleMapBrowserEvent PluggableMap.js:927
    e events.js:41
    dispatchEvent Target.js:101
    emulateClick_ MapBrowserEventHandler.js:119
    handlePointerUp_ MapBrowserEventHandler.js:175
    e events.js:41
    dispatchEvent Target.js:101
    fireNativeEvent PointerEventHandler.js:397
    an NativeSource.js:64
    eventHandler_ PointerEventHandler.js:203
    e events.js:41
    v events.js:174
    addEvents_ PointerEventHandler.js:214
    addEvents_ PointerEventHandler.js:213
    register_ PointerEventHandler.js:176
    registerSources PointerEventHandler.js:141
    e PointerEventHandler.js:115
    handlePointerDown_ MapBrowserEventHandler.js:217
    e events.js:41
    dispatchEvent Target.js:101
    fireNativeEvent PointerEventHandler.js:397
    on NativeSource.js:44
    eventHandler_ PointerEventHandler.js:203
    e events.js:41
    v events.js:174
    addEvents_ PointerEventHandler.js:214
    addEvents_ PointerEventHandler.js:213
    register_ PointerEventHandler.js:176
    registerSources PointerEventHandler.js:141
    e PointerEventHandler.js:115
    e MapBrowserEventHandler.js:78
    e PluggableMap.js:290
    e Map.js:75
    map_start_promise map.js:78
    <anonymous> (index):119
map.js:461:26

@Piiit Piiit added the bug Something isn't working label May 4, 2021
@Piiit
Copy link
Contributor Author

Piiit commented May 4, 2021

@rcavaliere FYI

@davidebz Do you have an idea how to solve this?

@noctho
Copy link
Collaborator

noctho commented May 4, 2021

The problem is that the code expects a result from the following request, but the data property is empty:

https://mobility.api.opendatahub.testingmachine.eu/v2/tree/TrafficSensor/*?where=scode.eq.municipalitybz:14

But the result of this request is not empty:

https://mobility.api.opendatahub.testingmachine.eu/v2/tree/TrafficSensor?where=scode.eq.municipalitybz:14

Therefore, I assume that the station "municipalitybz:14" does not contain any data type.

As you can see, the station "municipalitybz:14l2d1" contains some data types:

https://mobility.api.opendatahub.testingmachine.eu/v2/tree/TrafficSensor/*?where=scode.eq.municipalitybz:14l2d1

Would it be possible to change the API to return the station metadata with an empty sdatatypes array when a station does not contain a data type? That would solve this problem. Otherwise we have to send another request in order to show the metadata of the station in this case.

@Piiit
Copy link
Contributor Author

Piiit commented May 4, 2021

@noctho Hi, thanks for your investigations.

However, the API operates like a SQL statement as it is just a thin layer around Postgres queries. That is, if you have a filter that filters out everything, nothing is generated and an empty result returned. Checking the DB it turns out that that station has no measurements attached, hence the empty result.

I will think of a possibility to add empty sdatatypes, but that will not happen in short time. I have to rethink how the API works internally and see if I could make a left outer join, but I do not know what implications that might have for performance and other results. It should be possible for a v3 of the API thou.

So please, fix the logic inside your code in the meantime.

@rcavaliere
Copy link
Member

This is a special case of stations that have no data types and measurements associated. Yes, if we have a better error message here would be nicer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants