Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnteee/084905055529ef1b4bcbf7f699edff08 to your computer and use it in GitHub Desktop.
Save johnteee/084905055529ef1b4bcbf7f699edff08 to your computer and use it in GitHub Desktop.
let data = [{"County":"嘉義縣","PublishAgency":"環境保護署","PublishTime":"2018-03-05 09:00","SiteName":"塔塔加","UVI":"","WGS84Lat":"23,28,14.19","WGS84Lon":"120,52,50.06"},{"County":"嘉義市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"嘉義","UVI":"3.32","WGS84Lat":"23,29,45","WGS84Lon":"120,25,58"},{"County":"臺中市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"臺中","UVI":"2.38","WGS84Lat":"24,08,45","WGS84Lon":"120,41,03"},{"County":"澎湖縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"澎湖","UVI":"4.77","WGS84Lat":"23,33,56","WGS84Lon":"119,33,47"},{"County":"宜蘭縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"宜蘭","UVI":"4.10","WGS84Lat":"24,45,50","WGS84Lon":"121,45,24"},{"County":"金門縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"金門","UVI":"5.34","WGS84Lat":"24,24,26","WGS84Lon":"118,17,21"},{"County":"南投縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"日月潭","UVI":"1.42","WGS84Lat":"23,52,53","WGS84Lon":"120,54,29"},{"County":"臺東縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"臺東","UVI":"1.55","WGS84Lat":"22,45,08","WGS84Lon":"121,09,17"},{"County":"臺東縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"蘭嶼","UVI":"0.93","WGS84Lat":"22,02,13","WGS84Lon":"121,33,30"},{"County":"桃園市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"新屋","UVI":"4.16","WGS84Lat":"25,00,24","WGS84Lon":"121,02,51"},{"County":"基隆市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"基隆","UVI":"2.93","WGS84Lat":"25,07,60","WGS84Lon":"121,44,26"},{"County":"臺東縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"成功","UVI":"0.82","WGS84Lat":"23,05,51","WGS84Lon":"121,22,24"},{"County":"臺北市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"臺北","UVI":"2.84","WGS84Lat":"25,02,16","WGS84Lon":"121,30,53"},{"County":"屏東縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"恆春","UVI":"2.08","WGS84Lat":"22,00,14","WGS84Lon":"120,44,47"},{"County":"臺北市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"鞍部","UVI":"2.56","WGS84Lat":"25,10,57","WGS84Lon":"121,31,47"},{"County":"新竹縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"新竹","UVI":"4.04","WGS84Lat":"24,49,40","WGS84Lon":"121,00,51"},{"County":"臺南市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"臺南","UVI":"3.66","WGS84Lat":"22,59,36","WGS84Lon":"120,12,17"},{"County":"南投縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"玉山","UVI":"8.32","WGS84Lat":"23,29,15","WGS84Lon":"120,57,34"},{"County":"高雄市","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"高雄","UVI":"2.54","WGS84Lat":"22,33,58","WGS84Lon":"120,18,57"},{"County":"連江縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"馬祖","UVI":"3.83","WGS84Lat":"26,10,09","WGS84Lon":"119,55,24"},{"County":"花蓮縣","PublishAgency":"中央氣象局","PublishTime":"2018-03-09 15:00","SiteName":"花蓮","UVI":"0.39","WGS84Lat":"23,58,30","WGS84Lon":"121,36,48"},{"County":"新北市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"淡水","UVI":"3","WGS84Lat":"25,09,52.20","WGS84Lon":"121,26,57.26"},{"County":"新北市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"板橋","UVI":"3","WGS84Lat":"25,00,46.7","WGS84Lon":"121,27,31.2"},{"County":"桃園市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"桃園","UVI":"3","WGS84Lat":"24,59,41.24","WGS84Lon":"121,19,11.87"},{"County":"苗栗縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"苗栗","UVI":"4","WGS84Lat":"24,33,54.97","WGS84Lon":"120,49,12.72"},{"County":"臺中市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"沙鹿","UVI":"4","WGS84Lat":"24,13,32.26","WGS84Lon":"120,34,7.66"},{"County":"彰化縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"彰化","UVI":"4","WGS84Lat":"24,03,57.60","WGS84Lon":"120,32,29.47"},{"County":"南投縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"南投","UVI":"2","WGS84Lat":"23,54,46.8","WGS84Lon":"120,41,7.1"},{"County":"雲林縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"斗六","UVI":"3","WGS84Lat":"23,42,42.67","WGS84Lon":"120,32,41.98"},{"County":"嘉義縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 13:00","SiteName":"阿里山","UVI":"","WGS84Lat":"23,30,30.82","WGS84Lon":"120,48,05.02"},{"County":"嘉義縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"朴子","UVI":"5","WGS84Lat":"23,27,55.11","WGS84Lon":"120,14,50.46"},{"County":"臺南市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"新營","UVI":"4","WGS84Lat":"23,18,20.28","WGS84Lon":"120,19,2.10"},{"County":"高雄市","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"橋頭","UVI":"3","WGS84Lat":"22,45,27.02","WGS84Lon":"120,18,20.48"},{"County":"屏東縣","PublishAgency":"環境保護署","PublishTime":"2018-03-09 15:00","SiteName":"屏東","UVI":"2","WGS84Lat":"22,40,23.09","WGS84Lon":"120,29,16.92"}]
data.forEach(function(item){
let rawLat = item['WGS84Lat'];
let rawLon = item['WGS84Lon'];
let rawLatArr = rawLat.split(',')
let rawLonArr = rawLon.split(',')
let lat = (+rawLatArr[0]) + (+rawLatArr[1])/60 + (+rawLatArr[2])/3600;
let lon = (+rawLonArr[0]) + (+rawLonArr[1])/60 + (+rawLonArr[2])/3600;
console.log(`${item['County']}, ${lat}, ${lon} , ${rawLat}, ${rawLon}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment