Skip to content

Commit

Permalink
Merged with main with conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
VulpesFerrilata committed Apr 11, 2024
2 parents bd04f41 + 559367a commit 58f5019
Show file tree
Hide file tree
Showing 10 changed files with 467 additions and 133 deletions.
Binary file added docs/assets/images/customise-layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 3 additions & 105 deletions docs/db/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ Common additional parameters you may want to use include:

#### Other options

- `projection` - If the projection is anything other than EPSG:3857, set it here. For WMS based layers, this is enough. For XYZ layers, see the section on [XYZ reprojection](#xyz-reprojection)
- `cswendpoint` - An endpoint to retrieve a CSW Metadata document, describing the layer. The metadata document should use Dublin Core and will be available via the 'i' button next to the layer name in the layer control.
- `projection` - If the layer is only available in a projection that is not the same as the map you are putting it in to, set the projection here, otherwise you can not include it, and the layer will be requested in the projection of the map. For XYZ layers, see the section on [XYZ reprojection](#xyz-reprojection)
- `cswendpoint` - An endpoint to retrieve a CSW Metadata document, describing the layer. The metadata document should use Dublin Core and will be available via the 'i' button next to the layer name in the layer control.

### Layer

Expand All @@ -110,49 +110,7 @@ Once this has been created, the layer table has the following fields to fill in:

#### Info Templates

Info templates control how the user see's data when they click an item on the map. There are two info templates used by GIFramework Maps.

- `InfoTemplate` - The template for what appears when you select a single map feature

<figure markdown>
![An InfoTemplate for a single map feature](../assets/images/feature-details-address-information.png){width="350"}
<figcaption>An `InfoTemplate` for a single map feature. Mapping &copy; Crown Copyright OS.</figcaption>
</figure>

- `InfoListTitleTemplate` - The template for what appears when you select multiple map features and are presented with a list of features

<figure markdown>
![An InfoListTitleTemplate for multiple features](../assets/images/feature-details-multiple-addresses.png){width="350"}
<figcaption>An `InfoListTitleTemplate` for multiple features. Mapping &copy; Crown Copyright OS.</figcaption>
</figure>

`InfoTemplate`s use a system called [nunjucks](https://mozilla.github.io/nunjucks/templating.html) for templating. You can read their documentation or the [section below](#advanced-templating) for advanced uses. For basic uses, you simply write standard HTML, and use the placeholder `{{COLUMN_NAME}}` to inject attributes into the template.

!!! example

Template (assuming there are attributes called `ADDRESS` and `UPRN`):

`<h1>{{ADDRESS}}</h1><p><strong>UPRN:</strong> {{UPRN}}</p>`

Output:

`<h1>1 Somewhere Drive, Someplace, SM1 1AA</h1><p><strong>UPRN: </strong> 10010101001</p>`

`InfoListTitleTemplate`s are simpler, and are designed for a single line of text with placeholders. It still uses nunjucks and the placeholder `{{COLUMN_NAME}}`, but should be kept simple as there may be many results listed.

!!! warning
Avoid using HTML in an `InfoListTitleTemplate`. The template is injected into an `<a>` tag within a `<li>` tag, so adding further HTML may cause unexpected results.

!!! example
Template (assuming there is an attribute called `ADDRESS`):

`Address: {{ADDRESS}}`

Output:

- `Address: 1 Somewhere Drive, Someplace, SM1 1AA`
- `Address: 2 Somewhere Drive, Someplace, SM1 1AA`
- `Address: 3 Somewhere Drive, Someplace, SM1 1AA`
See ['Creating info templates'](../gui/layers.md#info-templates)

### CategoryLayer

Expand All @@ -179,66 +137,6 @@ The ImageWMS source is used for WMS layers that are provided 'untiled', so a sin

## Advanced configuration

### Advanced templating

There are a number of advanced features built into the templating engine to allow for some smart customisation.

#### Date formatting

You can apply custom date formatting to datetime attributes to make them more user friendly.

!!! warning
This is a custom extension to nunjucks and not part of the standard nunjucks templating engine

To apply basic datetime formatting, simply add ` | date` after your attribute name. For example `{{DATE_ATTRIBUTE | date}}` will attempt to render the attribute `DATE_ATTRIBUTE` using the [`toLocaleDateString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString#using_tolocaledatestring) JavaScript function. In `en-GB` locales this would convert the ISO date `2023-02-07T17:10:00.000Z` to `07/02/2023`.

You can also apply custom formatting by passing a `format` string to the `date` function. For example `{{DATE_ATTRIBUTE | date('yyyy')}}` will convert the ISO date `2023-02-07T17:10:00.000Z` to `2023`. This custom formatting is applied using a library called [luxon](https://moment.github.io/luxon), who provide [a table of tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) you can use.

!!! example "Examples"
Assuming an attribute called `DATE_ATTRIBUTE` with the value `2023-02-07T17:10:00.000Z` (Feb 7th, 2023 at 17:10)

- `{{DATE_ATTRIBUTE | date}}` :material-arrow-right: `07/02/2023`
- `{{DATE_ATTRIBUTE | date('yyyy')}}` :material-arrow-right: `2023`
- `{{DATE_ATTRIBUTE | date('ccc dd LLLL yyyy T')}}` :material-arrow-right: `Tuesday 07 February 2023 17:10`

#### Conditionals

You can use basic if statements to conditionally show/hide content in a template or render it in a different way.

!!! info
You can read the full documentation on if statements in nunjucks [in their documentation](https://mozilla.github.io/nunjucks/templating.html#if)

If statements are very simple and flexible. A basic example is
```
{% if attribute === 'something' %}
It is something
{% endif %}
```
This will render the string 'It is something' if the `attribute` is equal to 'something'. Everthing between the tags can include placeholders and HTML as normal.

For example, the following will wrap the `STATUS` attribute in a `<span>` with the class `text-danger` (rendering it as red text) if the `STATUS` is 'Closed', otherwise it will not wrap it in anything.
```
{% if STATUS === 'Closed' %}
<span class="text-danger">{{STATUS}}</span>
{% else %}
{{STATUS}}
{% endif %}
```

#### Everything else

There are many more helpers available. The best way to find out more is to read the [nunjucks templating documentation](https://mozilla.github.io/nunjucks/templating.html).

Some useful ones you might consider:

- [Math](https://mozilla.github.io/nunjucks/templating.html#math) - Perform simple math operations
- [capitalize](https://mozilla.github.io/nunjucks/templating.html#capitalize) - Make the first letter uppercase, the rest lower case
- [int](https://mozilla.github.io/nunjucks/templating.html#int) - Convert the value into an integer. If the conversion fails 0 is returned.
- [lower](https://mozilla.github.io/nunjucks/templating.html#lower) - Convert string to all lower case
- [round](https://mozilla.github.io/nunjucks/templating.html#round) - Round a number
- [truncate](https://mozilla.github.io/nunjucks/templating.html#truncate) - Return a truncated copy of the string
- [upper](https://mozilla.github.io/nunjucks/templating.html#upper) - Convert the string to upper case

### XYZ reprojection

XYZ layers can be provided in different projections. To make use of on the fly reprojection, you need to provide an appropriate `tilegrid` option, describing the resolutions and origins of the XYZ layer. The service provider should be able to provide this.
Expand Down
28 changes: 28 additions & 0 deletions docs/db/projections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Projections

GIFramework Maps can use multiple projections for both the actual map rendering and the display coordinates. The Projections table defines what projections are available to the application.

## Relevant tables

| Table Name | Description |
| --------------------------------- | ------------------------------------ |
| Projections | The projection definitions |
| VersionProjections | Table that defines which versions have which projections |

### Projections

This table contains the projection definition.

- `EPSGCode` - The EPSG code of the projection.
- `Name` - The name of the projection
- `Description` - A description of what this projection is and where it covers
- `Proj4Definition` - A Proj4 or WKT definition of the projection
- `MinBoundX` - The bottom left X coordinate of this projections maximum bounds, in Lat/Lon
- `MinBoundY` - The bottom left Y coordinate of this projections maximum bounds, in Lat/Lon
- `MaxBoundX` - The top right X coordinate of this projections maximum bounds, in Lat/Lon
- `MaxBoundY` - The top right Y coordinate of this projections maximum bounds, in Lat/Lon
- `DefaultRenderedDecimalPlaces` - The number of decimal places shown by default when showing coordinates in this projection

### VersionProjections

See [VersionProjections](../db/versions.md#versionprojection)
51 changes: 44 additions & 7 deletions docs/db/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ The `Versions` table contains all the basic information about a version of GIFra
| Table Name | Description |
| ----------------------------------- | ------------------------------------ |
| Versions | Contains the basic details about a version, including name, slug, start bound, theme and more |
| VersionBasemaps | Contains an optional `BoundId` column used to define what bounds the layer covers |
| VersionCategory | Contains a `BoundId` column used to define what bounds the basemap covers |
| VersionPrintConfiguration | Contains a `BoundId` column used to define what bounds the basemap covers |
| VersionSearchDefinition | Contains a `BoundId` column used to define what bounds the basemap covers |
| VersionUser | Contains a `BoundId` column used to define what bounds the basemap covers |
| VersionAnalytic | Identifies which analytics providers are enabled for a version |
| VersionBasemaps | Contains details of the basemaps that a version has available and their default options |
| VersionCategory | Contains a list of layer categories that a version has |
| VersionContact | Lists the users that should be contacted regarding a version |
| VersionLayer | Contains per-layer customisations applied to a version |
| VersionPrintConfiguration | Identifies which print configuration a version uses |
| VersionProjections | Lists the projections available to a version and what the defaults are |
| VersionSearchDefinition | Lists the search definitions that are enabled in a version and their default settings |
| VersionUser | Contains the users that have access to a version |

### Versions

- `Name` - The name of the version. This also appears to the user in the top left
- `Description` - A friendly description of the version. This also appears in the HTML meta description which is shown to search engines
- `Slug` - The `Slug` is the bit on the end of the URL. You can have up to 3 parts to a slug, seperated by slashes. See section below on [slugs](#slugs) for more info
- `Slug` - The `Slug` is the bit on the end of the URL. You can have up to 3 parts to a slug, seperated by slashes. See [slugs](../gui/versions.md#slugs) for more info
- `Enabled` - A boolean indicating whether this version is enabled or not. Disabled versions will show a specific 'Disabled' message, rather than the standard 'Not found'
- `RequireLogin` - A boolean indicating whether this version requires the user to login or not. Permissions need to be given to users using the [`VersionUser`](#versionuser) table.
- `RedirectionURL` - An optional URL to redirect the user to instead of loading the version. Can be useful if a version changes slug, or you want to point people elsewhere. Will issue a `HTTP 302 Found` response with the URL provided
Expand All @@ -35,7 +39,8 @@ The `Versions` table contains all the basic information about a version of GIFra
- `VersionImageURL` - An optional URL to an image that will show on a version's card on the version home page. If a URL is not supplied, a default image of the world will be used.
- `Hidden` - A boolean indicating whether to hide a version from the versions home page (this will not delete a version or stop it being accessed directly by its URL).

#### Slugs
### VersionAnalytic
The `VersionAnalytic` table defines which analytics providers are available in which versions.

Slugs are the bit on the end of your application URL which direct you to different versions of GIFramework Maps. You can have a maximum of three slugs seperated by forward slashes.

Expand Down Expand Up @@ -92,6 +97,29 @@ The `VersionCategory` table defines which categories are available in which vers
!!! info
If your category is a child, both the parent AND child categories need to be added to this table.

### VersionContact
The `VersionContact` table defines which users should be contacted about a version.

- `VersionContactId` - Unique ID for this entry
- `VersionId` - The `Id` from the `Versions` table
- `UserId` - The users unique identifier provided by the identity provider
- `DisplayName` - The users display name
- `Enabled` - Whether they should be included in the email drafting list

### VersionLayer
The `VersionLayer` table contains any per-layer customisations that have been applied to this version.

- `VersionId` - The `Id` from the `Versions` table
- `LayerId` - The `Id` from the `Layer` table
- `CategoryId` - The `Id` from the `Category` table
- `IsDefault` - Whether this layer is turned on by default or not
- `DefaultOpacity` - The default opacity of the layer
- `DefaultSaturation` - The default saturation of the layer
- `SortOrder` - The position this layer appears within its category
- `MaxZoom` - The maximum viewable zoom level of the layer
- `MinZoom` - The minimum viewable zoom level of the layer
- `Id` - Unique autogenerated ID for this customisation

### VersionPrintConfiguration

The `VersionPrintConfiguration` table defines which print configurations are used in which versions.
Expand All @@ -102,6 +130,15 @@ The `VersionPrintConfiguration` table defines which print configurations are use
!!! note
If a specific configuration is not set for a version, it will fall back to that defined for the 'general' version

### VersionProjection

The `VersionProjection` table defines which projection the map renders in and what projections are available for viewing.

- `VersionId` - The `Id` from the `Versions` table
- `ProjectionId` - The `Id` from the `Projections` table
- `IsDefaultMapProjection` - Whether this projection is the one used for map rendering
- `IsDefaultViewProjection` - Whether this projection is the default one set as the display coordinates

### VersionSearchDefinition

The `VersionSearchDefinition` table defines which searches are available in which versions.
Expand Down
Loading

0 comments on commit 58f5019

Please sign in to comment.