SlideShare une entreprise Scribd logo
1  sur  9
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();
}

Contenu connexe

Plus de Jiyoon Kim

Foss4 g kr-workshop_gps_2021
Foss4 g kr-workshop_gps_2021Foss4 g kr-workshop_gps_2021
Foss4 g kr-workshop_gps_2021Jiyoon Kim
 
Qgis에서 GPS 연동
Qgis에서 GPS 연동Qgis에서 GPS 연동
Qgis에서 GPS 연동Jiyoon Kim
 
Python qgis advanced
Python qgis advancedPython qgis advanced
Python qgis advancedJiyoon Kim
 
Geo tools Data Transfer
Geo tools Data TransferGeo tools Data Transfer
Geo tools Data TransferJiyoon Kim
 
Pyqgis 기초편
Pyqgis 기초편Pyqgis 기초편
Pyqgis 기초편Jiyoon Kim
 
Mongodb and spatial
Mongodb and spatialMongodb and spatial
Mongodb and spatialJiyoon Kim
 
osgeo 봄 세미나 -R
osgeo 봄 세미나 -Rosgeo 봄 세미나 -R
osgeo 봄 세미나 -RJiyoon Kim
 
웃는동안 배우는 Qgis
웃는동안 배우는 Qgis웃는동안 배우는 Qgis
웃는동안 배우는 QgisJiyoon Kim
 
웃으면서Python
웃으면서Python웃으면서Python
웃으면서PythonJiyoon Kim
 

Plus de Jiyoon Kim (9)

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

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(); }