title: Check if user location is inside a shape
body: <p>I made this method to check if an user location is inside a polygon on a map view (mapkit). 
  I pass to the method the current user location (CLLocationCoordinate2D) and return a boolean just to know if the user is in a polygon or not.</p>
  
  <pre><code>func userInsidePolygon(userlocation: CLLocationCoordinate2D ) -&gt; Bool{
      // get every overlay on the map  
      let o = self.mapView.overlays
      // loop every overlay on map
      for overlay in o {
          // handle only polygon
          if overlay is MKPolygon{
              let polygon:MKPolygon =  overlay as! MKPolygon
              let polygonPath:CGMutablePathRef  = CGPathCreateMutable()
              // get points of polygon
              let arrPoints = polygon.points()
              // create cgpath
              for (var i:Int=0; i &lt; polygon.pointCount; i++){
                  let mp:MKMapPoint = arrPoints[i]
                  if (i == 0){
                      CGPathMoveToPoint(polygonPath, nil, CGFloat(mp.x), CGFloat(mp.y))
                  }
                  else{
                      CGPathAddLineToPoint(polygonPath, nil, CGFloat(mp.x), CGFloat(mp.y))
                  }
              }
              let mapPointAsCGP:CGPoint = self.mapView.convertCoordinate(userlocation, toPointToView: self.mapView)
              return CGPathContainsPoint(polygonPath , nil, mapPointAsCGP, false)
          }
      }
      return false
  }
  </code></pre>
  
  <p>I don't really understand why, but the user is never inside a polygon after this test. (and i'm pretty sure he is)</p>
  
  <p>I think it's possible that i have a logic problem with lat/long against x,y.</p>
  
  <p>Does anybody already have work with like this ? </p>
  
  <p>Thanks in advance for all suggestions.</p>
  
  <p>Cheers </p>