summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLGeometry_Private.h
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-11-03 12:17:45 -0700
committerGitHub <noreply@github.com>2017-11-03 12:17:45 -0700
commit2955fb594c5235c302773d6fc36d85f05a654290 (patch)
treef2e0a5e3b1e575f835aa5017086cfa07a82dcafd /platform/darwin/src/MGLGeometry_Private.h
parentd1d0c200442133e2eca110e3521f1caf831eda5c (diff)
downloadqtlocation-mapboxgl-2955fb594c5235c302773d6fc36d85f05a654290.tar.gz
Make places and roads accessible to VoiceOver (#9950)
* [ios] Summarize places, roads after zooming with VoiceOver After zooming, MGLMapView’s accessibility value now indicates the number of visible roads and lists out a few places visible in the current viewport, starting with the features at the highest z-index (not necessarily the largest or the closest to the center of the view). Avoid saying that no annotations are visible. * [ios] Allow VoiceOver to navigate among place features Split out a separate header for the various accessibility elements tied to MGLMapView. Wrap place features in accessibility elements and insert them into the narration order after the visible annotations but before the attribution button. Refactored MGLMapView’s accessibility code to rely on ranges to avoid off-by-one errors. * [ios] Post layout change notification when fully rendered Post a layout change notification when fully finishing a map render. * [ios, macos] Moved MGLVectorSource+MGLAdditions to more specific group * [ios] Localize accessibility feature names * [ios] Find place feature accessibility elements by identifier * [ios] Refactored accessibility traits Also created a new MGLPlaceFeatureAccessibilityElement class. * [ios] Sort accessibility elements by screen distance from center Sort annotation accessibility elements by screen distance, not the hypotenuse of coordinates, which can yield incorrect results when the map is rotated or tilted or when the user is located at high latitudes. Sort place feature accessibility elements by screen distance as well. * [ios] Create a place feature accessibility element, not an abstract feature accessibility element * [ios] Only query for visible place features once per camera Improved accessibility performance after changing the map camera. MGLMapView no longer queries the map for place features once per place feature. * [ios] Made roads accessible Wrap visible road features in accessibility elements described by the road name, route number, and general direction of travel. * [ios] Cleaned up radian conversions * [ios] Thickened road accessibility elements * [ios] Made unioned roads accessible * [ios] Consistently sort accessibility elements Also fixed an issue causing road feature accessibility elements to get treated like place feature accessibility elements. * [ios] Announce direction of divided roads Announce the direction of a divided road based on the direction of its first polyline. * [ios] Refined announced elevation units * [ios] Romanize feature names * [ios] Updated changelog * [ios] Delay zoom announcement A 100-millisecond delay is enough for the post-zooming announcement to reflect the new zoom level rather than the previous zoom level. * [ios] Consolidated geometry functions Adopted MGLGeometry_Private.h in the accessibility code, forcing a conversion to Objective-C++. Avoid inlining some of the more complex geometric functions. * [ios] Fixed feature name romanization in accessibility labels NSLocale.scriptCode is only set when the locale identifier explicitly specifies a script. Use NSOrthography to identify the dominant orthography regardless of locale. Also added a unit test of feature accessibility element labels. * [ios] Added tests for place, road accessibility values * [ios] Announce one-way roads A road feature’s accessibility value now indicates whether the road is a one-way road.
Diffstat (limited to 'platform/darwin/src/MGLGeometry_Private.h')
-rw-r--r--platform/darwin/src/MGLGeometry_Private.h40
1 files changed, 14 insertions, 26 deletions
diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h
index 87a19989c1..8b9c6c2327 100644
--- a/platform/darwin/src/MGLGeometry_Private.h
+++ b/platform/darwin/src/MGLGeometry_Private.h
@@ -105,38 +105,26 @@ NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinateFromLocationCoordinate(CLLoca
MGLRadiansFromDegrees(locationCoordinate.longitude));
}
-/*
+/**
Returns the distance in radians given two coordinates.
*/
-NS_INLINE MGLRadianDistance MGLDistanceBetweenRadianCoordinates(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to)
-{
- double a = pow(sin((to.latitude - from.latitude) / 2), 2)
- + pow(sin((to.longitude - from.longitude) / 2), 2) * cos(from.latitude) * cos(to.latitude);
-
- return 2 * atan2(sqrt(a), sqrt(1 - a));
-}
+MGLRadianDistance MGLDistanceBetweenRadianCoordinates(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to);
-/*
+/**
Returns direction in radians given two coordinates.
*/
-NS_INLINE MGLRadianDirection MGLRadianCoordinatesDirection(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to) {
- double a = sin(to.longitude - from.longitude) * cos(to.latitude);
- double b = cos(from.latitude) * sin(to.latitude)
- - sin(from.latitude) * cos(to.latitude) * cos(to.longitude - from.longitude);
- return atan2(a, b);
-}
+MGLRadianDirection MGLRadianCoordinatesDirection(MGLRadianCoordinate2D from, MGLRadianCoordinate2D to);
-/*
- Returns coordinate at a given distance and direction away from coordinate.
+/**
+ Returns a coordinate at a given distance and direction away from coordinate.
*/
-NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinateAtDistanceFacingDirection(MGLRadianCoordinate2D coordinate,
- MGLRadianDistance distance,
- MGLRadianDirection direction) {
- double otherLatitude = asin(sin(coordinate.latitude) * cos(distance)
- + cos(coordinate.latitude) * sin(distance) * cos(direction));
- double otherLongitude = coordinate.longitude + atan2(sin(direction) * sin(distance) * cos(coordinate.latitude),
- cos(distance) - sin(coordinate.latitude) * sin(otherLatitude));
- return MGLRadianCoordinate2DMake(otherLatitude, otherLongitude);
-}
+MGLRadianCoordinate2D MGLRadianCoordinateAtDistanceFacingDirection(MGLRadianCoordinate2D coordinate,
+ MGLRadianDistance distance,
+ MGLRadianDirection direction);
+
+/**
+ Returns the direction from one coordinate to another.
+ */
+CLLocationDirection MGLDirectionBetweenCoordinates(CLLocationCoordinate2D firstCoordinate, CLLocationCoordinate2D secondCoordinate);
CGPoint MGLPointRounded(CGPoint point);