Constructor
new SpatialMath()
객체 초기 상태를 설정한다.
Methods
ComputeEllipsoidArea(positions) → {number}
주어진 다각형 좌표값(lon, lat)으로 면적을 계산한다.
Parameters:
Name | Type | Description |
---|---|---|
positions |
array | 다각형 좌표 배열값(positions[0].lat, positions[0].lon으로 관리) |
Returns:
면적값 반환
- Type
- number
containSphere(centerx, centery, centerz, radius, x, y, z) → {number}
주어진 구체(Sphere)내부에 임의 점(x, y, z)이 포함되어 있는지 판단한다.
Parameters:
Name | Type | Description |
---|---|---|
centerx |
number | 구체 중심의 x값 |
centery |
number | 구체 중심의 y값 |
centerz |
number | 구체 중심의 z값 |
radius |
number | 구체 반지름 |
x |
number | 임의 지점의 x값 |
y |
number | 임의 지점의 y값 |
z |
number | 임의 지점의 z값 |
Returns:
포함 여부 반환(1:내부 포함, 0:구체 표면 존재, -1:외부 존재)
- Type
- number
destGeographic(lon, lat, angle, distance) → {object}
임의지점(lon, lat)과 방위각(degree), 거리(m)가 주어졌을때 목표 지점의 좌표값(lon, lat)을 구한다.
계산 알고리즘은https://www.movable-type.co.uk/scripts/latlong.html Formula가 적용되어 있다.
Example
//경위도값과 각도, 거리를 입력하여 대상 지점(lon, lat)을 구한다.
var result = window.spatialMath.destGeographic(127.15, 36.15, 135, 10000);
//대상 지점을 Google Mercator 좌표값으로 변환한다.
var mercator = ol.proj.transform([result.lon, result.lat], 'EPSG:4326', 'EPSG:3857'); //Convert geographic to Google Mercator
console.log(mercator);
Parameters:
Name | Type | Description |
---|---|---|
lon |
number | 경도(degree) |
lat |
number | 위도(degree) |
angle |
number | 방위각(degree) |
distance |
number | 거리(m) |
Returns:
목표 지점의 lon(경도), lat(위도)값 반환
- Type
- object
destVincenty(lon1, lat1, brng, dist) → {object}
임의지점(lon, lat)과 방위각(degree), 거리(m)가 주어졌을때 목표 지점의 좌표값(lon, lat)을 구한다.
계산 알고리즘은 http://www.movable-type.co.uk/scripts/latlong-vincenty.html#direct가 적용되어 있다.
Example
//Google Mercator 좌표값을 경위도로 변환한다.
var epsg4326 = ol.proj.transform(mercatorCoordinate, 'EPSG:3857', 'EPSG:4326'); //Convert Google Mercator to geographic
//변환된 경위도 값을 기준으로 135도, 10000m 떨어진 대상 지점을 구한다.
var result = window.spatialMath.destVincenty(epsg4326[0], epsg4326[1], 135, 10000);
//경위도로 변환된 좌표값을 Google Mercator 좌표값으로 변환한다.
var mercator ol.proj.transform([result.lon, result.lat], 'EPSG:4326', 'EPSG:3857'); //Convert geographic to Google Mercator
console.log(mercator);
Parameters:
Name | Type | Description |
---|---|---|
lon1 |
number | 경도(degree) |
lat1 |
number | 위도(degree) |
brng |
number | 방위각(degree) |
dist |
number | 거리(m) |
Returns:
목표 지점의 lon(경도), lat(위도)값 반환
- Type
- object
distVincenty(lon1, lat1, lon2, lat2) → {number}
위/경도 형식의 두 점이 주어졌을때 거리를 구한다.
계산 알고리즘은 Vincenty's Formula가 적용되어 있다.
Parameters:
Name | Type | Description |
---|---|---|
lon1 |
number | 경도(degree) |
lat1 |
number | 위도(degree) |
lon2 |
number | 경도(degree) |
lat2 |
number | 위도(degree) |
Returns:
거리(m) 반환
- Type
- number
getAngleBetweenPoints(x1, y1, x2, y2) → {number}
두 지점간의 각도를 구한다.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | 임의 지점의 x1값 |
y1 |
number | 임의 지점의 y1값 |
x2 |
number | 임의 지점의 x2값 |
y2 |
number | 임의 지점의 y2값 |
Returns:
각도(Radian) 반환
- Type
- number
getBearing(startGeo, endGeo) → {string}
경위도 좌표 기준의 두 지점간의 방위각을 반환한다.
방위각이란 자신이 서 있는 위치를 중심으로 북쪽을 기준으로 삼고 시계 바늘 방향으로 잰 동, 서, 남, 북의 방위가 있는 각도를 의미한다.
정북 방위각은 0 또는 360이고
동 방위각은 90도
남 방위각은 180도
서 방위각은 270도 이다.
Parameters:
Name | Type | Description |
---|---|---|
startGeo |
number | 경위도(Degree) 시작점 좌표 |
endGeo |
number | 경위도(Degree) 끝점 좌표 |
Returns:
방위각 반환
- Type
- string
getBearingByMercator(start, end) → {string}
Google Mercator 좌표 기준의 두 점간의 방위각을 반환한다.
방위각이란 자신이 서 있는 위치를 중심으로 북쪽을 기준으로 삼고 시계 바늘 방향으로 잰 동, 서, 남, 북의 방위가 있는 각도를 의미한다.
정북 방위각은 0 또는 360이고
동 방위각은 90도
남 방위각은 180도
서 방위각은 270도 이다.
Parameters:
Name | Type | Description |
---|---|---|
start |
number | Google Mercator 시작점 좌표 |
end |
number | Google Mercator 끝점 좌표 |
Returns:
방위각 반환
- Type
- string
getCoordinateFromPixel(pixel) → {object}
화면 좌표값으로부터 Google Mercator 좌표값을 계산한다.
모니터 해상도에 따른 픽셀값을 고려하여 화면좌표값을 처리한다.
Parameters:
Name | Type | Description |
---|---|---|
pixel |
object | 화면 좌표값 설정 |
Returns:
Google Mercator 좌표값 반환
- Type
- object
getHeight(lon, lat, callbackFunc)
입력 지점의 고도값(m)를 callback 형식으로 반환한다.
Example
window.spatialMath.getHeight(lon, lat, result => {
console.log('height is ', result);
});
Parameters:
Name | Type | Description |
---|---|---|
lon |
number | 경도(Degree) 좌표 |
lat |
number | 위도(Degree) 좌표 |
callbackFunc |
callbackFunc | 입력 지점에 고도값(m)을 callback 값으로 반환한다. |
getMapScale() → {number}
현재 축적을 표시한다.
Returns:
현재 축척 반환
- Type
- number
getMax(array)
입력값들 중 최대값을 구한다.
Parameters:
Name | Type | Description |
---|---|---|
array |
object | 배열값 설정 |
getMin(array)
입력값들 중 최소값을 구한다.
Parameters:
Name | Type | Description |
---|---|---|
array |
object | 배열값 설정 |
getMinMax(xArray, yArray) → {object}
x, y 입력값들중 최대/최소값을 반환한다.
Parameters:
Name | Type | Description |
---|---|---|
xArray |
object | x 배열값 설정 |
yArray |
object | y 배열값 설정 |
Returns:
Google Mercator 좌표값 기준으로 결과 반환
- Type
- object
getNormalizeCoordinate(mercatorCoordinate) → {object}
Google Mercator 좌표값을 정규화(전세계 유효범위) 처리한다.
Parameters:
Name | Type | Description |
---|---|---|
mercatorCoordinate |
number | Google Mercator 좌표값 |
Returns:
정규화된 Google Mercator 좌표값 반환
- Type
- object
getPixelFromCoordinate(coordinate) → {object}
Google Mercator 입력 좌표값으로부터 화면좌표값을 계산한다.
모니터 해상도에 따른 픽셀값을 고려하여 화면좌표값을 처리한다.
Parameters:
Name | Type | Description |
---|---|---|
coordinate |
object | 좌표값 설정 |
Returns:
화면 좌표값 반환
- Type
- object
getZoomLevel() → {number}
현재 지도 Zoom 레벨값을 반환한다.
Zoom 레벨별 서비스 축척은 아래와 같다.
3 레벨은 축척으로 55,467,893 이다.
4 레벨은 축척으로 27,733,947 이다.
5 레벨은 축척으로 13,866,973 이다.
6 레벨은 축척으로 6,933,487 이다.
7 레벨은 축척으로 3,466,743 이다.
8 레벨은 축척으로 1,733,372 이다.
9 레벨은 축척으로 866,686 이다.
10 레벨은 축척으로 433,343 이다.
11 레벨은 축척으로 216,671 이다.
12 레벨은 축척으로 108,336 이다.
13 레벨은 축척으로 54,168 이다.
14 레벨은 축척으로 27,084 이다.
15 레벨은 축척으로 13,542 이다.
16 레벨은 축척으로 6,771 이다.
17 레벨은 축척으로 3,385 이다.
18 레벨은 축척으로 1,693 이다.
19 레벨은 축척으로 846 이다.
Returns:
현재 지도 Zoom 레벨 반환
- Type
- number
normalizeAngle(angle) → {number}
입력 각도가 360가 넘지 않도록 정규화 처리한다.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | 입력 각도(degree) |
Returns:
정규화된 각도 반환
- Type
- number
setMapScale(scale)
현재 축적을 설정한다.
타일맵 해상도를 기준으로 지도 축척이 정해지므로 입력 축척값은 레벨별 축척 범위에 값으로 자동 전환되어 적용된다.
Parameters:
Name | Type | Description |
---|---|---|
scale |
number | 축적값 설정 |
setZoomLevel(val)
현재 지도 Zoom 레벨을 설정한다.
Zoom 레벨은 3 ~ 19까지 지원한다.
3 레벨은 축적으로 55,467,893이며 19 레벨은 축척으로 846에 해당한다.
Parameters:
Name | Type | Description |
---|---|---|
val |
number | Zoom 레벨 설정 |
toDeg(n)
입력값을 degree로 변환한다.
Example
window.spatialMath.toDeg(0.567);
Parameters:
Name | Type | Description |
---|---|---|
n |
number | 입력값 |
Returns:
degree 리턴
toRad(n)
입력값을 radian으로 변환한다.
Example
window.spatialMath.toRad(125);
Parameters:
Name | Type | Description |
---|---|---|
n |
number | 입력값 |
Returns:
radian 반환
Validate_Point_In_Bound(minX, minY, maxX, maxY, x, y) → {bool}
주어진 사각형 영역내에 임의 점(a, b)이 포함되는지 여부를 판단한다.
Parameters:
Name | Type | Description |
---|---|---|
minX |
number | 사각형 x축 최소값 |
minY |
number | 사각형 y축 최소값 |
maxX |
number | 사각형 x축 최대값 |
maxY |
number | 사각형 y축 최대값 |
x |
number | 임의 지점의 x값 |
y |
number | 임의 지점의 y값 |
Returns:
포함 여부 반환
- Type
- bool
Validate_Point_In_Circle(a, b, x, y, r) → {bool}
반경(r)이 주어진 원(x, y)에 임의 점(a, b)이 포함되는지 여부를 판단한다.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | 임의 지점의 x값 |
b |
number | 임의 지점의 y값 |
x |
number | 원 중심의 x값 |
y |
number | 원 중심의 y값 |
r |
number | 원 반지름 |
Returns:
포함 여부 반환
- Type
- bool
ValidatePolygonInPointByCartographic(positions, x, y) → {bool}
주어진 다각형 영역내에 경위도 임의 점(a, b)이 포함되는지 여부를 판단한다.
Parameters:
Name | Type | Description |
---|---|---|
positions |
array | 다각형 좌표 배열값(positions[0].latitude, positions[0].longitude로 관리) |
x |
number | 임의 지점의 x값 |
y |
number | 임의 지점의 y값 |
Returns:
포함 여부 반환
- Type
- bool
ValidatePolygonInPointByMercator(polygon, x, y) → {bool}
주어진 다각형 영역내에 직교좌표 임의 점(a, b)이 포함되는지 여부를 판단한다.
Parameters:
Name | Type | Description |
---|---|---|
polygon |
array | 다각형 좌표 배열값(polygon[0][0], polygon[0][1]로 관리) |
x |
number | 임의 지점의 x값 |
y |
number | 임의 지점의 y값 |
Returns:
포함 여부 반환
- Type
- bool