User Tools

Site Tools


api:dk11:delphi:gislayervector.tgis_shape.setposition_tgis_point_tgis_layervector_double

TGIS_Shape.SetPosition method

DK11 for Delphi | GisLayerVector.TGIS_Shape.SetPosition | Constructors | Fields | Methods | Properties

Move the whole shape.

Available also on: .NET | Java | ActiveX.

Syntax

// Delphi
public
  procedure SetPosition(
    const _ptg : TGIS_Point;
    const _layer : TGIS_LayerVector;
    const _prec : Double
  );
// C++ Builder
public:
  void SetPosition(
    TGIS_Point* const _ptg,
    TGIS_LayerVector* const _layer,
    const double _prec
  );

Parameters

Name Type Description
_ptg TGIS_Point point to which we are moving ;
_layer TGIS_LayerVector snapping layer; if nil, a shape will not be snapped; just perfect for GPS snap-to-road function
_prec Double snapping precision; only points closer to _ptg than _prec can be found ;

Remarks

Use this method to move the whole shape. Reference point is the same as Centroid.

Example

Delphi

procedure MyClass.SynchroMove( _shp : TGIS_Shape ; _x,_y : Integer ) ;
var
  ll  : TGIS_LayerVector ;
  shp : TGIS_Shape ;
  ptgA : TGIS_Point ;
  ptgB : TGIS_Point ;
  ex  : TGIS_Extent ;
begin
  // move main shape
  ptgA := _shp.GetPoint( 0, 0 ) ;
  ptgA.X := ptgA.X + _x ;
  ptgA.Y := ptgA.Y + _y ;
  _shp.SetPosition( ptgA , nil, 0 ) ;
 
  // move "sidekick"
  ll := TGIS_LayerVector( GIS.Get('sidekicks') ) ;
  shp := ll.GetShape( _shp.Uid ) ;
  ptgB := shp.GetPoint( 0, 0 ) ;
  ptgB.X := ptgB.X + _x ;
  ptgB.Y := ptgB.Y + _y ;
  shp.SetPosition( ptgB , nil, 0 ) ;
 
  // additional invalidation - we have now a strange big
  // combo shape
  ex.XMin := Min( ptgA.X, ptgB.X ) ;
  ex.YMin := Min( ptgA.Y, ptgB.Y ) ;
  ex.XMax := Max( ptgA.X, ptgB.X ) ;
  ex.YMax := Max( ptgA.Y, ptgB.Y ) ;
  GIS.InvalidateExtent( ex, True );
end ;

References

2020/05/07 01:09

Page Tools