-
Notifications
You must be signed in to change notification settings - Fork 20
one to many relations #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ To use the numeric widget in your form from Input: | |
|
|
||
|  | ||
|
|
||
| ## Slider | ||
| ## Slider | ||
|
|
||
| For setting up a slider, ensure your field type is an integer. | ||
|
|
||
|
|
@@ -145,9 +145,9 @@ To have a more advanced form with drill-down menu option, see [cascade form setu | |
| ## QR code reader | ||
| To be able to use your camera in forms to scan QR codes and populate the text in the field | ||
|
|
||
| ### QGIS | ||
| ### QGIS | ||
|
|
||
| To be able to scan QR codes in your forms, your field or the alias for the field should contain **qrcode** (the text is not case sensitive and it can be be in combination of lower or upper case letters). For an example, see the <MerginMapsProject id="documentation/test_qrcode" /> | ||
| To be able to scan QR codes in your forms, your field or the alias for the field should contain **qrcode** (the text is not case sensitive and it can be be in combination of lower or upper case letters). For an example, see the <MerginMapsProject id="documentation/test_qrcode" /> | ||
|
|
||
| ### Input | ||
|
|
||
|
|
@@ -164,7 +164,7 @@ To use the QR code scanner in the form from Input: | |
|  | ||
|
|
||
|
|
||
| ## Datetime | ||
| ## Datetime | ||
|
|
||
| If you want to record time and date when you capture the feature, you need to make sure you have a field with **Date** or **Date and Time** type present in your survey layer. Note that all GIS data formats support these types of field. It is assumed, you use Geopackage layer, hence this field type is supported. | ||
|
|
||
|
|
@@ -309,4 +309,53 @@ To use the drop-down widget in the form from Input: | |
|
|
||
|  | ||
|  | ||
|  | ||
|  | ||
|
|
||
| ## 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 | ||
|
|
||
| Another example is when you try to capture multiple photos for a single feature. | ||
|
|
||
| In the sections below, you can see how this type of relations can be set up in QGIS and utilised in the Input app. | ||
|
|
||
| ### Project preparation in QGIS | ||
|
|
||
| The example projects can be found: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" />) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inspection -> inspections |
||
| - [Adding multiple photos to a single feature](<MerginMapsProject id="documentation/forms_multiple_photos" />) | ||
|
|
||
| To configure 1-N relations in QGIS: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| - From the main menu, select **Projects** > **Properties ...** | ||
| - In the new window, select the **Relations** tab | ||
| - Select **Add Relation** to create a new one | ||
| - A new window will appear, where we can define the parent and child layers and the fields to link the two layers: | ||
| - For **Name** type **Inspection** | ||
| - For the **Referenced(parent)** layer, select **manhole_locations** | ||
| - For **Field 1** of the **Referenced(parent)** layer, select **Manhole** | ||
| - For the **Referencing(child)** layer, select **inspections** | ||
| - For **Field 1** of the **Referencing(child)** layer, select **Manhole ID** | ||
|
|
||
|  | ||
|
|
||
| This should now allow you to add multiple inspections for each manhole location (**manhole_locations** point layer). The inspections records will be stored in the **inspections** table. | ||
|
|
||
| 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: | ||
|
|
||
|  | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
||
|  | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Another use-case for having multiple photos linked to a single feature is using 1-N relation. | ||
|
|
||
| To set up a project in QGIS, similar to the previous example, we need a unique field to link the following two tables: | ||
| - Survey layer (containing spatial information) | ||
| - A non-spatial table containing path to the photos | ||
|
|
||
| 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" />). | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|  | ||
There was a problem hiding this comment.
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"