SlideShare a Scribd company logo
VWORLD API C# 에서 쓰기
정리: 세월을 낚는 어부
실습순서
• VWORLD 키 획득
• VWORLD API 연동 클래스 설명
• 주소에서 위경도 가져오기 실습
• 위경도 에서 주소 가져오기 실습
• 구글 에서 고도 값 가져오기 실습
• proj4.net 과 geoapi .net dll을 이용하여 TM좌표로 변환 실습
VWORLD KEY 획득
- 회원가입 후 로그인해서 사용자정보 등 등록.
- URL을 등록하고 ,인증키를 받음
- 키를 붙임
실습에 필요한 개발환경
- vs2010 이상
- Geoapi.net, pro4j.Net
Vworld API 연동 클래스 설명
.vworldrefer.cs
public 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; }
}
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;
}
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;
}
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. 좌표변환해보기
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();
}

More Related Content

PDF
Whats new rails 7
PPTX
Intro to algorithms
PDF
Browser Engineering - Ch1 Summary
PDF
[Swift] Protocol (2/2)
PPTX
게임에서 사용할 수 있는 포물선 운동
PPTX
전자해도세미나
PDF
전자해도 표준과 뷰어 (최규성)
PDF
한국에서 오픈소스GIS로 사업하기
Whats new rails 7
Intro to algorithms
Browser Engineering - Ch1 Summary
[Swift] Protocol (2/2)
게임에서 사용할 수 있는 포물선 운동
전자해도세미나
전자해도 표준과 뷰어 (최규성)
한국에서 오픈소스GIS로 사업하기

More from Jiyoon Kim (9)

PPTX
Foss4 g kr-workshop_gps_2021
PPTX
Qgis에서 GPS 연동
PPTX
Python qgis advanced
PPTX
Geo tools Data Transfer
PPT
Pyqgis 기초편
PPTX
Mongodb and spatial
PPTX
osgeo 봄 세미나 -R
PPTX
웃는동안 배우는 Qgis
PPT
웃으면서Python
Foss4 g kr-workshop_gps_2021
Qgis에서 GPS 연동
Python qgis advanced
Geo tools Data Transfer
Pyqgis 기초편
Mongodb and spatial
osgeo 봄 세미나 -R
웃는동안 배우는 Qgis
웃으면서Python
Ad

Vworld api desktop에서 쓰기

  • 1. VWORLD API C# 에서 쓰기 정리: 세월을 낚는 어부
  • 2. 실습순서 • VWORLD 키 획득 • VWORLD API 연동 클래스 설명 • 주소에서 위경도 가져오기 실습 • 위경도 에서 주소 가져오기 실습 • 구글 에서 고도 값 가져오기 실습 • proj4.net 과 geoapi .net dll을 이용하여 TM좌표로 변환 실습
  • 3. VWORLD KEY 획득 - 회원가입 후 로그인해서 사용자정보 등 등록. - URL을 등록하고 ,인증키를 받음 - 키를 붙임
  • 4. 실습에 필요한 개발환경 - vs2010 이상 - Geoapi.net, pro4j.Net
  • 5. Vworld API 연동 클래스 설명 .vworldrefer.cs public 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; } }
  • 6. 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; }
  • 7. 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; }
  • 8. 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. 좌표변환해보기
  • 9. 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(); }