Skip to content

Commit

Permalink
Merge pull request #38 from AshFurrow/master
Browse files Browse the repository at this point in the history
Fixed #37.
  • Loading branch information
dblock committed Jun 17, 2014
2 parents 97ed5bd + a21cb7d commit 23a4807
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Next

* [#37](https://github.com/neilang/NAMapKit/issues/37) - Added assert inside NAMapView#zoomRelativePoint when returning `{NaN, NaN}` - [@ashfurrow](http://github.com/ashfurrow).

#### [3.1.1](https://github.com/neilang/NAMapKit/tree/v3.1.1) (5/12/2014)

* [#31](https://github.com/neilang/NAMapKit/issues/31) - Fix: `NAPinAnnotation` and `NAPinAnnotationView` retain cycle - [@dblock](https://github.com/dblock).
Expand Down
4 changes: 4 additions & 0 deletions Demo/DemoTests/NAMapViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
expect(mapView).toNot.beNil();
expect(mapView).to.beKindOf([NAMapView class]);
});

it(@"asserts on zoomRelativePoint: with a zero content size", ^{
expect(^{[mapView zoomRelativePoint:CGPointZero];}).to.raise(@"NSInternalInconsistencyException");
});
});

SpecEnd
Expand Down
3 changes: 3 additions & 0 deletions NAMapKit/NAMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ - (void)centerOnPoint:(CGPoint)point animated:(BOOL)animate

- (CGPoint)zoomRelativePoint:(CGPoint)point
{
BOOL hasContentSize = fabsf(self.originalSize.width) > 0 && fabsf(self.originalSize.height) > 0;
NSAssert(hasContentSize, @"originalSize dimension is zero, will result in NaN in returned value.");

CGFloat x = (self.contentSize.width / self.originalSize.width) * point.x;
CGFloat y = (self.contentSize.height / self.originalSize.height) * point.y;
return CGPointMake(round(x), round(y));
Expand Down

0 comments on commit 23a4807

Please sign in to comment.