Skip to content

Instantly share code, notes, and snippets.

@signedav
Last active June 24, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save signedav/1ed868dd89cf6f1fe3f89f3d2676f061 to your computer and use it in GitHub Desktop.
Save signedav/1ed868dd89cf6f1fe3f89f3d2676f061 to your computer and use it in GitHub Desktop.

Use case

Assets should have multiple region of interests (and back) what can be multiple geometries of every type

Inheritance

ILI

INTERLIS 2.3;

MODEL RegionOfInterest_Inheritance (en) 
AT "https://signedav.github.io/usabilitydave/models"
VERSION "2020-06-22" =
  
    IMPORTS GeometryCHLV95_V1, Units;
    IMPORTS UNQUALIFIED INTERLIS;
  
    DOMAIN
        Line = POLYLINE WITH (STRAIGHTS) VERTEX GeometryCHLV95_V1.Coord2;
        Surface = SURFACE WITH (STRAIGHTS) VERTEX GeometryCHLV95_V1.Coord2 WITHOUT OVERLAPS > 0.005;
        
        !! BAG OF with INTERLIS 2.3 only possible with STRUCTURE
        STRUCTURE PointStructure = 
            Point: GeometryCHLV95_V1.Coord2;
        END PointStructure;
        
        !!@ili2db.mapping=MultiPoint
        STRUCTURE MultiPoint =
            Points: BAG {1..*} OF PointStructure;
        END MultiPoint;
        
        STRUCTURE LineStructure = 
            Line: Line;
        END LineStructure;
        
        !!@ili2db.mapping=MultiLine
        STRUCTURE MultiLine =
            Lines: BAG {1..*} OF LineStructure;
        END MultiLine;
        
        STRUCTURE SurfaceStructure = 
            Surface: Surface;
        END SurfaceStructure;
        
        !!@ili2db.mapping=MultiSurface
        STRUCTURE MultiSurface =
            Surfaces: BAG {1..*} OF SurfaceStructure;
        END MultiSurface;
        
    TOPIC Assets =

        CLASS RegionOfInterest =
        Name: TEXT;
        END RegionOfInterest;

        CLASS StudySection EXTENDS RegionOfInterest =
            Geometry : MultiLine;
        END StudySection;

        CLASS StudyArea EXTENDS RegionOfInterest =
            Geometry : MultiSurface;
        END StudyArea;

        CLASS StudyLocation EXTENDS RegionOfInterest =
            Geometry : MultiPoint;
        END StudyLocation;

        CLASS Asset =
            Name: TEXT;
        END Asset;
        
        ASSOCIATION Asset_RegionOfInterest =
            Asset -- {1..*} Asset;
            RegionOfInterest -- {1..*} RegionOfInterest;
        END Asset_RegionOfInterest;

    END Assets; !! of TOPIC

END RegionOfInterest_Inheritance. !! of MODEL

UML

uml_inheritance

PostgreSQL

pg_inheritance

QGIS

qgis_inheritance

Conclusion:

Okay. But migth be an overkill

Relations

ILI

INTERLIS 2.3;

MODEL RegionOfInterest_Relations (en) 
AT "https://signedav.github.io/usabilitydave/models"
VERSION "2020-06-22" =
  
    IMPORTS GeometryCHLV95_V1, Units;
    IMPORTS UNQUALIFIED INTERLIS;
  
    DOMAIN
        Line = POLYLINE WITH (STRAIGHTS) VERTEX GeometryCHLV95_V1.Coord2;
        Surface = SURFACE WITH (STRAIGHTS) VERTEX GeometryCHLV95_V1.Coord2 WITHOUT OVERLAPS > 0.005;
        
        !! BAG OF with INTERLIS 2.3 only possible with STRUCTURE
        STRUCTURE PointStructure = 
            Point: GeometryCHLV95_V1.Coord2;
        END PointStructure;
        
        !!@ili2db.mapping=MultiPoint
        STRUCTURE MultiPoint =
            Points: BAG {1..*} OF PointStructure;
        END MultiPoint;
        
        STRUCTURE LineStructure = 
            Line: Line;
        END LineStructure;
        
        !!@ili2db.mapping=MultiLine
        STRUCTURE MultiLine =
            Lines: BAG {1..*} OF LineStructure;
        END MultiLine;
        
        STRUCTURE SurfaceStructure = 
            Surface: Surface;
        END SurfaceStructure;
        
        !!@ili2db.mapping=MultiSurface
        STRUCTURE MultiSurface =
            Surfaces: BAG {1..*} OF SurfaceStructure;
        END MultiSurface;
        
    TOPIC Assets =

        CLASS StudySection =
            Geometry : MultiLine;
        END StudySection;

        CLASS StudyArea =
            Geometry : MultiSurface;
        END StudyArea;

        CLASS StudyLocation =
            Geometry : MultiPoint;
        END StudyLocation;

        CLASS Asset =
            Name: TEXT;
        END Asset;
        
        ASSOCIATION Asset_RegionOfInterest =
            Asset -- {1..*} Asset;
            StudySection -- {1..*} StudySection;
            StudyArea -- {1..*} StudyArea;
            StudyLocation -- {1..*} StudyLocation;
        END Asset_RegionOfInterest;

    END Assets; !! of TOPIC

END RegionOfInterest_Relations. !! of MODEL

UML

uml_relations

PostgreSQL

pg_relations

QGIS

qgis_relations

Conclusion

Is what postgresql does with inheritances, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment