GeoServer UI let's you save duplicate grids names

Description

A Gridset with duplicate grid names will cause referencing issues, for example:

  • Duplicate an existing Gridset

  • Set a few grid names all the same string

  • Apply that gridset to a layer

  • Open the tile layers preview for that layer

  • Zoom in

Since the grids have the same name, the first matching will be used even if the client is sending the coordinates of a different grid.
The client will use what is told to use according to the WMTS GetCapabilities.
The server will assume the client is requesting an out of bound tile.

The GeoServer UI should prevent the user from input duplicate grid names, or at least inform the user that issues may arise.

Example of bad configuration:

```
[...]
<scaleNames>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:8</string>
<string>GlobalCRS84Pixel:9</string>
<string>GlobalCRS84Pixel:10</string>
<string>GlobalCRS84Pixel:11</string>
<string>GlobalCRS84Pixel:12</string>
<string>GlobalCRS84Pixel:13</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
<string>GlobalCRS84Pixel:14</string>
</scaleNames>
[...]
```

Example of a request from the demo page:
http://localhost:8080/geoserver/gwc/service/wmts?layer=topp%3Astates&style=&tilematrixset=My_GlobalCRS84Pixel&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=GlobalCRS84Pixel%3A14&TileCol=5&TileRow=2

Response:
```
<?xml version="1.0" encoding="UTF-8"?>
<ExceptionReport version="1.1.0" xmlns="http://www.opengis.net/ows/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://geowebcache.org/schema/ows/1.1.0/owsExceptionReport.xsd">
<Exception exceptionCode="TileOutOfRange" locator="TILECOLUMN">
<ExceptionText>Column 5 is out of range, min: 0 max:0</ExceptionText>
</Exception>
</ExceptionReport>
```

Environment

None

Status

Assignee

Andrea Aime

Reporter

Gnafu

Triage

None

Fix versions

Affects versions

Components

Priority

Medium
Configure