diff options
author | Aleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com> | 2019-07-16 22:29:40 +0300 |
---|---|---|
committer | Jason Wray <friedbunny@users.noreply.github.com> | 2019-07-17 16:13:33 -0700 |
commit | ae38a22dc181c803acbc31a69b018ecac11f7d1e (patch) | |
tree | b0ade5e5e0604ae600cb9910263b8c23335dd0b2 /platform | |
parent | 8fe469f6b17056e20eda1f15053ed54aa938b559 (diff) | |
download | qtlocation-mapboxgl-ae38a22dc181c803acbc31a69b018ecac11f7d1e.tar.gz |
[core] Fix collision with content insets
Viewport center offset usage was wrongly submitted in #14664. It was part of alternative approach that used enlarged viewport. Existing and added tests were not sufficient to spot the regression, since the collision check padding is usually larger than the center offset x and y. Annotation picking has tolerance of only 10 pixels but no annotation integration test was using content insets.
Usage of offset is not needed because `posMatrix` in e.g. `CollisionIndex::projectPoint(const mat4& posMatrix, const Point<float>& point)` already incorporates center offset (projection matrix) and the code in current master was just offsetting all by the value.
Modified [ios] MGLAnnotationViewIntegrationTests.testSelectingAnnotationWithCenterOffset to use different insets. It verifies the fix.
Fixes [iOS] Annotations are not selectable (added via iosapp menu) #15106:
In case of #15106, view's original content insets is {top:88, bottom:34}, causing that center offset is {x:0, y:27} and selection with tolerance of 10 wouldn't select annotation.
After tapping the view, so that the header gets removed, view's content insets get changed to {top:44, bottom:34}, center offset is {x:0, y:5} and annotation selection would work, as described in #15106.
Fixes: #15106
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m b/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m index 162bfc5237..f129277e87 100644 --- a/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m +++ b/platform/ios/Integration Tests/Annotation Tests/MGLAnnotationViewIntegrationTests.m @@ -401,15 +401,17 @@ static const CGPoint kAnnotationRelativeScale = { 0.05f, 0.125f }; for (CGFloat dx = -100.0; dx <= 100.0; dx += 100.0 ) { for (CGFloat dy = -100.0; dy <= 100.0; dy += 100.0 ) { CGVector offset = CGVectorMake(dx, dy); - [self internalTestSelectingAnnotationWithCenterOffsetWithOffset:offset]; + UIEdgeInsets edgeInsets = UIEdgeInsetsMake(fmax(-dy, 0.0), fmax(-dy, 0.0), fmax(dy, 0.0), fmax(dx, 0.0)); + [self internalTestSelectingAnnotationWithCenterOffsetWithOffset:offset edgeInsets:edgeInsets]; } } } -- (void)internalTestSelectingAnnotationWithCenterOffsetWithOffset:(CGVector)offset { +- (void)internalTestSelectingAnnotationWithCenterOffsetWithOffset:(CGVector)offset edgeInsets:(UIEdgeInsets)edgeInsets { NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReuseIdentifer"; + self.mapView.contentInset = edgeInsets; CGSize size = self.mapView.bounds.size; CGSize annotationSize = CGSizeMake(40.0, 40.0); @@ -449,8 +451,8 @@ static const CGPoint kAnnotationRelativeScale = { 0.05f, 0.125f }; // Check that the annotation is in the center of the view CGPoint annotationPoint = [self.mapView convertCoordinate:point.coordinate toPointToView:self.mapView]; - XCTAssertEqualWithAccuracy(annotationPoint.x, size.width/2.0, 0.25); - XCTAssertEqualWithAccuracy(annotationPoint.y, size.height/2.0, 0.25); + XCTAssertEqualWithAccuracy(annotationPoint.x, (size.width - edgeInsets.right + edgeInsets.left)/2.0, 0.25); + XCTAssertEqualWithAccuracy(annotationPoint.y, (size.height - edgeInsets.bottom + edgeInsets.top)/2.0, 0.25); // Now test taps around the annotation CGPoint tapPoint = CGPointMake(annotationPoint.x + offset.dx, annotationPoint.y + offset.dy); |