Documentation | ⌂ Topology Layers | « Previous | Next »
The topology workflows presented throughout this guide assume the existence of a basic GIS application capable of displaying, selecting, creating, and editing vector geometry.
Topology editing in TatukGIS builds upon the standard editing framework provided by the TGIS_Editor class. Before adding topology functionality, an application should already support common GIS editing operations such as shape selection, geometry creation, geometry editing, shape deletion, and undo/redo functionality.
This chapter presents the minimal editing framework used by the TopologyLayer sample application and serves as a foundation for the topology workflows described throughout this tutorial.
A typical GIS application operates in several viewer modes:
procedure TfrmTopology.btnSelectModeClick(Sender: TObject); begin if endEdit then GIS.Mode := TGIS_ViewerMode.Select ; end ;
The btnSelectModeClick method is used throughout the application to safely return the viewer to Select mode. Before changing the viewer mode, it calls endEdit to ensure that any active editing operation is completed correctly.
procedure TfrmTopology.btnEditModeClick(Sender: TObject); begin GIS.Mode := TGIS_ViewerMode.Edit ; end ; procedure TfrmTopology.btnDragModeClick(Sender: TObject); begin GIS.Mode := TGIS_ViewerMode.Drag ; end ; procedure TfrmTopology.btnZoomClick(Sender: TObject); begin GIS.Mode := TGIS_ViewerMode.Zoom ; end ;
Switching between modes provides a simple mechanism for controlling viewer behavior and editing workflows.
To create new geometry, the application enters Edit mode and remembers which layer will receive new objects.
procedure TfrmTopology.btnAddShapeClick(Sender: TObject); begin endEdit ; GIS.Mode := TGIS_ViewerMode.Edit ; editLayer := gisLegend.GIS_Layer ; end ;
Actual geometry creation occurs later during mouse interaction.
Existing shapes can be edited through the standard editor framework.
GIS.Editor.TryEditShape( shp, 0, ptg ) ;
Once editing starts, the editor framework handles vertex manipulation and geometry updates automatically.
Shapes can be removed directly through the editor.
procedure TfrmTopology.btnDeleteClick(Sender: TObject); begin GIS.Editor.DeleteShape ; btnSelectModeClick( self ) ; end ;
The editor framework provides built-in support for Undo and Redo operations.
procedure TfrmTopology.btnUndoClick(Sender: TObject); begin GIS.Editor.Undo ; end ; procedure TfrmTopology.btnRedoClick(Sender: TObject); begin GIS.Editor.Redo ; end ;
function TfrmTopology.endEdit: Boolean; begin Result := GIS.Editor.TryEndEdit ; if not Result then exit ; editLayer := nil ; end ;
This ensures that all editor validation and finishing procedures are executed correctly.
Mouse interaction forms the core of most GIS editing applications. When the user clicks on the map, the application converts screen coordinates into map coordinates, identifies the clicked object, and performs the appropriate action based on the current viewer mode.
The following event handler demonstrates the approach used by the TopologyLayer sample application.
procedure TfrmTopology.GISMouseUp( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer ); var shp : TGIS_Shape ; ptg : TGIS_Point ; endEditRequired : Boolean ; begin if GIS.IsEmpty then exit ; if Button = mbRight then begin btnSelectModeClick( Self ) ; exit ; end ; ptg := GIS.ScreenToMap( Point( X, Y ) ) ; shp := TGIS_Shape( GIS.Locate( ptg, 5 / GIS.Zoom ) ) ; if GIS.Mode = TGIS_ViewerMode.Select then begin if not Assigned( shp ) then exit ; if ssCtrl in Shift then begin shp.IsSelected := not shp.IsSelected ; gisAttributes.ShowSelected( shp.Layer ) ; end else begin shp.Layer.DeselectAll ; shp.IsSelected := not shp.IsSelected ; gisAttributes.ShowShape( shp ) ; end ; gisLegend.GIS_Layer := shp.Layer ; end else if GIS.Mode = TGIS_ViewerMode.Edit then begin if Assigned( GIS.Editor.CurrentShape ) then exit ; if Assigned( editLayer ) then begin if not GIS.Editor.TryCreateShape( gisLegend.GIS_Layer, ptg, TGIS_ShapeType.Unknown, endEditRequired ) or endEditRequired then begin btnSelectModeClick( Self ) ; end ; end else begin if not GIS.Editor.TryEditShape( shp, 0, ptg ) then exit ; end ; editLayer := nil ; GIS.InvalidateEditor( True ) ; end ; end ;
When the viewer operates in Select mode, a mouse click is used to identify and select existing shapes.
The Locate method is used to identify the object nearest to the click location. The selected shape then becomes the active object displayed in the Attributes window.
In Edit mode, clicking on the map may create a new geometry object.
GIS.Editor.TryCreateShape(...)
The shape type is determined automatically from the destination layer.
If the user clicks an existing shape while in Edit mode, the editor framework attempts to open that shape for editing.
GIS.Editor.TryEditShape(...)
Topology editing does not replace the standard GIS editing framework. Instead, it extends it.
The same viewer modes, mouse events, selection mechanisms, and editor operations are used throughout the topology workflows described in this guide.
When topology editing is enabled, the topology engine automatically maintains topology relationships, creates Nodes, updates Edges, generates Faces, and synchronizes Feature Layers.
The next chapter summarize Topology Layer features. « Previous | Next »