title: Swift: Point in polygon? How can I check if a user's location falls within a Geo-JSON polygon?
body: <p>I have a user's location coordinates. Given the location is in one of the polygons, how do I return in which polygon it falls, by OBJECTID, using Swift or Objective-C?</p>
  <p>The sample JSON polygon data I am using looks like this:</p>
  <pre><code>{ &quot;type&quot;: &quot;Feature&quot;, &quot;properties&quot;: { &quot;OBJECTID&quot;: 10, &quot;District_N&quot;: &quot;10&quot;, &quot;WARD&quot;: 10 }, &quot;geometry&quot;: { &quot;type&quot;: &quot;Polygon&quot;, &quot;coordinates&quot;: [ [ [ -87.52389, 41.742767 ], [ -87.524668, 41.644637 ], [ -87.578588, 41.64473 ], [ -87.580619, 41.65028 ], [ -87.601709, 41.676572 ], [ -87.60172, 41.685837 ], [ -87.592251, 41.703002 ], [ -87.592202, 41.707656 ], [ -87.586051, 41.707765 ], [ -87.585322, 41.709059 ], [ -87.585162, 41.720732 ], [ -87.563165, 41.698022 ], [ -87.563275, 41.706395 ], [ -87.559645, 41.706399 ], [ -87.559775, 41.715404 ], [ -87.569434, 41.715639 ], [ -87.566814, 41.716484 ], [ -87.565902, 41.722585 ], [ -87.556604, 41.722701 ], [ -87.556693, 41.726351 ], [ -87.554907, 41.726374 ], [ -87.557838, 41.729746 ], [ -87.552591, 41.728229 ], [ -87.552639, 41.730057 ], [ -87.555405, 41.730014 ], [ -87.555585, 41.737329 ], [ -87.556887, 41.737313 ], [ -87.555191, 41.744277 ], [ -87.551526, 41.742147 ], [ -87.550325, 41.744674 ], [ -87.541923, 41.744779 ], [ -87.541772, 41.741144 ], [ -87.529645, 41.741412 ], [ -87.530874, 41.748023 ], [ -87.544007, 41.753548 ], [ -87.540739, 41.757435 ], [ -87.524445, 41.760035 ], [ -87.52389, 41.742767 ] ] ] } }
  ,
  { &quot;type&quot;: &quot;Feature&quot;, &quot;properties&quot;: { &quot;OBJECTID&quot;: 11, &quot;District_N&quot;: &quot;11&quot;, &quot;WARD&quot;: 11 }, &quot;geometry&quot;: { &quot;type&quot;: &quot;Polygon&quot;, &quot;coordinates&quot;: [ [ [ -87.647655, 41.874319 ], [ -87.645662, 41.874331 ], [ -87.644767, 41.867185 ], [ -87.639218, 41.867254 ], [ -87.639014, 41.860018 ], [ -87.64194, 41.859984 ], [ -87.641864, 41.857621 ], [ -87.639967, 41.857648 ], [ -87.644938, 41.852666 ], [ -87.638532, 41.852792 ], [ -87.640478, 41.849467 ], [ -87.631965, 41.848252 ], [ -87.629944, 41.846683 ], [ -87.629594, 41.83097 ], [ -87.631504, 41.830939 ], [ -87.631465, 41.829064 ], [ -87.633842, 41.827265 ], [ -87.633763, 41.823616 ], [ -87.636354, 41.823583 ], [ -87.635839, 41.809046 ], [ -87.640679, 41.808952 ], [ -87.641275, 41.805025 ], [ -87.645432, 41.80494 ], [ -87.645538, 41.808864 ], [ -87.65524, 41.808734 ], [ -87.655246, 41.81237 ], [ -87.665064, 41.812222 ], [ -87.665568, 41.830501 ], [ -87.657712, 41.830726 ], [ -87.66436, 41.839375 ], [ -87.664449, 41.844617 ], [ -87.658043, 41.847724 ], [ -87.646473, 41.84919 ], [ -87.646495, 41.852647 ], [ -87.648132, 41.852613 ], [ -87.647673, 41.859898 ], [ -87.656479, 41.859765 ], [ -87.656554, 41.862513 ], [ -87.650937, 41.863499 ], [ -87.652815, 41.873034 ], [ -87.647655, 41.874319 ] ] ] } }
  </code></pre>