Tutorial Equipments - ORGTYTESPOO/kiradigiasm GitHub Wiki

Inserting

Equipments are divided into 3 tables.

  • Asset
    • A row in the Asset table can exist on it's own.
  • Equipment (parent)
  • Equipment (multiple child tables depending on the type and group)
    • A row in the Equipment tables cannot exist without a row in the Asset table because of a Foreign Key constraint
  1. You need to load your data into some separate table (a separate schema is recommended). This loading table is built according to your data structure (the data structure of the WFS -interface, Shp- file, JSON file/REST etc.). It's best to collect the data like it's defined in the master database to avoid a lot of work. So next time you order a data collection use the data model as your definition.
    1. Loading data with QGIS
  2. Inserting to Asset and Equipment tables
    1. Insert a row into the Asset -table. Be sure to insert a dataid from the original data to be able to join the right rows later on.
    2. Insert a row (or rows) into the correct child table e.g. TrashEquipment. This will insert a row (or rows) with the same attributes into the parent Equipment -table with the correct foreign key id (reference to the asset gid).
    3. TrashEquipment Insert Example with code

Link equipments to InfraParts with an analysis

  1. Example with code (under construction)

Updating

Deleting

Some ERRORS that might come up when using POINT geometry

ERROR: Geometry type (Point) does not match column type (MultiPoint)
Trying to insert geometry from table a to table b when table a has POINT and table b has MULTIPOINT

ERROR: Column has Z dimension but geometry does not
Using ST_Multi works only for 2D geometry:

To be sure you might want to dissemble the geometry attribute into x, y and z and rebuild it.