The IDatumShiftProgress interface must be implemented by the user in order to receive regular updates on the progress of the DataSource.GetValidDatumShifts method. The object that implements this interface must be passed to the DatumShiftPreferencesEx.AdviseOnProgress method in order to hook up the progress updates.
|
Method |
Description |
|
ProgressUpdate |
This is the method that will be called to give progress updates |
' Class Module DatumShiftProgress:
Implements IDatumShiftProgress
Private Sub IDatumShiftProgress_ProgressUpdate(ByVal index As Long, ByVal totalCount As Long, ByVal pData As Long)
MsgBox ("Progress update: " + CStr(index) + " of " + CStr(totalCount) + ", pdata = " + CStr(pData))
End Sub
Sub DatumShiftPreferencesEx_AdviseOnProgress(data As DataSource)
Dim source As ICoordSys
Dim target As ICoordSys
Set source = data.GetGeodeticCoordSys("BMG", "WGS84")
Set target = data.GetProjectedCoordSys("BMG", "GA-27W")
Dim shiftPrefs As New DatumShiftPreferencesEx
shiftPrefs.area = data.GetEnvelope("BMG", "STANDARD_ENVELOPE")
shiftPrefs.BitFlags = dsbBursaWolfe Or dsbMolodensky
Dim progger As New DatumShiftProgress
shiftPrefs.AdviseOnProgress progger, 0
Dim shiftSets As DatumShiftInfoSetCollection
If Not data.GetValidDatumShifts(source, target, shiftPrefs, shiftSets) Then
MsgBox ("GetValidDatumShifts failed")
End If
End Sub
// Unit2.pas:
unit Unit2;
interface
uses
GeoCalcCOM_TLB, Dialogs, SysUtils;
type
TDatumShiftProgress = class(TInterfacedObject, IDatumShiftProgress)
public
function ProgressUpdate(index: Integer; totalCount: Integer; pData: integer): HResult; stdcall;
end;
implementation
function TDatumShiftProgress.ProgressUpdate(index: Integer; totalCount: Integer; pData: integer): HResult; stdcall;
var
msg : string;
begin
msg := 'Progress Update: ' + IntToStr(index) + ' of ' + IntToStr(totalCount) + ', pData = ' + IntToStr(pData);
ShowMessage(msg);
end;
end.
// In another unit:
procedure DatumShiftPreferencesEx_AdviseOnProgress(data : DataSource);
var
ct : CoordTransform;
shiftPrefs : DatumShiftPreferencesEx;
shiftSets : DatumShiftInfoSetCollection;
progger : TDatumShiftProgress;
begin
ct := CoCoordTransform.Create;
ct.SourceCoordSys := data.GetProjectedCoordSys('BMG', 'TX-27NC');
ct.TargetCoordSys := data.GetGeodeticCoordSys('BMG', 'WGS84_coordinate_system');
shiftPrefs := CoDatumShiftPreferencesEx.Create;
shiftPrefs.OnlyGoThruIntermediate := false;
shiftPrefs.BitFlags := dsbNadcon or dsbMolodensky or dsBursaWolfe;
progger := TDatumShiftProgress.Create;
shiftPrefs.AdviseOnProgress(progger, 0);
shiftSets := CoDatumShiftInfoSetCollection.Create;
if not data.GetValidDatumShifts(ct.SourceCoordSys, ct.TargetCoordSys, shiftPrefs, shiftSets) then
begin
ShowMessage('GetValidDatumShifts failed');
end;
end;