Skip to content

Conversation

@saberraz
Copy link
Contributor

@saberraz saberraz commented Oct 6, 2021

Documentation for 1 to many relations. Including adding multiple photos to a feature.

### Project preparation in QGIS

The example projects can be found:
- [Assigning multiple inspection to a single feature](https://public.cloudmergin.com/projects/documentation/forms_one-to-many-relations)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<MerginMapsProject id="documentation/forms_one-to-many-relations" />


The example projects can be found:
- [Assigning multiple inspection to a single feature](https://public.cloudmergin.com/projects/documentation/forms_one-to-many-relations)
- [Adding multiple photos to a single feature](https://public.cloudmergin.com/projects/documentation/forms_multiple_photos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<MerginMapsProject id="documentation/forms_multiple_photos" />

@PeterPetrik PeterPetrik merged commit 1064253 into main Oct 6, 2021
@PeterPetrik PeterPetrik deleted the one-to-many branch October 6, 2021 08:37

## 1-N relations

It is often the case that you have a set of spatial features and you want to record some parameters every now and then. For example, there is a GIS layer representing the manholes and the surveyors carry out regular inspections of the manholes. Instead of duplicating the manhole layer and recording each inspection, you can create a non-spatial table and store each inspection as a new line. An example project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfinished sentence "An example project"

### Project preparation in QGIS

The example projects can be found:
- [Assigning multiple inspection to a single feature](<MerginMapsProject id="documentation/forms_one-to-many-relations" />)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspection -> inspections


### Project preparation in QGIS

The example projects can be found:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the wording a bit strange? How about "See the example projects:"

- [Assigning multiple inspection to a single feature](<MerginMapsProject id="documentation/forms_one-to-many-relations" />)
- [Adding multiple photos to a single feature](<MerginMapsProject id="documentation/forms_multiple_photos" />)

To configure 1-N relations in QGIS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before showing how to set it up for a particular project, it would be worth showing the structure of the tables (what are the columns and maybe few sample rows), so it is is clear how the data are linked.


When you open the form for an existing record in the **manhole_locations** point layer, you should be able to see the existing inspection records and optionally add, delete or edit the records:

![1-N relations in QGIS - form view](./input_forms_many-relations1.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad picture linked

The same project when you open add inspection to a manhole in Input will look like the image below:

![Many photos to a single feature](./input_forms_one-to-many.png)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add another header here - .e.g "Link multiple photos to a feature" and add the example project right after that.

The key part when linking the above to table is to avoid using **FID** field in the GeoPackage. Mergin uses the FID to consolidate changes and therefore can change the FIDs. This will result in having photos linked to the incorrect feature on the map.

For that, we can create a new field and use the **uuid()** as the default value. To learn more about how this can be configured, you can see [this example](<MerginMapsProject id="documentation/forms_multiple_photos" />).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be explained also how you get the image viewer in Input - that it is automatically detected that the linked layer has a field with attachment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants