DigSyLand-Logo
DigSyLand ist deutschsprachiger TatukGIS-Vertriebspartner. You find the English web site of TatukGIS at www.tatukgis.com.

TatukGIS Developer Kernel (DK) Toolkit: Verschiedene Code-Beispiele

An den folgenden Code-Beispielen für die verschiendenen unterstützten Systeme und Entwicklungsumgebungen können Sie erkennen, wie die Einbindung der GIS-Funktionalität auf einfache und intuitive Weise erfolgt.


Delphi DK VCL & DK VCL.NET code (DK.VCL)

procedure TForm1.GISMouseMove(Sender: TObject; Shift: TShiftState; Y: Integer);
var
  ptg : TGIS_Point ;
  shp : TGIS_Shape ;
begin
  ptg := GIS.ScreenToMap( Point(x, y ) );
  shp := TGIS_Shape( GIS.Locate( ptg, 5/GIS.Zoom ) ) ; // 5 pixels precision
  if shp = nil then
    StatusBar.SimpleText := ''
  else
    StatusBar.SimpleText := shp.GetField('name');
end;


C++ Builder DK VCL & DK VCL.NET code (DK.VCL)

void __fastcall TForm1::GISMouseDown(TObject *Sender, TMouseButton Button,
                                     TShiftState Shift, int X, int Y)
{
  TGIS_Point   ptg  ;
  TGIS_Shape  *shp  ;

  if ( GIS->IsEmpty ) return;
  ptg = GIS->ScreenToMap( Point(X, Y) );
  shp = (TGIS_Shape *)( GIS->Locate( ptg, 5/GIS->Zoom, TRUE ) ) ; // 5 pixels precision
  if (shp == NULL)
     StatusBar->SimpleText = "" ;
  else
     StatusBar->SimpleText = shp->GetField("name") ;
}


VisualBasic 6 DK ActiveX code (XDK)

Private Sub GIS_OnMouseMove(translated As Boolean, ByVal shift As TatukGIS_DK.X_ShiftState,
                            ByVal X As Long, ByVal Y As Long)

  Dim ptg As XGIS_Point
  Dim shp As XGIS_Shape

  Set ptg = GIS.ScreenToMap(GisUtils.Point(X, Y))
  Set shp = GIS.Locate(ptg, 5 / GIS.Zoom) ' 5 pixels precision
  If shp Is Nothing Then
    StatusBar.SimpleText = ""
  Else
    StatusBar.SimpleText = shp.GetField("name")
  End If
End Sub


Visual C++ MFC DK ActiveX code (XDK)

void CLocateDlg::OnOnMouseDownXgis(BOOL FAR* translated, long button,
                                   long shift, long X, long Y)
{
  IXGIS_Point ptg ;
  IXGIS_Shape shp ;
  IXGIS_LayerVector ll ;

  if ( m_gis.get_IsEmpty() ) return ;
  if ( m_gis.get_Mode() != m_gis.XgisSelect ) return ;
  ptg = m_gis.ScreenToMap( m_utils.Point( X, Y ) ) ;

  // just different method then on OnMouseMove - locate based on layer
  ll = m_gis.Get( "states" ) ;
  shp = ll.Locate( ptg, 5. / m_gis.get_Zoom() ) ;

  if ( shp.m_lpDispatch != NULL ) {
    var = shp.GetField( "NAME" ) ;
    str = var.bstrVal ;
    SetDlgItemText( IDC_LABEL, str );
  }
  else {
    SetDlgItemText( IDC_LABEL, _T("") );
  }
}


VisualBasic.NET ActiveX code (XDK)

Private Sub GIS_OnMouseDownEvent(ByVal eventSender As System.Object,
                                 ByVal eventArgs As AxTatukGIS_DK.IXGIS_ViewerWndEvents_OnMouseDownEvent)
                                 Handles GIS.OnMouseDown

  Dim ptg As TatukGIS_DK.IXGIS_Point
  Dim shp As TatukGIS_DK.IXGIS_Shape

  ptg = GIS.ScreenToMap(GisUtils.Point(eventArgs.x, eventArgs.y))
  shp = GIS.Locate(ptg, 5 / GIS.Zoom) ' 5 pixels precision
  If shp Is Nothing Then
    StatusBar1.Text = ""
  Else
    StatusBar1.Text = shp.GetField("name")
  End If

End Sub