scraly / developers-conferences-agenda

This repository list a maximum of tech conferences's date and CFP in order to help conferences organizers, speakers & attendees
https://developers.events/
1.61k stars 393 forks source link

Unable to get geocode for location #1049

Closed scraly closed 3 months ago

scraly commented 3 months ago

I've got two troubles to identify geocoding even if it's working on openstreetmap website

Unable to get geocode for location:  Tacoma, WA (USA)
Unable to get geocode for location:  Burlington, VT (USA)
Unable to get geocode for location:  Yogyakarta (Indonesia)
Unable to get geocode for location:  Hyderabad (India)
Unable to get geocode for location:  Metro Manila (Philippines)
* 20: [GitHub Field Philippines](https://githubfieldday.com/ph2024/) - Philippines
HanzCEO commented 3 months ago

Upon deeper inspection, not providing 'User-Agent' header violates OSM Policy: image

This works:

const fetch = require('fix-esm').require('node-fetch').default;

const NodeGeocoder = require('node-geocoder');
let options = {
  provider: 'openstreetmap',
  fetch(url, options) {
    return fetch(url, {...options, headers: { 'user-agent': 'dca-0' }})
  }
};

const geocoder = NodeGeocoder(options);
const locations = ['Tacoma, WA (USA)'];

geocoder.batchGeocode(locations).then(result => {
  console.dir(result, {depth:null});
});
scraly commented 3 months ago

Thanks! Fixed in commit: https://github.com/scraly/developers-conferences-agenda/commit/eb3f09301ddca2abeede5818b07db7866b73763b

dca-0 is a good idea for a unique user-agent thanks :)