기하, 좌표 변환, MGRS
WKB·WKT에서 기하를 만들고, 범위와 길이·면적을 구하거나 교차·포함을 판정할 수 있습니다. 좌표 변환은 대상 좌표 참조계(CRS)의 축 순서와 단위를 따릅니다. MGRS는 WGS 84 위치 또는 EPSG CRS 좌표를 정해진 크기의 UTM·UPS 격자 칸으로 표현합니다.
.NET에서 사용하기
좌표를 다른 CRS로 바꾸거나 기하의 공간 관계를 계산할 때 사용합니다. 좌표 한 점은 좌표 변환, 피처 기하는 기하 변환을 선택합니다. SRID 표기와 실제 좌표 변환을 구별합니다.
호출 순서: 입력 CRS 확인 → 출력 CRS 구성 → 변환 → 결과와 오류 확인.
Note
길이·면적의 단위와 축 순서는 호출별 계약을 확인합니다. 좌표에 EPSG 번호를 붙이는 것만으로 재투영되지 않습니다.
개념과 사용 순서 · 관계와 처리 흐름 · .NET 시작하기
C# 실행 예제
아래는 SDK 샘플의 실제 코드 영역입니다. 초기화·오류 처리·해제를 포함한 전체 흐름은 사용 가이드에서 확인하세요.
// TransformPoint returns the transformed point. A point that cannot be
// transformed (the transform itself is fine, this coordinate is not)
// throws glsGdkException; native code reports it as *outTransformed ==
// false. For EPSG:4326 the input order is X = longitude, Y = latitude.
private static bool TransformPoint()
{
using (glsSpatialReference wgs84 = glsSpatialReference.FromEpsg(4326))
using (glsSpatialReference mercator = glsSpatialReference.FromEpsg(3857))
using (glsCoordinateTransform toMercator = wgs84.CreateTransformTo(mercator))
using (glsCoordinateTransform toWgs84 = mercator.CreateTransformTo(wgs84))
{
glsMapPoint point = toMercator.TransformPoint(10.0, 50.0);
Console.WriteLine("[sample] (10, 50) -> {0} {1}", F(point.X, 2), F(point.Y, 2));
glsMapPoint back = toWgs84.TransformPoint(point.X, point.Y);
Console.WriteLine("[sample] and back: {0} {1}", F(back.X, 6), F(back.Y, 6));
glsMapPoint swapped = toMercator.TransformPoint(50.0, 10.0);
Console.WriteLine("[sample] (50, 10), latitude first -> {0} {1}", F(swapped.X, 2), F(swapped.Y, 2));
bool transformed = true;
try
{
toMercator.TransformPoint(10.0, 95.0);
}
catch (glsGdkException)
{
transformed = false;
}
Console.WriteLine("[sample] (10, 95) was transformed: {0}", YesNo(transformed));
}
return true;
}
기하
공간 관계를 판정하거나 이항 기하 연산을 적용하기 전에 서로 다른 비영 SRID를 사용하는지 확인합니다. 연산에서 반환된 기하 객체는 호출자가 해제합니다.
생성과 수명
형식과 측정
공간 관계와 연산
- Contains(glsGeometry)
- Disjoint(glsGeometry)
- EqualsTopo(glsGeometry)
- Intersects(glsGeometry)
- Touches(glsGeometry)
- Within(glsGeometry)
- Buffer(double, int)
- Difference(glsGeometry)
- Intersection(glsGeometry)
- UnaryUnion()
- Union(glsGeometry)
내보내기
좌표 변환
변환 객체가 생성된 뒤에도 CRS 쌍이 지원되지 않을 수 있습니다. IsValid와 OperationInfo로 지원 여부와 실패 사유를 확인합니다.
- CreateTransformTo(glsSpatialReference)
- CreateTransformTo(glsSpatialReference, glsCoordinateTransformOptions)
점 좌표 변환과 수명
- IsValid
- OperationInfo
- Source
- Target
- TransformPoint(double, double)
- TransformPoint3D(double, double, double, out double, out double, out double)
- Dispose()
- ~glsCoordinateTransform()
변환 옵션
WGS 84 근사 플래그
좌표 연산 유형
변환 실패 사유
- ApproximationNotAllowed
- InvalidOptions
- None
- UnsupportedCrs
- UnsupportedDatumPair
- UnsupportedDimension
- UnsupportedEpoch
좌표 연산 정보
- ApproximationUsed
- East
- FailureReason
- HasArea
- HasNominalDatumAccuracy
- HeightPreserved
- HorizontalOnly
- Inverse
- Kind
- NominalDatumAccuracyMeters
- North
- OperationEpsgCode
- South
- West
MGRS 인코딩과 디코딩
경위도는 도, 격자 좌표는 미터로 주고받습니다. 정밀도는 축별 숫자 자릿수로 지정합니다. 정확히 북위 84도에서 사용하는 격자는 인코딩 옵션에 따라 달라집니다.
경위도와 EPSG CRS 좌표
- ToMgrs(double, double, glsMgrsPrecision)
- ToMgrs(double, double, glsMgrsPrecision, glsMgrsEncodingOptions)
- FromMgrs(string, bool, ref double, ref double)
- CoordToMgrs(int, glsMapPoint, glsMgrsPrecision)
- CoordToMgrs(int, glsMapPoint, glsMgrsPrecision, glsMgrsEncodingOptions)
- MgrsToCoord(string, int, bool)
격자 좌표의 인코딩과 디코딩
- ToMgrsFromGrid(glsMgrsGridCoordinate, glsMgrsPrecision)
- FromMgrsToGrid(string, bool, out int)
- ToMgrsFromUtm(glsUtmCoordinate, glsMgrsPrecision)
- FromMgrsToUtm(string)
문법과 격자 조회
- IsValidMgrsSyntax(string)
- MgrsPrecisionOf(string)
- UtmZoneForLonLat(double, double)
- LatitudeBandLetter(double)