Linkit

Link It offers an easy way to link features on the map from the available relations in the project.

View the Project on GitHub 3nids/linkit

What ?

Link It offers an easy way to link features on the map from the available relations in the project.

How ?

A demo is visible on youtube.

  1. Create relation in the project properties
  2. In the referencing layer properties, set the corresponding field as a "relation reference" widget
  3. Show the dock using the dedicated icon
  4. Select the corresponding relation
  5. Using the provided map tool, choose the referencing feature you want to show/edit.
  6. If editing on the referencing layer is turned on, you can choose a new referenced map tool using the other provided map tool.

Tip

If you want to have a postgis layer drawing a nice arrow from one feature (child) to another (parent), here you go. Just change the values between underscores.

CREATE OR REPLACE VIEW _schema_._view_name_ AS
    SELECT child, parent,
         ST_CurveToLine(ST_GeomFromEWKT('SRID=_YOURSRID_;CIRCULARSTRING('
            ||ST_X(start_point)||' '||ST_Y(start_point)
            ||','||
            ST_X(middle_point)+distance*cos(azimuth)||' '||ST_Y(middle_point)+distance*sin(azimuth)
            ||','||
            ST_X(end_point)||' '||ST_Y(end_point) 
            ||')'
        ),15)::geometry(LineString,21781) AS wkb_geometry
    FROM (
        SELECT child,parent,
            start_point , end_point ,
            pi()/2+ST_Azimuth(start_point,end_point) AS azimuth,
            .5*ST_Distance(start_point,end_point) AS distance,
            ST_Line_Interpolate_Point(ST_MakeLine( start_point , end_point ),.5)::geometry(Point,21781) AS middle_point
        FROM (
            SELECT a.id AS child ,b.id AS parent, 
                    ST_Line_Interpolate_Point(a.wkb_geometry,.5)::geometry(Point,21781) AS start_point,
                    /* select end_point at 4 meters from the closest side of the pipe */
                    ST_ClosestPoint(ST_MakeLine(  
                        ST_Line_Interpolate_Point(b.wkb_geometry,   LEAST(1,  4/b._length2d/2))::geometry(Point,21781) ,
                        ST_Line_Interpolate_Point(b.wkb_geometry,GREATEST(0,1-4/b._length2d/2))::geometry(Point,21781) 
                    ),a.wkb_geometry) AS end_point
            FROM _yourschema_._yourtable_ a 
            INNER JOIN _yourschema_._yourtable_ b ON a._fieldOfParentID_ = b.id
            WHERE a.id_parent IS NOT NULL
        ) AS foo
    ) AS foo2;