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

More consistent interface for converting between screen and geographic coordinates #822

Merged
merged 4 commits into from
Jul 13, 2016

Conversation

matteblair
Copy link
Member

@matteblair matteblair commented Jul 12, 2016

  1. Uses consistent types and naming for the relevant function calls. It should be obvious that these functions are the inverse of one another.

  2. lngLatToScreenPosition returns true if the point is visible (the opposite of the old behavior). This is a more subjective point but to me it seems much more intuitive to associate a "positive" result with something being visible, e.g. the following use case seems reasonable:

    if (lngLatToScreenPosition(lng, lat, &x, &y)) {
      // draw a marker on screen at (x, y)
    }
  3. screenPositionToLngLat returns true if the screen position corresponds to a geographic location (i.e. if the ray cast has a positive intersection). This is meaningful information for tilted views.

@@ -88,12 +88,11 @@ float getTilt();

// Transform coordinates in screen space (x right, y down) into their longitude
// and latitude in the map view
Copy link
Member

Choose a reason for hiding this comment

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

Can you update the comments here to reflect (lng, lat) pair has the appropriate value. Currently if one just reads the comments it seems x and y will be transformed/updated to have lng/lat respectively.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

@matteblair matteblair force-pushed the screen2lonlat2screen branch from caeb93e to 89a2991 Compare July 12, 2016 17:32
@matteblair
Copy link
Member Author

Updated with improved comments and one more commit.

@tallytalwar
Copy link
Member

Looks good to me. Merging.

@matteblair
Copy link
Member Author

One question first!

@matteblair
Copy link
Member Author

Ok, last issue resolved, should be good to go!

@@ -379,12 +379,15 @@ public CameraType getCameraType() {
/**
* Find the geographic coordinates corresponding to the given position on screen
* @param screenPosition Position in pixels from the top-left corner of the map area
* @return LngLat corresponding to the given point
* @return LngLat corresponding to the given point, or null if the screen position
* does not intersect a geographic location.
Copy link
Member

Choose a reason for hiding this comment

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

We can mention "or null if the screen position does not intersect a geographic location, which can happen at higher tilt angles".

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@matteblair matteblair force-pushed the screen2lonlat2screen branch from a70362b to c550df2 Compare July 13, 2016 01:11
@matteblair matteblair merged commit 009de5e into master Jul 13, 2016
@matteblair matteblair deleted the screen2lonlat2screen branch July 13, 2016 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants