Skip to content

BGDIINF_SB_2673 show absence of data in the profile#388

Merged
pakb merged 9 commits intodevelopfrom
feat-BGDIINF_SB-2673_profile_show_absence_of_data
Apr 27, 2023
Merged

BGDIINF_SB_2673 show absence of data in the profile#388
pakb merged 9 commits intodevelopfrom
feat-BGDIINF_SB-2673_profile_show_absence_of_data

Conversation

@pakb
Copy link
Contributor

@pakb pakb commented Mar 3, 2023

Brand new approach to the profile chart generation, we now only request service-alti backend when we deal with coordinates in LV95's extent, and show the user on the profile chart when there is no data.
Also adding the possibility to zoom into the profile with a pinch gesture (mobile) or through a wheel or shift+drag gesture (on desktop)

Test link

@pakb pakb marked this pull request as ready for review March 3, 2023 16:44
@pakb pakb requested review from davidoesch, jedef and ltshb March 3, 2023 16:44
@davidoesch
Copy link
Contributor

Very nice.
I like the zoom approach and the no data approach.
Might be interesting to add for the missing data this source https://open-elevation.com/ but post post mvp

@pakb pakb force-pushed the feat-BGDIINF_SB-2673_profile_show_absence_of_data branch 2 times, most recently from 7a4e5c3 to 66793b0 Compare March 7, 2023 15:28
@ltshb
Copy link
Contributor

ltshb commented Mar 8, 2023

On mobile by default the tooltip is display below with the description and if we want to see the profile we need to scroll down which is not very user friendly. Especially if the description is empty we only see an empty description and have to scroll down to see the profile. Some possible mitigation

  • Increase the height of the profile tooltip footer on mobile
  • Put the description below the profile
  • Reduce the description box size if it is empty

Before it was not optimal but we could see at least part of the profile on an Iphone SE, now we don't see anything and it is then not trivial to see that there is a profile below
image

@pakb
Copy link
Contributor Author

pakb commented Mar 8, 2023

I agree with your remark but say this is out of scope of this PR. Here I try to replace the chart generation framework, which is already a big chunk of code to review, I would do what you propose in a second PR/ticket.
A possible solution would be to use the header of the infobox (the light gray part) to add two "tabs" there when we are on mobile and dealing with a feature that can be edited and has a profile chart at the same time, so that the user can show only the part that is of interest, and clearly sees that there is two "sides" to this feature.

@davidoesch
Copy link
Contributor

Use opentopography freemium API to cover missing data https://opentopography.org/developers

@pakb
Copy link
Contributor Author

pakb commented Mar 8, 2023

Use opentopography freemium API to cover missing data https://opentopography.org/developers

I prefer to wait for some sort of official solution from our backend, I don't know if users will find this particular solution precise enough when mixed with our data, and that adds a layer of complexity to show the user that this data isn't ours.

I think we should think of a more thorough solution and make our backend service world-wide and mercator compatible.

@davidoesch
Copy link
Contributor

We do already have 2 datasets in the elevation, Swissalti and dhm25 .

https://open-elevation.com/ would be my choice

Copy link
Contributor

@ltshb ltshb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still on-going review

},
ticks: {
// processing distance number to be more human-readable
callback: (val) => round(val * this.factorToUseForDisplayedDistances, 1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that returning a callback function in computed property is a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know either. I don't think we can externalise that (that's a requirement from ChartJS to give a function to process this styling) as we are using some other computed/data props here (this.factorToUseForDisplayedDistance)

chartJsTooltipConfiguration() {
return {
enabled: false,
external: ({ chart, tooltip }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid returning complex method/callback in computed properties which are cached and reactive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then maybe move that to some methods, and have watchers to update the ChartJS instances in case of update... I'll look into it, that's true it's not optimal to have such big objects in the reactive loop

@jedef
Copy link
Contributor

jedef commented Mar 13, 2023

The old tooltip was always visible, even at the border:
image

This is not the case anymore of the new tooltip:
image

@jedef
Copy link
Contributor

jedef commented Mar 13, 2023

The data model source was previously a link that was clickable:
image

This is not anymore the case:
image

Is this a wanted change?

Copy link
Contributor

@jedef jedef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are lots of changes, so I could not review all of it today, so I publish what I already have. Overall I like very much the new style of the graph, that the datapoints are visible and that you can zoom in the graph.
I think that by default the backend always returns 200 points for each request. (but at least every km as the geodesic gemoetry we send to the backend has at least a point every km) I was asking myself if maybe we should adapt the resolution depeding on the length?

@jedef
Copy link
Contributor

jedef commented Mar 13, 2023

The problem with the lv95 boundings it that they seem pretty approximative. There is no guarantee that data is available even if within the bonds. ( In the example above the bound is more than 10 km off)
image

Edit:
Thats strange. If I move the line just a little bit, suddenly the line is detected as being completly off the bounds even though it is not.
image

And when the line is long enough the split is done correctly. So maybe this is not a problem with the bound after all and only with how the splitting is done?
image

pakb added 9 commits April 26, 2023 13:38
Will detect if line is overlapping LV95 bounds and split it into multiple chunks, so that we can request our backends only with segments that are within LV95 bounds

Using some lib that implements the Liang-Barsky algorithm to achieve this, see https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm
Add a new "no data" translation key
Adding one class per profile data structure.
Implementing a segmenting of the profile before sending backend request, so that we only request data for coordinates that are in LV95 bounds. All out of bound chunks are ignored and filled with a simple Pythagoras distance calculation.
D3 starts to be a bit outdated and hard to handle with the segmentation approach.
ChartJS offers a wide variety of customization through plugin, and less direct canvas manipulation (as it functions how we want it to out of the box).
Adding two custom ChartJS module to handle the empty/nodata segments of the profile, and one to show the user the data model being used.
Using a zoom plugin so that users can now zoom in the profile to better see some feature of it.
Rework of the styling of the profile done in the process of switching to ChartJS (e.g. points are now barely visible, but can help to read/understand where the data is)
Instead of re-requesting data from the backend, we can create the CSV data on the fly as we've got everything we need.
Removing now unused API function to request profile as a CSV, and fixing the E2E test covering this part of the app.
Also fixing the tooltip positioning when hovering the profile chart.
This should clarify why some calculation aren't available, and why part of the UI shouldn't be rendered. Should also behave better in case of malformed/invalid data.
after splitting hasData into two distinct boolean, the tooltip generation went through the refactoring unchanged, this is now fixed.
Manage profile tooltip position so that it doesn't go further than the graph
Rework of profile calculation so that each segment now does its own calculation, and the profile make a sum of all wanted values
@pakb pakb force-pushed the feat-BGDIINF_SB-2673_profile_show_absence_of_data branch from d39cff9 to 735856d Compare April 26, 2023 11:38
@pakb pakb requested review from jedef and ltshb April 26, 2023 13:27
@pakb pakb merged commit 2cce178 into develop Apr 27, 2023
@pakb pakb deleted the feat-BGDIINF_SB-2673_profile_show_absence_of_data branch April 27, 2023 06:24
@pakb pakb mentioned this pull request May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants