9
VWORLD API C# 에에 에에 에에 : 에에에 에에 에에

Vworld api desktop에서 쓰기

Embed Size (px)

Citation preview

Page 1: Vworld api desktop에서 쓰기

VWORLD API C# 에서 쓰기

정리 : 세월을 낚는 어부

Page 2: Vworld api desktop에서 쓰기

실습순서• VWORLD 키 획득• VWORLD API 연동 클래스 설명• 주소에서 위경도 가져오기 실습• 위경도 에서 주소 가져오기 실습• 구글 에서 고도 값 가져오기 실습• proj4.net 과 geoapi .net dll 을 이용하여 TM 좌표로 변환

실습

Page 3: Vworld api desktop에서 쓰기

VWORLD KEY 획득

- 회원가입 후 로그인해서 사용자정보 등 등록 .- URL 을 등록하고 , 인증키를 받음 - 키를 붙임

Page 4: Vworld api desktop에서 쓰기

실습에 필요한 개발환경- vs2010 이상- Geoapi.net, pro4j.Net

Page 5: Vworld api desktop에서 쓰기

Vworld API 연동 클래스 설명

*

.vworldrefer.cspublic XmlDocument GetVWorldData(string qUrl): VWorld 의 지도 및 데이터 레퍼런스 API 를 이용해서 원하는 값을 Xml 형식으로 반환public LonLat JibunToLonLat(string Jibun): 지번을 좌표로 변환public LonLat DoRoToLonLat(string DoRo): 도로명 주소를 좌표로 변환public List<string> GetJiBunAddr(string Lat, string Lon): 경위도를 지번으로 변환 public List<string> GetDoRoNameAddr(string Lat, string Lon): 경위도로 도로명 변환 public double getElevation(double latitude, double longitude): 경위도로 구글 고도 값 가져오기*.Struct.cs 데이터구조public class LonLat { public LonLat() { Lat = 0; Lon = 0; } public LonLat(double Lat, double Lon) { this.Lat = Lat; this.Lon = Lon; } public double Lat { get; set; } public double Lon { get; set; }

public string LAT { get; set; } }

Page 6: Vworld api desktop에서 쓰기

1. 주소를 좌표로 변환하기public void jusocoord(string juso, string type) { LonLat ll4326 = new LonLat(); if( type.Equals("jibun")){

ll4326 = vworld.JibunToLonLat(juso);

}

if (type.Equals("newaddr")) {

ll4326 = vworld.DoRoToLonLat(juso);

} txt_lat.Text = ll4326.Lat.ToString(); txt_lon.Text = ll4326.Lon.ToString(); //return coordinate; }

Page 7: Vworld api desktop에서 쓰기

2. 좌표를 주소로 변환하기public void coordtojuso(string lat, string lon , string type) { string addressText = string.Empty; string tempaddress = string.Empty; List<string> addr = null; if (type.Equals("jibun")) { addr = vworld.GetJiBunAddr(lat, lon); } if (type.Equals("newaddr")) { addr = vworld.GetDoRoNameAddr(lat, lon); } // List<string> doro = vr.GetDoRoNameAddr(lat, lon);

int cnt = addr.Count; for (int i=0;i<cnt;i++) { if (cnt > 0) { tempaddress = addr[i] + " "; addressText = addressText + tempaddress; tempaddress = null; } // addressText = " 해당주소 없음 "; } this.txtjuso.Text = addressText; }

Page 8: Vworld api desktop에서 쓰기

3. 고도 값 보기 double lat = Convert.ToDouble(txt_lat.Text); double lon = Convert.ToDouble(txt_lon.Text); double elev = vworld.getElevation(lat, lon); txtElev.Text = elev.ToString();

4. 좌표변환해보기

Page 9: Vworld api desktop에서 쓰기

public void ConvertLonLatToLonLat(double sLat, double sLon) { String epsg = cboEpsg.Text; String proj = cboEpsg.SelectedValue.ToString(); var crsFactory = new Proj4Net.CoordinateReferenceSystemFactory(); var crsSource = crsFactory.CreateFromParameters("EPSG:4326", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"); var crsTarget = crsFactory.CreateFromParameters(epsg, proj); var transformFactory = new Proj4Net.CoordinateTransformFactory(); var transform = transformFactory.CreateTransform(crsSource, crsTarget); var NewPT = new GeoAPI.Geometries.Coordinate(); transform.Transform(new GeoAPI.Geometries.Coordinate(sLon, sLat), NewPT);

txtNx.Text = NewPT.X.ToString(); txtEy.Text = NewPT.Y.ToString(); }