Skip to content

Commit

Permalink
Merge pull request #446 from CesiumGS/add-wmts-properties
Browse files Browse the repository at this point in the history
Add extra WMTS properties
  • Loading branch information
kring authored Mar 29, 2024
2 parents 354466e + e1a0bc6 commit 07c62eb
Show file tree
Hide file tree
Showing 9 changed files with 509 additions and 78 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

##### Additions :tada:

- Added `CesiumWebMapTileServiceRasterOverlay`, which enables Web Map Tile Service (WMTS) imagery to be draped on a `Cesium3DTileset`.
- Added support for the `KHR_texture_transform` glTF extension - including rotation - for picking with `CesiumFeatureIdTexture`.

##### Fixes :wrench:
Expand Down
2 changes: 0 additions & 2 deletions Editor/Cesium3DTilesetEditor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

Expand Down
3 changes: 0 additions & 3 deletions Editor/CesiumWebMapServiceRasterOverlayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace CesiumForUnity
[CustomEditor(typeof(CesiumWebMapServiceRasterOverlay))]
public class CesiumWebMapServiceRasterOverlayEditor : Editor
{
private CesiumWebMapServiceRasterOverlay _webMapServiceOverlay;
private CesiumRasterOverlayEditor _rasterOverlayEditor;

private SerializedProperty _baseUrl;
Expand All @@ -18,8 +17,6 @@ public class CesiumWebMapServiceRasterOverlayEditor : Editor

private void OnEnable()
{
this._webMapServiceOverlay =
(CesiumWebMapServiceRasterOverlay)this.target;
this._rasterOverlayEditor =
(CesiumRasterOverlayEditor)Editor.CreateEditor(
this.target,
Expand Down
216 changes: 175 additions & 41 deletions Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,58 @@ namespace CesiumForUnity
[CustomEditor(typeof(CesiumWebMapTileServiceRasterOverlay))]
public class CesiumWebMapTileServiceRasterOverlayEditor : Editor
{
private CesiumWebMapTileServiceRasterOverlay _webMapTileServiceOverlay;
private CesiumRasterOverlayEditor _rasterOverlayEditor;

private SerializedProperty _baseUrl;
private SerializedProperty _layer;
private SerializedProperty _style;
private SerializedProperty _format;
private SerializedProperty _tileMatrixSetID;
private SerializedProperty _tileMatrixSetLabelPrefix;
private SerializedProperty _specifyTileMatrixSetLabels;
private SerializedProperty _tileMatrixSetLabels;
private SerializedProperty _projection;
private SerializedProperty _specifyTilingScheme;
private SerializedProperty _rootTilesX;
private SerializedProperty _rootTilesY;
private SerializedProperty _rectangleWest;
private SerializedProperty _rectangleSouth;
private SerializedProperty _rectangleEast;
private SerializedProperty _rectangleNorth;
private SerializedProperty _tileWidth;
private SerializedProperty _tileHeight;
private SerializedProperty _specifyZoomLevels;
private SerializedProperty _minimumLevel;
private SerializedProperty _maximumLevel;
private SerializedProperty _format;
private SerializedProperty _style;
private SerializedProperty _layer;
private SerializedProperty _tileMatrixSetID;
private SerializedProperty _useGeographicProjection;

private void OnEnable()
{
this._webMapTileServiceOverlay =
(CesiumWebMapTileServiceRasterOverlay)this.target;
this._rasterOverlayEditor =
(CesiumRasterOverlayEditor)Editor.CreateEditor(
this.target,
typeof(CesiumRasterOverlayEditor));

this._baseUrl = this.serializedObject.FindProperty("_baseUrl");
this._layer = this.serializedObject.FindProperty("_layer");
this._style = this.serializedObject.FindProperty("_style");
this._format = this.serializedObject.FindProperty("_format");
this._tileMatrixSetID = this.serializedObject.FindProperty("_tileMatrixSetID");
this._tileMatrixSetLabelPrefix = this.serializedObject.FindProperty("_tileMatrixSetLabelPrefix");
this._specifyTileMatrixSetLabels = this.serializedObject.FindProperty("_specifyTileMatrixSetLabels");
this._tileMatrixSetLabels = this.serializedObject.FindProperty("_tileMatrixSetLabels");
this._projection = this.serializedObject.FindProperty("_projection");
this._specifyTilingScheme = this.serializedObject.FindProperty("_specifyTilingScheme");
this._rootTilesX = this.serializedObject.FindProperty("_rootTilesX");
this._rootTilesY = this.serializedObject.FindProperty("_rootTilesY");
this._rectangleWest = this.serializedObject.FindProperty("_rectangleWest");
this._rectangleSouth = this.serializedObject.FindProperty("_rectangleSouth");
this._rectangleEast = this.serializedObject.FindProperty("_rectangleEast");
this._rectangleNorth = this.serializedObject.FindProperty("_rectangleNorth");
this._tileWidth = this.serializedObject.FindProperty("_tileWidth");
this._tileHeight = this.serializedObject.FindProperty("_tileHeight");
this._specifyZoomLevels = this.serializedObject.FindProperty("_specifyZoomLevels");
this._minimumLevel = this.serializedObject.FindProperty("_minimumLevel");
this._maximumLevel = this.serializedObject.FindProperty("_maximumLevel");
this._format = this.serializedObject.FindProperty("_format");
this._style = this.serializedObject.FindProperty("_style");
this._layer = this.serializedObject.FindProperty("_layer");
this._tileMatrixSetID = this.serializedObject.FindProperty("_tileMatrixSetID");
this._useGeographicProjection = this.serializedObject.FindProperty("_useGeographicProjection");
}

private void OnDisable()
Expand All @@ -54,14 +73,20 @@ public override void OnInspectorGUI()
this.serializedObject.Update();

EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
DrawWebMapTileServiceProperties();
this.DrawBasicProperties();
EditorGUILayout.Space(5);
this.DrawTileMatrixSetProperties();
EditorGUILayout.Space(5);
this.DrawTilingSchemeProperties();
EditorGUILayout.Space(5);
DrawRasterOverlayProperties();
this.DrawLevelOfDetailContent();
EditorGUILayout.Space(5);
this.DrawRasterOverlayProperties();

this.serializedObject.ApplyModifiedProperties();
}

private void DrawWebMapTileServiceProperties()
private void DrawBasicProperties()
{
GUIContent baseUrlContent = new GUIContent(
"Base URL",
Expand All @@ -71,32 +96,155 @@ private void DrawWebMapTileServiceProperties()
"\n\n" +
"https://tile.openstreetmap.org/{TileMatrix}/{TileCol}/{TileRow}.png");
EditorGUILayout.DelayedTextField(this._baseUrl, baseUrlContent);

GUIContent layerContent = new GUIContent(
"Layer",
"The layer name for WMTS requests.");
EditorGUILayout.DelayedTextField(this._layer, layerContent);

GUIContent styleContent = new GUIContent(
"Style",
"The style name for WMTS requests.");
EditorGUILayout.DelayedTextField(this._style, styleContent);

GUIContent formatContent = new GUIContent(
"Format",
"The MIME type for images to retrieve from the server.");
EditorGUILayout.DelayedTextField(this._format, formatContent);

}

private void DrawTileMatrixSetProperties()
{
GUILayout.Label("Tile Matrix Set Descriptors", EditorStyles.boldLabel);

GUIContent tileMatrixSetIDContent = new GUIContent(
"Tile Matrix Set ID",
"The tile matrix set identifier for WMTS requests.");
EditorGUILayout.DelayedTextField(this._tileMatrixSetID, tileMatrixSetIDContent);

GUIContent useGeographicProjectionContent = new GUIContent(
"Use Geographic Projection",
"If true, the overlay will be projected using a geographic projection. " +
"If false, the overlay will be projected using a web mercator projection.");
EditorGUILayout.PropertyField(this._useGeographicProjection, useGeographicProjectionContent);

EditorGUI.BeginDisabledGroup(this._specifyTileMatrixSetLabels.boolValue);
GUIContent tileMatrixSetLabelPrefixContent = new GUIContent(
"Tile Matrix Set Label Prefix",
"The prefix to use for the tile matrix set labels. For instance, setting \"EPSG:4326:\" " +
"as the prefix generates the list [\"EPSG:4326:0\", \"EPSG:4326:1\", \"EPSG:4326:2\", ...]." +
"\n\n" +
"Only applicable when \"Specify Tile Matrix Set Labels\" is false.");
EditorGUILayout.PropertyField(this._tileMatrixSetLabelPrefix, tileMatrixSetLabelPrefixContent);
EditorGUI.EndDisabledGroup();

GUIContent specifyTileMatrixSetLabelsContent = new GUIContent(
"Specify Tile Matrix Set Labels",
"Set this to true to manually specify the tile matrix set labels. If false, the labels " +
"will be constructed from the specified levels and prefix (if one is specified).");
EditorGUILayout.PropertyField(this._specifyTileMatrixSetLabels, specifyTileMatrixSetLabelsContent);

EditorGUI.BeginDisabledGroup(!this._specifyTileMatrixSetLabels.boolValue);
GUIContent tileMatrixSetLabelsContent = new GUIContent(
"Tile Matrix Set Label",
"The manually specified tile matrix set labels." +
"\n\n" +
"Only applicable when \"Specify Tile Matrix Set Labels\" is true.");
EditorGUILayout.PropertyField(this._tileMatrixSetLabels, tileMatrixSetLabelsContent);
EditorGUI.EndDisabledGroup();
}

private void DrawTilingSchemeProperties()
{
GUILayout.Label("Tiling Scheme", EditorStyles.boldLabel);

GUIContent projectionContent = new GUIContent(
"Projection",
"The type of projection used to project the WMTS imagery onto the globe. " +
"For instance, EPSG:4326 uses geographic projection and EPSG:3857 uses Web Mercator.");
EditorGUILayout.PropertyField(this._projection, projectionContent);

GUIContent specifyTilingSchemeContent = new GUIContent(
"Specify Tiling Scheme",
"Set this to true to specify the quadtree tiling scheme according to the specified root " +
"tile numbers and projected bounding rectangle. If false, the tiling scheme will be " +
"deduced from the projection.");
EditorGUILayout.PropertyField(this._specifyTilingScheme, specifyTilingSchemeContent);

EditorGUI.BeginDisabledGroup(!this._specifyTilingScheme.boolValue);
GUIContent rootTilesXContent = new GUIContent(
"Root Tiles X",
"The number of tiles corresponding to TileCol, also known as TileMatrixWidth. " +
"If specified, this determines the number of tiles at the root of the quadtree " +
"tiling scheme in the X direction." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
EditorGUILayout.PropertyField(this._rootTilesX, rootTilesXContent);

GUIContent rootTilesYContent = new GUIContent(
"Root Tiles Y",
"The number of tiles corresponding to TileRow, also known as TileMatrixHeight. " +
"If specified, this determines the number of tiles at the root of the quadtree " +
"tiling scheme in the Y direction." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
EditorGUILayout.PropertyField(this._rootTilesY, rootTilesYContent);

GUIContent rectangleWest = new GUIContent(
"Rectangle West",
"The west boundary of the bounding rectangle used for the quadtree tiling scheme. " +
"Specified in longitude degrees in the range [-180, 180]." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
CesiumInspectorGUI.ClampedDoubleField(this._rectangleWest, -180, 180, rectangleWest, true);

GUIContent rectangleSouth = new GUIContent(
"Rectangle South",
"The south boundary of the bounding rectangle used for the quadtree tiling scheme. " +
"Specified in latitude degrees in the range [-90, 90]." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
CesiumInspectorGUI.ClampedDoubleField(this._rectangleSouth, -90, 90, rectangleSouth, true);

GUIContent rectangleEast = new GUIContent(
"Rectangle East",
"The east boundary of the bounding rectangle used for the quadtree tiling scheme. " +
"Specified in longitude degrees in the range [-180, 180]." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
CesiumInspectorGUI.ClampedDoubleField(this._rectangleEast, -180, 180, rectangleEast, true);

GUIContent rectangleNorth = new GUIContent(
"Rectangle North",
"The north boundary of the bounding rectangle used for the quadtree tiling scheme. " +
"Specified in latitude degrees in the range [-90, 90]." +
"\n\n" +
"Only applicable if \"Specify Tiling Scheme\" is set to true.");
CesiumInspectorGUI.ClampedDoubleField(this._rectangleNorth, -90, 90, rectangleNorth, true);
EditorGUI.EndDisabledGroup();
}

private void DrawLevelOfDetailContent()
{
GUILayout.Label("Level of Detail", EditorStyles.boldLabel);

GUIContent specifyZoomLevelsContent = new GUIContent(
"Specify Zoom Levels",
"Set this to true to directly specify the minimum and maximum zoom levels available " +
"from the server. If false, the minimum and maximum zoom levels will be retrieved " +
"from the server's tilemapresource.xml file."
);
EditorGUILayout.PropertyField(this._specifyZoomLevels, specifyZoomLevelsContent);

EditorGUI.BeginDisabledGroup(!this._specifyZoomLevels.boolValue);
GUIContent minimumLevelContent = new GUIContent(
"Minimum Level",
"Minimum zoom level." +
"\n\n" +
"Take care when specifying this that the number of tiles at the " +
"minimum level is small, such as four or less. A larger number " +
"is likely to result in rendering problems.");
EditorGUILayout.PropertyField(this._minimumLevel, minimumLevelContent);

GUIContent maximumLevelContent = new GUIContent(
"Maximum Level",
"Maximum zoom level.");
EditorGUILayout.PropertyField(this._maximumLevel, maximumLevelContent);
EditorGUI.EndDisabledGroup();

GUIContent tileWidthContent = new GUIContent(
"Tile Width",
Expand All @@ -115,20 +263,6 @@ private void DrawWebMapTileServiceProperties()
64,
2048,
tileHeightContent);

GUIContent minimumLevelContent = new GUIContent(
"Minimum Level",
"Minimum zoom level." +
"\n\n" +
"Take care when specifying this that the number of tiles at the " +
"minimum level is small, such as four or less. A larger number " +
"is likely to result in rendering problems.");
EditorGUILayout.PropertyField(this._minimumLevel, minimumLevelContent);

GUIContent maximumLevelContent = new GUIContent(
"Maximum Level",
"Maximum zoom level.");
EditorGUILayout.PropertyField(this._maximumLevel, maximumLevelContent);
}

private void DrawRasterOverlayProperties()
Expand Down
4 changes: 2 additions & 2 deletions Runtime/CesiumGeoreference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public double latitude
get => this._latitude;
set
{
this._latitude = value;
this._latitude = Math.Clamp(value, -90, 90);
this.originAuthority = CesiumGeoreferenceOriginAuthority.LongitudeLatitudeHeight;
}
}
Expand All @@ -149,7 +149,7 @@ public double longitude
get => this._longitude;
set
{
this._longitude = value;
this._longitude = Math.Clamp(value, -180, 180);
this.originAuthority = CesiumGeoreferenceOriginAuthority.LongitudeLatitudeHeight;
}
}
Expand Down
Loading

0 comments on commit 07c62eb

Please sign in to comment.