測地線に基づく距離の計測

Public Sub Test()
    Dim pSpatialReferenceFactory As ISpatialReferenceFactory2
    Set pSpatialReferenceFactory = New SpatialReferenceEnvironment
    
    '地理座標系(WGS84)の定義
    Dim pSpatialReference As ISpatialReference
    Set pSpatialReference = pSpatialReferenceFactory.CreateGeographicCoordinateSystem(4326) 'WGS84
    
    Dim pPointFrom As IPoint
    Set pPointFrom = New Point
    pPointFrom.PutCoords 0, 45
    
    Dim pPointTo As IPoint
    Set pPointTo = New Point
    pPointTo.PutCoords 1, 45
    
    
'    'Polyline の定義
'    Dim pPolyline As IPolyline
'    Set pPolyline = New Polyline
'    Set pPolyline.SpatialReference = pSpatialReference
'
'    Dim pPointCollection As IPointCollection
'    Set pPointCollection = pPolyline
'    pPointCollection.AddPoint pPointFrom
'    pPointCollection.AddPoint pPointTo
    
'    Dim pPolylineArray As IPolylineArray
'    Set pPolylineArray = New PolylineArray
'    pPolylineArray.Add pPointCollection

    '距離単位の定義
    Dim pLinearUnit As ILinearUnit
    Set pLinearUnit = New LinearUnit
    Dim pLinearUnitEdit As ILinearUnitEdit
    Set pLinearUnitEdit = pLinearUnit
    pLinearUnitEdit.Define "Meter", "", "", "", 1
    
    Dim pGeometryServer As IGeometryServer3
    Set pGeometryServer = New GeometryServer
    
'    Dim pDoubleArray As IDoubleArray
'    Set pDoubleArray = pGeometryServer.GetLengthsGeodesic(pSpatialReference, pPolylineArray, pLinearUnit)
'
'    '距離の出力
'    Debug.Print pDoubleArray.Element(0)
    
    
    Debug.Print pGeometryServer.GetDistanceGeodesic(pSpatialReference, pPointFrom, pPointTo, pLinearUnit)

End Sub