ν°μ€ν 리 λ·°
[ Openlayers ] μ€νλ μ΄μ΄μ€μμ μ’νκ³ λ³νμ΄ μλλ κ²½μ°( ol6 κΈ°μ€ )
Kithub 2023. 3. 21. 11:19λ€μμ κ²½μ°λ 5179μ’νκ³λ₯Ό μ¬μ©νλ geojsonμ μ½μ΄λ€μ¬ μ’νκ³ λ³νμ νλ κ²½μ°μ΄λ€.
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
loader: function (extent) {
const url = "./geojson/seoulHD.geojson";//5179
fetch(url)
.then((response) => response.json())
.then((data) => {
const features = vectorSource.getFormat().readFeatures(data);
console.log("λ³νμ - ",features[0].getGeometry().getCoordinates()[0][0][0]);
features.forEach((feature) => feature.getGeometry().transform('EPSG:5179', 'EPSG:3857'));
console.log("λ³νν - ",features[0].getGeometry().getCoordinates()[0][0][0]);
vectorSource.addFeatures(features)
});
},
});
μ½λλ₯Ό μννλ©΄ λ€μκ³Ό κ°μ μ€λ₯κ° λ°μνλ€ .
κ·Έ μ΄μ λ λ€λ₯Έ μ’νκ³κ°μ λ³νμ΄ μ΄λ£¨μ΄μ§λ λ°μνλ μ€λ₯μΈλ°, 'EPSG:5179' μ’νκ³λ₯Ό μ€νλ μ΄μ΄μ€μκ² μΈμμμΌμ£Όμ§ μμκΈ° λλ¬Έμ΄λ€. μ€νλ μ΄μ΄μ€λ κΈ°λ³Έμ μΌλ‘ EPSG:3857μ μΈμνκ³ μμ΄ μ΄μΈ μ’νκ³λ₯Ό λ±λ‘ν΄μ£Όμ΄μΌ νλ€.
μ€νλ μ΄μ΄μ€ 곡μλ¬Έμμμλ λΌμ΄λΈλ¬λ¦¬λ₯Ό ν΅ν΄ μ’νκ³λ₯Ό μμ±νλΌκ³ μλ΄νκ³ μμ΅λλ€.
By default OpenLayers does not know about the EPSG:21781 (Swiss) projection. So we create a projection instance for EPSG:21781 and pass it to register to make it available to the library for lookup by its code.
μ΄λ₯Ό ν΄κ²°νκΈ° μν΄μλ proj4 λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©ν΄ μ’νκ³κ°μ λ³νμ ν μ μκ² ν΄μ£Όμ΄μΌνλ€.
1. proj4.js κ°μ Έμ€κΈ°
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
2. μ’νκ³ λ±λ‘
- μνλ μ’νκ³μ μΈμλ₯Ό λ€μκ³Ό κ°μ΄ μ μνκ³ , λ±λ‘ν΄μ£Όλ©΄ λλ€.
- μ’νκ³ μΈμ νμΈνκΈ°
[μ μ§κ΅¬ μ’νκ³]
μ μΈκ³λ₯Ό νλ²μ λνλ΄μΌ ν λ λ§μ΄ μ°μ΄λ μ’νκ³λ€μ
λλ€.
*WGS84 κ²½μλ: GPSκ° μ¬μ©νλ μ’νκ³
EPSG:4326, EPSG:4166 (Korean 1995)
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
*Bessel 1841 κ²½μλ: νκ΅κ³Ό μΌλ³Έμ μ λ§λ μ§μνμ체λ₯Ό μ¬μ©ν μ’νκ³
EPSG:4004, EPSG:4162 (Korean 1985)
+proj=longlat +ellps=bessel +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*GRS80 κ²½μλ: WGS84μ κ±°μ μ μ¬
EPSG:4019, EPSG:4737 (Korean 2000)
+proj=longlat +ellps=GRS80 +no_defs
*Google Mercator: ꡬκΈμ§λ/λΉμ§λ/μΌνμ§λ/OSM λ± μμ μ¬μ©μ€μΈ μ’νκ³
EPSG:3857(곡μ), EPSG:900913(ν΅μΉ)
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
[UTM]
μ μΈκ³λ₯Ό 6λ λ¨μλ‘ λλλ νμ€μ μΈ TMμΌλ‘ κ΅°μ¬μ§λμμ λ§μ΄ μ¬μ©ν©λλ€.
*UTM52N (WGS84): κ²½λ 120~126λ μ¬μ΄μμ μ¬μ©
EPSG:32652
+proj=utm +zone=52 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
*UTM51N (WGS84): κ²½λ 126~132λ μ¬μ΄μμ μ¬μ©
EPSG:32651
+proj=utm +zone=51 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
[보μ μλ μ€λλ μ§λ¦¬μ νμ€]
μ΄ μ’νκ³λ€μ EPSGμ λ±λ‘λμ΄ μμ§λ§, lon_0κ°μ λ¬Έμ λ‘ μ€μ λ‘λ κ±°μ μ¬μ©λμ§ μμ΅λλ€.
[μ€λλ μ§λ¦¬μ νμ€]μ΄ νμ μμ μ€μ μ¬μ©λ μ’νκ³μ λλ€.
EPSG:2096
+proj=tmerc +lat_0=38 +lon_0=129 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*μ€λΆμμ (Bessel): μμΈ λ± μ€λΆμ§μ
EPSG:2097
+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*μλΆμμ (Bessel): μν΄5λ λ± μλΆμ§μ
EPSG:2098
+proj=tmerc +lat_0=38 +lon_0=125 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
[μ€λλ μ§λ¦¬μ νμ€]
2002λ
μ΄μ μ μ§λ¦¬μμ μ§νλμ KLIS λ± κ΅κ° μμ€ν
μμ μ¬μ©λμλ μ’νκ³μ
λλ€.
EPSG:5173
+proj=tmerc +lat_0=38 +lon_0=125.0028902777778 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*보μ λ μ€λΆμμ (Bessel): KLISμμ μ€λΆμ§μμ μ¬μ©μ€
EPSG:5174
+proj=tmerc +lat_0=38 +lon_0=127.0028902777778 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*보μ λ μ μ£Όμμ (Bessel): KLISμμ μ μ£Όμ§μμ μ¬μ©μ€
EPSG:5175
+proj=tmerc +lat_0=38 +lon_0=127.0028902777778 +k=1 +x_0=200000 +y_0=550000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*보μ λ λλΆμμ (Bessel): KLISμμ λλΆμ§μμ μ¬μ©μ€
EPSG:5176
+proj=tmerc +lat_0=38 +lon_0=129.0028902777778 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*보μ λ λν΄(μΈλ¦)μμ (Bessel): KLISμμ μΈλ¦μ§μμ μ¬μ©μ€
EPSG:5177
+proj=tmerc +lat_0=38 +lon_0=131.0028902777778 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
[KATEC κ³μ΄]
νλ°λ μ 체λ₯Ό νλμ μ’νκ³λ‘ λνλΌ λ λ§μ΄ μ¬μ©νλ μ’νκ³μ
λλ€.
*UTM-K (Bessel): μμ£Όμμ§λμμ μ¬μ© μ€
EPSG:5178
+proj=tmerc +lat_0=38 +lon_0=127.5 +k=0.9996 +x_0=1000000 +y_0=2000000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
*UTM-K (GRS80): λ€μ΄λ²μ§λμμ μ¬μ©μ€μΈ μ’νκ³
EPSG:5179
+proj=tmerc +lat_0=38 +lon_0=127.5 +k=0.9996 +x_0=1000000 +y_0=2000000 +ellps=GRS80 +units=m +no_defs
// 2014λ 1μ 21μΌ μ μν¬ μΆκ°
*λ€λΉκ²μ΄μ μ© KATEC μ’νκ³(KOTI-KATEC)
EPSG μμ. λΉκ³΅μ μ’νκ³μ.
+proj=tmerc +lat_0=38 +lon_0=128 +k=0.9999 +x_0=400000 +y_0=600000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43
[νμ체 λ°κΎΌ μ§λ¦¬μ νμ€]
κ³Όκ±° μ§λ¦¬μ μ’νκ³μμ νμ체μ lon_0 λ¬Έμ λ₯Ό μμ ν μ’νκ³λ‘ 2000λ λ μ΄λ°μ μ μ λ§μ΄ μ¬μ©λμμ΅λλ€.
EPSG:5180
+proj=tmerc +lat_0=38 +lon_0=125 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m +no_defs
*μ€λΆμμ (GRS80)-falseY:50000: λ€μμ§λμμ μ¬μ©μ€μΈ μ’νκ³
EPSG:5181
+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m +no_defs
*μ μ£Όμμ (GRS80)-falseY:55000
EPSG:5182
+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=550000 +ellps=GRS80 +units=m +no_defs
*λλΆμμ (GRS80)-falseY:50000
EPSG:5183
+proj=tmerc +lat_0=38 +lon_0=129 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m +no_defs
*λν΄(μΈλ¦)μμ (GRS80)-falseY:50000
EPSG:5184
+proj=tmerc +lat_0=38 +lon_0=131 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +units=m +no_defs
[νμ¬ κ΅ν μ§λ¦¬μ 보μ νμ€]
2002λ μ΄νμ κ΅ν μ§λ¦¬μ 보μ μ§νλμμ μ¬μ©μ€μΈ μ’νκ³μ λλ€.
*μλΆμμ (GRS80)-falseY:60000
EPSG:5185
+proj=tmerc +lat_0=38 +lon_0=125 +k=1 +x_0=200000 +y_0=600000 +ellps=GRS80 +units=m +no_defs
*μ€λΆμμ (GRS80)-falseY:60000
EPSG:5186
+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=600000 +ellps=GRS80 +units=m +no_defs
*λλΆμμ (GRS80)-falseY:60000
EPSG:5187
+proj=tmerc +lat_0=38 +lon_0=129 +k=1 +x_0=200000 +y_0=600000 +ellps=GRS80 +units=m +no_defs
*λν΄(μΈλ¦)μμ (GRS80)-falseY:60000
EPSG:5188
+proj=tmerc +lat_0=38 +lon_0=131 +k=1 +x_0=200000 +y_0=600000 +ellps=GRS80 +units=m +no_defs
proj4.defs("EPSG:5179", "+proj=tmerc +lat_0=38 +lon_0=127.5 +k=0.9996 +x_0=1000000 +y_0=2000000 +ellps=GRS80 +units=m +no_defs");
ol.proj.proj4.register(proj4);
μ΄μ μμ μ½λλ₯Ό λ€μ μ€ννλ©΄
μ μμ μΌλ‘ μ’νλ³νμ΄ μ΄λ£¨μ΄μ§ κ²μ νμΈ ν μ μλ€.
μ°Έκ³ : https://www.osgeo.kr/17