Skip to content

Do not ignore initial bbox - #98

Merged
easbar merged 2 commits into
masterfrom
info_bbox
Jun 9, 2021
Merged

easbar merged 2 commits into
masterfrom
info_bbox

Conversation

@easbar

@easbar easbar commented Jun 8, 2021

Copy link
Copy Markdown
Member

When the map loads and the bounding box is not the entire world (e.g. when using a local GH server with a smaller server) the map should be focused to the bounding box of the available road network. However, without this fix the initial bounding box we get from /info is ignored.

Comment thread src/stores/RouteStore.ts
private static getEmptyPath(): Path {
return {
bbox: [0, 0, 0, 0],
bbox: undefined,

@easbar easbar Jun 8, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We had a similar discussion before and I am still open to this :) In BasePath the bbox is declared optional, but here we set it to [0, 0, 0, 0] for the empty path. We then check for route.selectedPath.bbox here:

if (!route.selectedPath.bbox) setBbox(info.bbox)
but this does not do what we want. We would have to change this to route.selectedPath.bbox.every(num => num !== 0), but since bbox is declared optional we even need route.selectedPath.bbox && route.selectedPath.bbox.every(num => num !== 0). So we could do this but then I think bbox should not be optional in BasePath. Then again if bbox might be missing I think declaring it optional and handling the cases where it is missing is perfectly fine.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I agree. Since [0,0,0,0] is still a valid bbox having it undefined to indicate we really don't have a bbox is probably better.

Comment thread src/map/Mapbox.ts
}

fitBounds(bbox: Bbox) {
if (bbox.every(num => num !== 0)) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Here we do not need the bbox.every check, because if there was no bounding box it would be undefined and since the type here is Bbox (not optional) we do not have to do this check and can rely on the fact it is not missing and we checked for the missing value elsewhere.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, as stated in the other comment

Comment thread src/stores/RouteStore.ts
private static getEmptyPath(): Path {
return {
bbox: [0, 0, 0, 0],
bbox: undefined,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I agree. Since [0,0,0,0] is still a valid bbox having it undefined to indicate we really don't have a bbox is probably better.

Comment thread src/map/Mapbox.ts
}

fitBounds(bbox: Bbox) {
if (bbox.every(num => num !== 0)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, as stated in the other comment

@easbar
easbar merged commit de2960e into master Jun 9, 2021
@easbar
easbar deleted the info_bbox branch June 9, 2021 07:59
@easbar

easbar commented Jun 9, 2021

Copy link
Copy Markdown
Member Author

Thanks for taking a look 👍

ZeroGxMax pushed a commit to minhhpkp/graphhopper-maps that referenced this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants