james075
james075

Reputation: 1278

how to check if bounding box contains my point

I wanna know if my point is in my bounding box using coordinates:

point to check:

CLLocation -> 48.847172 2.386597

bounding box :

maxLat minLat / maxLon minLon

"48.7998602295",
"48.8198640442",
"2.46138595581",
"2.48138619423"

how can i check that ?

Upvotes: 0

Views: 1342

Answers (1)

sergio
sergio

Reputation: 69027

Would CGRectContainsPoint

bool CGRectContainsPoint (
  CGRect rect,
  CGPoint point
);

work for you?

You can convert a CLLocationCoordinate2D into a CGPoint like this:

CGPoint p = (CGPoint) { loc.latitude, loc.longitude };

Upvotes: 5

Related Questions