[Google app script] ์ง€๋ฒˆ์ฃผ์†Œ์—์„œ ๋„๋กœ๋ช…์ฃผ์†Œ ๋ณ€ํ™˜
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋””์ง€ํ„ธ ๊ฟ€ํŒ

[Google app script] ์ง€๋ฒˆ์ฃผ์†Œ์—์„œ ๋„๋กœ๋ช…์ฃผ์†Œ ๋ณ€ํ™˜

by ์ผ์ƒ์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค 2022. 1. 31.

์—…๋ฌด์— ํ•„์š”ํ•˜์—ฌ ์ž‘์—…ํ•˜๊ฒŒ ๋˜์–ด ๊ธ‰ํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ ์Šคํฌ๋ฆฝํŠธ ์ง€๋ฒˆ ์ฃผ์†Œ <-> ๋„๋กœ๋ช… ์ฃผ์†Œ๋ฅผ ์™”๋‹ค๊ฐ”๋‹ค ํ•  ์ˆ˜ ์žˆ๋‹ค

 

์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ณด๊ธฐ ์ „์— ๋„๋กœ๋ช… ์ฃผ์†Œ์— ๋Œ€ํ•œ ๊ฐœ๋…์„ ์•Œ๊ณ  ๊ฐ€์ž!

์šฐ๋ฆฌ๋‚˜๋ผ ํ–‰์ •์•ˆ์ „๋ถ€์—์„œ ์ •์˜ํ•œ ๋ฐ”๋กœ, ๋„๋กœ๋ช… + ๊ฑด๋ฌผ๋ฒˆํ˜ธ๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ์œผ๋ฉฐ,
์‹ ์ฃผ์†Œ์ฒด๊ณ„๋กœ ์˜ˆ์ „ ์ง€๋ฒˆ์ฃผ์†Œ์— ๋„๋กœ๋ช…์ด ์—†๊ฑฐ๋‚˜
๋„๋กœ๋ช… ์ฃผ์†Œ๊ฐ€ ์žˆ์–ด๋„ ์ง€๋ฒˆ์ฃผ์†Œ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒ ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๊ฑธ ํ•˜๋ฉด์„œ ๋Š๋‚€๊ฑด ์šฐ๋ฆฌ๋‚˜๋ผ ์ฃผ์†Œ์ฒด๊ณ„๊ฐ€ ์ฐธ ๋ณ„๋กœ๋ผ๊ณ  ๋Š๋‚€๊ฑฐ๋‹ค
์ง€๋ฒˆ์ฃผ์†Œ/๋„๋กœ๋ช… ์ฃผ์†Œ๋„ ๋‚˜๋‰˜๊ณ  ํ–‰์ •๋™/๋ฒ•์ •๋™์œผ๋กœ ๋™๋„ ๋‚˜๋‰˜๊ณ .. 

 

๋„๋กœ๋ช…์ฃผ์†Œ ์†Œ๊ฐœ | ๋„๋กœ๋ช…์ฃผ์†Œ ์•ˆ๋‚ด์‹œ์Šคํ…œ

์ด์ „ ๋‹ค์Œ ๋„๋กœ๋ช…์ฃผ์†Œ ์†Œ๊ฐœ Guide bookIntroduce Road name address ๋„๋กœ๋ช…์ฃผ์†Œ ์•ˆ๋‚ด์‹œ์Šคํ…œ ๋„๋กœ๋ช…์ฃผ์†Œ ์†Œ๊ฐœ chapter 1 ๋„๋กœ๋ช…์ฃผ์†Œ๋ž€? "๋„๋กœ๋ช…์ฃผ์†Œ"๋ž€ ๋ถ€์—ฌ๋œ ๋„๋กœ๋ช…, ๊ธฐ์ดˆ๋ฒˆํ˜ธ, ๊ฑด๋ฌผ๋ฒˆํ˜ธ, ์ƒ์„ธ์ฃผ์†Œ์— ์˜ํ•˜์—ฌ

www.juso.go.kr

์œ„ ๋ฌธ์„œ๋ฅผ ๋ณด๋ฉด ๋„๋กœ๋ช…์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์„ค๋ช…๋˜์–ด ์žˆ๋‹ค.

์กฐ๊ฑด

1. ์ƒ์„ธ์ฃผ์†Œ๋Š” ๋ณ€ํ™˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
2. ์ง€๋ฒˆ์ฃผ์†Œ๋ฅผ ๋„๋กœ๋ช… ์ฃผ์†Œ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค

์ฒ˜์Œ์— ๋‚ด๊ฐ€ ์ƒ์„ธ ์ฃผ์†Œ์— ๋Œ€ํ•œ ๊ฐœ๋…์„ ๋ชจ๋ฅด๊ณ  ์‚ฝ์งˆํ•œ ๊ฑธ ์ƒ๊ฐํ•˜๋ฉด ์–ด์ด๊ฐ€ ์—†๋‹ค ๐Ÿ˜ฅ 

์นด์นด์˜ค API ์‚ฌ์šฉ

function getRoadAddress(jibunAddr) {

	var appKey = 'KakaoAK xxxxxxxxxxxxxxxxxx'; //kakao apiKey
    var url = 'https://dapi.kakao.com/v2/local/search/address.json?query='//api
	var road = ''; //๋„๋กœ๋ช… ์ฃผ์†Œ

	url = url + jibunAddr; // url + ์ง€๋ฒˆ ์ฃผ์†Œ
 
    var response = UrlFetchApp.fetch(url, 
      {
        'method' : 'GET',
        'headers': {                    
          'Authorization': appKey
        }
      });
        
    var resData = response.getContentText();
    resData = JSON.parse(resData);
    
    try {
      road = resData.documents[0].road_address.address_name;
    }catch(e){
      road = 'Error :' + e
      console.log(e, addr);
    }

  return road;
}
๋ฐ˜์‘ํ˜•

๋„ค์ด๋ฒ„ API ์‚ฌ์šฉ

function getNaverAddress(addr) { 

  var apiURL  = 'https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query=' + addr;

  var response = UrlFetchApp.fetch(apiURL,{'method' : 'GET',
          'headers': {                    
            'X-NCP-APIGW-API-KEY-ID' : 'client key',
            'X-NCP-APIGW-API-KEY' : 'secret key'}
      });          

  var resData = response.getContentText();
  resData = JSON.parse(resData);

  try {
      road = resData.addresses[0].roadAddress;
  
      if (road == ''){
        road = '์ •๋ณด ์—†์Œ(๊ณต๋ž€)'
      } 
  }catch(e){
      road = 'Error :' + e
      console.log(e, addr);
  }

  return road;
}

 

์œ„ ์†Œ์Šค๋ฅผ ๋ณด๊ณ  ์–ด๋ ต๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ ๋‹ค๋ฉด, ๋จผ์ € ๊ตฌ๊ธ€ ์•ฑ์Šคํฌ๋ฆฝํŠธ ์‹œ์ž‘ํ•˜๋Š” ๋ฐฉ๋ฒ• ๋ถ€ํ„ฐ ์ตํ˜€์•ผ ํ•œ๋‹ค.

ํ˜น์‹œ๋ผ๋„ ์–ด๋ ค์›Œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ํ•ด์„œ ํ•˜๊ณ  ์‹ถ์œผ์‹  ์ดˆ๋ณด์ž๋“ค์€ ์•„๋ž˜ ๋‚ด์šฉ ํ™•์ธ 

 

์—‘์…€ ์ „๋ฌธ๊ฐ€๊ฐ€ ๋งŒ๋“ค์–ด ๋†“์œผ์‹  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ - windows๋งŒ ๊ฐ€๋Šฅ

- KakaoAddress ํ•จ์ˆ˜ ์ถ”๊ฐ€๊ธฐ๋Šฅ (๋„๋กœ๋ช…์ฃผ์†Œ ์ง€๋ฒˆ์ฃผ์†Œ ์ž๋™๋ณ€ํ™˜)

๋Œ“๊ธ€