Cesium for Unity 1.23.0
Loading...
Searching...
No Matches
CesiumGeoJsonDocument.cs
Go to the documentation of this file.
1using Reinterop;
2using System;
3using System.Threading.Tasks;
4using UnityEngine;
5
6namespace CesiumForUnity
7{
16 [ReinteropNativeImplementation(
17 "CesiumForUnityNative::CesiumGeoJsonDocumentImpl",
18 "CesiumGeoJsonDocumentImpl.h")]
19 public partial class CesiumGeoJsonDocument
20 {
24 internal CesiumGeoJsonDocument()
25 {
26 CreateImplementation();
27 }
32 public partial bool IsValid();
33
39
45 public static CesiumGeoJsonDocument Parse(string geoJsonString)
46 {
47 var document = new CesiumGeoJsonDocument();
48 if (document.ParseInternal(geoJsonString))
49 {
50 return document;
51 }
52 return null;
53 }
54
58 internal partial bool ParseInternal(string geoJsonString);
59
65 public static async Task<CesiumGeoJsonDocument> LoadFromUrlAsync(string url)
66 {
67 var tcs = new TaskCompletionSource<CesiumGeoJsonDocument>();
68 LoadFromUrl(url, (document) =>
69 {
70 tcs.SetResult(document);
71 });
72 return await tcs.Task;
73 }
74
80 private static partial void LoadFromUrl(string url, Action<CesiumGeoJsonDocument> callback);
81
89 public static async Task<CesiumGeoJsonDocument> LoadFromCesiumIonAsync(
90 long ionAssetId,
91 string ionAccessToken = "",
92 CesiumIonServer ionServer = null)
93 {
94 var tcs = new TaskCompletionSource<CesiumGeoJsonDocument>();
95 string serverUrl = ionServer != null ? ionServer.apiUrl : CesiumIonServer.defaultServer.apiUrl;
96 string token = !string.IsNullOrEmpty(ionAccessToken)
97 ? ionAccessToken
98 : (ionServer != null ? ionServer.defaultIonAccessToken : CesiumIonServer.defaultServer.defaultIonAccessToken);
99
100 LoadFromCesiumIon(ionAssetId, token, serverUrl, (document) =>
101 {
102 tcs.SetResult(document);
103 });
104 return await tcs.Task;
105 }
106
114 private static partial void LoadFromCesiumIon(
115 long ionAssetId,
116 string ionAccessToken,
117 string ionApiUrl,
118 Action<CesiumGeoJsonDocument> callback);
119
120 }
121}
partial CesiumGeoJsonObject GetRootObject()
Gets the root object of this GeoJSON document.
static async Task< CesiumGeoJsonDocument > LoadFromCesiumIonAsync(long ionAssetId, string ionAccessToken="", CesiumIonServer ionServer=null)
Loads a GeoJSON document from Cesium ion asynchronously.
static async Task< CesiumGeoJsonDocument > LoadFromUrlAsync(string url)
Loads a GeoJSON document from a URL asynchronously.
static CesiumGeoJsonDocument Parse(string geoJsonString)
Parses a GeoJSON document from a string.
partial bool IsValid()
Checks whether this GeoJSON document is valid.
Represents an object in a GeoJSON document.
Defines a Cesium ion Server.
string apiUrl
The URL of the main API endpoint of the Cesium ion server.
string defaultIonAccessToken
The default token used to access Cesium ion assets at runtime.
static CesiumIonServer defaultServer
Gets the default Cesium ion Server (ion.cesium.com).