index.js
// This function checks what city a point coordinate is in based on polygons of cities
This function checks what city a point coordinate is in based on polygons of cities
This function checks what city a point coordinate is in based on polygons of cities
function coordInPolygon(centerCoord, polygons) {
  let city = undefined
  let cities = polygons.features
  for (let i = 0; i < cities.length; i++) {
    let cityCoords = cities[i].geometry.coordinates[0]
    for (let j = 0; j < cityCoords.length; j++) {
      if (inside(centerCoord, cityCoords[j])) {
        city = cities[i].properties.name;
        return city
      }
    }
  }
  return city;
}
function coordInPolygon ( centerCoord , polygons ) { let city = undefined let cities = polygons . features for ( let i = 0 ; i < cities . length ; i ++ ) { let cityCoords = cities [ i ] . geometry . coordinates [ 0 ] for ( let j = 0 ; j < cityCoords . length ; j ++ ) { if ( inside ( centerCoord , cityCoords [ j ] ) ) { city = cities [ i ] . properties . name ; return city } } } return city ; }
This function checks what city a point coordinate is in based on polygons of cities
This function checks what city a point coordinate is in based on polygons of cities