This commit is contained in:
runette committed 2024-04-22 15:52:51 +01:00
commit e0afef912e
1285 files changed
+83219

No files matched your search

@@ -0,0 +1,54 @@
using Mapbox.Json;
using Mapbox.Utils;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mapbox.Platform.TilesetTileJSON
{
public class TileJSON
{
private IFileSource _fileSource;
private int _timeout;
public IFileSource FileSource { get { return _fileSource; } }
public TileJSON(IFileSource fileSource, int timeout)
{
_fileSource = fileSource;
_timeout = timeout;
}
public IAsyncRequest Get(string tilesetName, Action<TileJSONResponse> callback)
{
string url = string.Format(
"{0}v4/{1}.json?secure"
, Constants.BaseAPI
, tilesetName
);
return _fileSource.Request(
url
, (Response response) =>
{
string json = Encoding.UTF8.GetString(response.Data);
TileJSONResponse tileJSONResponse = JsonConvert.DeserializeObject<TileJSONResponse>(json);
if (tileJSONResponse != null)
{
tileJSONResponse.Source = tilesetName;
}
callback(tileJSONResponse);
}
, _timeout
);
}
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ab78da4f6b501ed4b8ea92121d3392b8
timeCreated: 1515589539
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
namespace Mapbox.Platform.TilesetTileJSON
{
using Mapbox.Json;
using System.Collections.Generic;
public class TileJSONObjectVectorLayer
{
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("fields")]
public Dictionary<string, string> Fields { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("source")]
public string Source { get; set; }
[JsonProperty("source_name")]
public string SourceName { get; set; }
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 4d926842f7750b041be895c39e959799
timeCreated: 1515590225
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,165 @@
namespace Mapbox.Platform.TilesetTileJSON
{
using Mapbox.Json;
using Mapbox.Utils;
using System;
public class TileJSONResponse
{
[JsonProperty("attribution")]
public string Attribution { get; set; }
[JsonProperty("autoscale")]
public bool AutoScale { get; set; }
private double[] _bounds;
[JsonProperty("bounds")]
public double[] Bounds
{
get { return _bounds; }
set
{
_bounds = value;
BoundsParsed = new Vector2dBounds(
new Vector2d(Bounds[1], Bounds[0])
, new Vector2d(Bounds[3], Bounds[2])
);
}
}
[JsonIgnore]
public Vector2dBounds BoundsParsed { get; private set; }
private double[] _center;
[JsonProperty("center")]
public double[] Center
{
get { return _center; }
set
{
_center = value;
CenterParsed = new Vector2d(_center[1], _center[0]);
}
}
[JsonIgnore]
public Vector2d CenterParsed { get; private set; }
private long? _created;
/// <summary>Concatenated tilesets don't have a created property </summary>
[JsonProperty("created")]
public long? Created
{
get { return _created; }
set
{
_created = value;
if (_created.HasValue)
{
CreatedUtc = UnixTimestampUtils.From(_created.Value);
}
else
{
CreatedUtc = null;
}
}
}
/// <summary>Concatenated tilesets don't have a created property </summary>
[JsonIgnore]
public DateTime? CreatedUtc { get; private set; }
[JsonProperty("description")]
public string Description { get; set; }
/// <summary>Can be empty</summary>
[JsonProperty("format")]
public string Format { get; set; }
/// <summary>Can be empty (for concatenated tilesets)</summary>
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("maxzoom")]
public int MaxZoom { get; set; }
[JsonProperty("minzoom")]
public int MinZoom { get; set; }
private long? _modified;
/// <summary>Unmodified tilesets don't have a modfied property </summary>
[JsonProperty("modified")]
public long? Modified
{
get { return _modified; }
set
{
_modified = value;
if (_modified.HasValue)
{
ModifiedUtc = UnixTimestampUtils.From(_modified.Value);
}
else
{
ModifiedUtc = null;
}
}
}
/// <summary>Unmodified tilesets don't have a modfied property </summary>
[JsonIgnore]
public DateTime? ModifiedUtc { get; private set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("private")]
public bool Private { get; set; }
[JsonProperty("scheme")]
public string Scheme { get; set; }
/// <summary>Can be empty</summary>
[JsonProperty("source")]
public string Source { get; set; }
[JsonProperty("tilejson")]
public string TileJSONVersion { get; set; }
[JsonProperty("tiles")]
public string[] Tiles { get; set; }
[JsonProperty("vector_layers")]
public TileJSONObjectVectorLayer[] VectorLayers { get; set; }
/// <summary>Can be empty (for concatenated tilesets)</summary>
[JsonProperty("webpage")]
public string WebPage { get; set; }
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8f58425aa7b211946a73691da0414edb
timeCreated: 1515589539
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: