Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

PrecisionPoint TransformState::latLngToPoint dateline issue #4155

Closed

Description

@tobrun

Issue in mbgl when calculating points based on LatLng from the left side of the dateline after crossing the dateline from left to right. This is a follow up issue for #3995.

An example:

Take this LatLng:

LatLng [longitude=-179.64576449708883, latitude=-16.83408606795382, altitude=0.0]

before crossing the dateline latLngToPoint is giving us Point[x=455.80133, y= 746.6456]
while after crossing the dateline latLngToPoint is giving us Point[x=393667.44, y=747.1837].
Normally we should see a small decrease in value not a big increase.

Activity

  1. tobrun commented on Mar 1, 2016

    @tobrun
    MemberAuthor

    Related method in transform_state.cpp:

    PrecisionPoint TransformState::latLngToPoint(const LatLng& latLng) const {
        return coordinateToPoint(latLngToCoordinate(latLng));
    }

    which on his turn calls:

    PrecisionPoint TransformState::coordinateToPoint(const TileCoordinate& coord) const {
        mat4 mat = coordinatePointMatrix(coord.zoom);
        matrix::vec4 p;
        matrix::vec4 c = {{ coord.column, coord.row, 0, 1 }};
        matrix::transformMat4(p, c, mat);
        return { p[0] / p[3], height - p[1] / p[3] };
    }

    and

    TileCoordinate TransformState::latLngToCoordinate(const LatLng& latLng) const {
        const double tileZoom = getZoom();
        const double k = zoomScale(tileZoom) / worldSize();
        return {
            lngX(latLng.longitude) * k,
            latY(latLng.latitude) * k,
            tileZoom
        };
    }
  2. 1ec5 commented on Mar 1, 2016

    @1ec5
    Contributor

    I can reproduce this issue in the iOS SDK. From my location in California, if I zoom out to z0 and pan west, the user location annotation disappears as soon as the map view’s center point crosses the antimeridian. The iOS SDK similarly positions the user location annotation using Transform::latLngToPoint() (via Map::pixelForLatLng() and -[MGLMapView convertCoordinate:toPointToView:]).

  3. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    To make this problem a bit more visual, see this clip where I'm visualising the touch events.

  4. brunoabinader commented on Mar 6, 2016

    @brunoabinader
    Contributor

    @tobrun @1ec5 this should have been fixed in fd123de - could you please test using this hash?

  5. tobrun commented on Mar 6, 2016

    @tobrun
    MemberAuthor

    @brunoabinader I'm on it, currently building specifically from that commit.

  6. tobrun commented on Mar 6, 2016

    @tobrun
    MemberAuthor

    The user location and camera are LatLng [longitude=179.931, latitude=-16.945]
    At that time the user location is converted to x: 77.64928 and y: 918.33923

    Just before crossing the dateline the camera is on LatLng [longitude=179.99965655644286, latitude=-16.91392665410768] the values are x: 40.649273 and y: 906.33923.

    Just after crossing the dateline the camera is on LatLng [longitude=-179.99907836847547, latitude=-16.91429282823615] the values are x: 3601749.0 and y: 618666.6

    While it should be almost the same as before crossing, the x value should be a bit lower.

  7. tobrun commented on Mar 6, 2016

    @tobrun
    MemberAuthor

    Here is the related video showing it,
    note that the hash mentioned above contained this flashing regression from #4174.
    which is no longer a problem on master.

  8. self-assigned this
    on Mar 7, 2016
  9. brunoabinader commented on Mar 7, 2016

    @brunoabinader
    Contributor

    On it 👍

  10. brunoabinader commented on Mar 7, 2016

    @brunoabinader
    Contributor

    👉 #4214.

  11. added this to the android-v4.0.0 milestone on Mar 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions