Skip to content

Commit 561795d

Browse files
committed
add useGeographicProjection
1 parent fab3ed7 commit 561795d

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class CesiumWebMapTileServiceRasterOverlayEditor : Editor
1818
private SerializedProperty _style;
1919
private SerializedProperty _layer;
2020
private SerializedProperty _tileMatrixSetID;
21+
private SerializedProperty _useGeographicProjection;
2122

2223
private void OnEnable()
2324
{
@@ -37,6 +38,7 @@ private void OnEnable()
3738
this._style = this.serializedObject.FindProperty("_style");
3839
this._layer = this.serializedObject.FindProperty("_layer");
3940
this._tileMatrixSetID = this.serializedObject.FindProperty("_tileMatrixSetID");
41+
this._useGeographicProjection = this.serializedObject.FindProperty("_useGeographicProjection");
4042
}
4143

4244
private void OnDisable()
@@ -121,6 +123,12 @@ private void DrawWebMapTileServiceProperties()
121123
"Tile Matrix Set ID",
122124
"The tile matrix set identifier for WMTS requests.");
123125
EditorGUILayout.DelayedTextField(this._tileMatrixSetID, tileMatrixSetIDContent);
126+
127+
GUIContent useGeographicProjectionContent = new GUIContent(
128+
"Use Geographic Projection",
129+
"If true, the overlay will be projected using a geographic projection. " +
130+
"If false, the overlay will be projected using a web mercator projection.");
131+
EditorGUILayout.PropertyField(this._useGeographicProjection, useGeographicProjectionContent);
124132
}
125133

126134
private void DrawRasterOverlayProperties()

Runtime/CesiumWebMapTileServiceRasterOverlay.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ public string tileMatrixSetID
9292
this.Refresh();
9393
}
9494
}
95+
96+
[SerializeField] private bool _useGeographicProjection = false;
97+
98+
/// <summary>
99+
/// Change projection to GeographicProjection (the default is WebMercatorProjection).
100+
/// </summary>
101+
public bool useGeographicProjection
102+
{
103+
get => this._useGeographicProjection;
104+
set
105+
{
106+
this._useGeographicProjection = value;
107+
this.Refresh();
108+
}
109+
}
95110

96111
[SerializeField] private int _minimumLevel = 0;
97112

Runtime/ConfigureReinterop.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public void ExposeToCPP()
345345
webMapTileServiceRasterOverlay.style = webMapTileServiceRasterOverlay.style;
346346
webMapTileServiceRasterOverlay.layer = webMapTileServiceRasterOverlay.layer;
347347
webMapTileServiceRasterOverlay.tileMatrixSetID = webMapTileServiceRasterOverlay.tileMatrixSetID;
348+
webMapTileServiceRasterOverlay.useGeographicProjection = webMapTileServiceRasterOverlay.useGeographicProjection;
348349

349350
baseOverlay = webMapTileServiceRasterOverlay;
350351

native~/Runtime/src/CesiumWebMapTileServiceRasterOverlayImpl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ void CesiumWebMapTileServiceRasterOverlayImpl::AddToTileset(
4848
wmtsOptions.tileWidth = overlay.tileWidth();
4949
wmtsOptions.tileHeight = overlay.tileHeight();
5050

51+
if (overlay.useGeographicProjection()) {
52+
wmtsOptions.projection = CesiumGeospatial::GeographicProjection();
53+
}
54+
5155
CesiumForUnity::CesiumRasterOverlay genericOverlay = overlay;
5256
RasterOverlayOptions options =
5357
CesiumRasterOverlayUtility::GetOverlayOptions(genericOverlay);

0 commit comments

Comments
 (0)