Skip to content
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e2135b7
start working on multithreaded/multitasked FileSource
wilhelmberg Mar 21, 2017
92d67f1
rewor FileSource
wilhelmberg Mar 21, 2017
25304e2
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg Mar 21, 2017
89dd63f
Merge branch 'master' into BergWerkGIS-multithread-filesource
wilhelmberg Mar 23, 2017
676f50e
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg Mar 24, 2017
47a78ac
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg Apr 11, 2017
d34e21f
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg Apr 20, 2017
179ddd7
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg Apr 20, 2017
73bc07c
[wip] backport new FileSource and HttpRequest
wilhelmberg Apr 20, 2017
015d58a
test hang locally, let's see what AppVeyor does
wilhelmberg Apr 20, 2017
f5e5c51
AppVeyor: try tests again
wilhelmberg Apr 20, 2017
7e8d90c
more safe measures for HttpWebRequest.Abort
wilhelmberg Apr 20, 2017
fa698ae
[wip] Action.BeginInvoke does not work on UWP
wilhelmberg Apr 21, 2017
d80a8e8
[wip] UWP HTTPRequest
wilhelmberg Apr 24, 2017
78dec8c
new methods (UnityMainThreadDispatcher.Enqueue(())
wilhelmberg Apr 25, 2017
034e525
speed up HTTPWebRequest
wilhelmberg Apr 26, 2017
5fdada4
[wip] backporting latest HTTPRequest improments
wilhelmberg Apr 27, 2017
79e8041
comment Application.DoEvents
wilhelmberg Apr 27, 2017
213fc85
AppVeyor tests: how are you doing?
wilhelmberg Apr 28, 2017
3ac685e
quick fix for UWP
wilhelmberg Apr 28, 2017
8ed1f32
MockApi first try with https://github.com/richardszalay/mockhttp
wilhelmberg Apr 28, 2017
3655d67
MockApi try with https://github.com/hibri/HttpMock
wilhelmberg Apr 28, 2017
41f1b7b
mock api: hibri/HttpMock seems to work
wilhelmberg Apr 28, 2017
f4352c1
hm, mock api tests failing on AppVeyor
wilhelmberg Apr 28, 2017
06f5b5f
more mock api tests
wilhelmberg Apr 28, 2017
6cd195d
fix 'RateLimitHit' test
wilhelmberg May 3, 2017
32f1809
add HTTPRequest for 404
wilhelmberg May 3, 2017
a182306
add 'HasError' and 'Exceptions' to Mapbox.Map.Tile
wilhelmberg May 3, 2017
c4c25a4
HTTPRequest clean up and some changes for UWP
wilhelmberg May 3, 2017
d2f632e
progress and finished callbacks on IFileSource
wilhelmberg May 4, 2017
2df9131
[wip ]non threaded HTTPRequest
wilhelmberg May 4, 2017
c81d570
[wip] multiple implementations of IASynyRequest
wilhelmberg May 5, 2017
0937d97
try AppVeyor: HTTPRequestNonThreaded
wilhelmberg May 8, 2017
d92d66a
AppVeyor: another HTTPRequest test run
wilhelmberg May 8, 2017
474ee65
clean up HTTPRequest calling callback ;-)
wilhelmberg May 8, 2017
20e690b
Merge branch 'master' of https://github.com/mapbox/mapbox-sdk-cs into…
wilhelmberg May 9, 2017
4824dab
use 'Mapbox.Unity.Utilities.HTTPRequest' in IAsyncFactory
wilhelmberg May 9, 2017
e7cc5a5
remove left over HTTPREquestThreaded-2.cs
wilhelmberg May 9, 2017
5b440ea
convenience method: ExceptionsAsString
wilhelmberg May 9, 2017
da62fc6
some more Unity fixes
wilhelmberg May 9, 2017
3a98107
* Force Response to be created from ApiResponses
wilhelmberg May 9, 2017
8c29ead
fixes for UWP apps built with Unity
wilhelmberg May 9, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions MapboxSdkCs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geocoding", "src\Geocoding\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Directions", "src\Directions\Directions.csproj", "{08214364-755E-4D6F-B7FF-9D2D49011C20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono", "src\Mono\Mono.csproj", "{346B1208-1587-490B-A7DE-A96B86E81CD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "test\UnitTest\UnitTest.csproj", "{F04D4384-62B7-4F73-ACD9-C9A5112FC53F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Map", "src\Map\Map.csproj", "{6AECAE3C-A1F3-4B94-976B-D27AA4610879}"
Expand All @@ -26,8 +24,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeocodingUWP", "src\Geocodi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectionsUWP", "src\Directions\DirectionsUWP.csproj", "{44852FAF-423D-446D-BFDC-8A11DDA0C1C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoUWP", "src\Mono\MonoUWP.csproj", "{CD90BB97-AFF1-4699-96D6-2E9823FA7505}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapUWP", "src\Map\MapUWP.csproj", "{B01D8D98-78E8-4419-8138-4BE47BDD985B}"
EndProject
Global
Expand Down Expand Up @@ -102,21 +98,6 @@ Global
{08214364-755E-4D6F-B7FF-9D2D49011C20}.DebugUWP|x64.Build.0 = DebugUWP|Any CPU
{08214364-755E-4D6F-B7FF-9D2D49011C20}.DebugUWP|x86.ActiveCfg = DebugUWP|Any CPU
{08214364-755E-4D6F-B7FF-9D2D49011C20}.DebugUWP|x86.Build.0 = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|Any CPU.ActiveCfg = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|Any CPU.Build.0 = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|ARM.ActiveCfg = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|ARM.Build.0 = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|x64.ActiveCfg = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|x64.Build.0 = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|x86.ActiveCfg = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugNet|x86.Build.0 = DebugNet|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|Any CPU.ActiveCfg = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|ARM.ActiveCfg = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|ARM.Build.0 = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|x64.ActiveCfg = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|x64.Build.0 = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|x86.ActiveCfg = DebugUWP|Any CPU
{346B1208-1587-490B-A7DE-A96B86E81CD6}.DebugUWP|x86.Build.0 = DebugUWP|Any CPU
{F04D4384-62B7-4F73-ACD9-C9A5112FC53F}.DebugNet|Any CPU.ActiveCfg = DebugNet|Any CPU
{F04D4384-62B7-4F73-ACD9-C9A5112FC53F}.DebugNet|Any CPU.Build.0 = DebugNet|Any CPU
{F04D4384-62B7-4F73-ACD9-C9A5112FC53F}.DebugNet|ARM.ActiveCfg = DebugNet|Any CPU
Expand Down Expand Up @@ -222,21 +203,6 @@ Global
{44852FAF-423D-446D-BFDC-8A11DDA0C1C9}.DebugUWP|x64.Build.0 = DebugUWP|x64
{44852FAF-423D-446D-BFDC-8A11DDA0C1C9}.DebugUWP|x86.ActiveCfg = DebugUWP|x86
{44852FAF-423D-446D-BFDC-8A11DDA0C1C9}.DebugUWP|x86.Build.0 = DebugUWP|x86
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|Any CPU.ActiveCfg = DebugUWP|Any CPU
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|ARM.ActiveCfg = DebugNet|ARM
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|ARM.Build.0 = DebugNet|ARM
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|x64.ActiveCfg = DebugNet|x64
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|x64.Build.0 = DebugNet|x64
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|x86.ActiveCfg = DebugNet|x86
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugNet|x86.Build.0 = DebugNet|x86
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|Any CPU.ActiveCfg = DebugUWP|Any CPU
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|Any CPU.Build.0 = DebugUWP|Any CPU
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|ARM.ActiveCfg = DebugUWP|ARM
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|ARM.Build.0 = DebugUWP|ARM
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|x64.ActiveCfg = DebugUWP|x64
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|x64.Build.0 = DebugUWP|x64
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|x86.ActiveCfg = DebugUWP|x86
{CD90BB97-AFF1-4699-96D6-2E9823FA7505}.DebugUWP|x86.Build.0 = DebugUWP|x86
{B01D8D98-78E8-4419-8138-4BE47BDD985B}.DebugNet|Any CPU.ActiveCfg = DebugUWP|Any CPU
{B01D8D98-78E8-4419-8138-4BE47BDD985B}.DebugNet|ARM.ActiveCfg = DebugNet|ARM
{B01D8D98-78E8-4419-8138-4BE47BDD985B}.DebugNet|ARM.Build.0 = DebugNet|ARM
Expand Down
16 changes: 0 additions & 16 deletions src/Map/Map.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mapbox.VectorTile.ExtensionMethods, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mapbox.VectorTile.1.0.3-alpha1\lib\net35\Mapbox.VectorTile.ExtensionMethods.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mapbox.VectorTile.Geometry, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mapbox.VectorTile.1.0.3-alpha1\lib\net35\Mapbox.VectorTile.Geometry.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mapbox.VectorTile.PbfReader, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mapbox.VectorTile.1.0.3-alpha1\lib\net35\Mapbox.VectorTile.PbfReader.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mapbox.VectorTile.VectorTileReader, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Mapbox.VectorTile.1.0.3-alpha1\lib\net35\Mapbox.VectorTile.VectorTileReader.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Map/Map.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"win": {}
},
"dependencies": {
"Mapbox.VectorTile": "1.0.3-alpha2"
"Mapbox.VectorTile": "1.0.4-alpha1"
}
}
151 changes: 82 additions & 69 deletions src/Map/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@
// </copyright>
//-----------------------------------------------------------------------

namespace Mapbox.Map
{
namespace Mapbox.Map {
using System;
using Mapbox.Platform;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;


/// <summary>
/// A Map tile, a square with vector or raster data representing a geographic
/// bounding box. More info <see href="https://en.wikipedia.org/wiki/Tiled_web_map">
/// here </see>.
/// </summary>
public abstract class Tile
{
public abstract class Tile {


private CanonicalTileId _id;
private List<Exception> _exceptions;
private State _state = State.New;
private IAsyncRequest _request;
private Action _callback;

private CanonicalTileId id;
private string error;
private State state = State.New;
private IAsyncRequest request;
private Action callback;

/// <summary> Tile state. </summary>
public enum State
{
public enum State {
/// <summary> New tile, not yet initialized. </summary>
New,
/// <summary> Loading data. </summary>
Expand All @@ -38,67 +41,74 @@ public enum State

/// <summary> Gets the <see cref="T:Mapbox.Map.CanonicalTileId"/> identifier. </summary>
/// <value> The canonical tile identifier. </value>
public CanonicalTileId Id
{
get
{
return this.id;
}
set
{
this.id = value;
public CanonicalTileId Id {
get { return _id; }
set { _id = value; }
}


/// <summary>Flag to indicate if the request was successful</summary>
public bool HasError {
get {
return _exceptions == null ? false : _exceptions.Count > 0;
}
}

/// <summary> Gets the error message if any. </summary>
/// <value> The error string. </value>
public string Error
{
get
{
return this.error;

/// <summary> Exceptions that might have occured during creation of the tile. </summary>
public ReadOnlyCollection<Exception> Exceptions {
get { return null == _exceptions ? null : _exceptions.AsReadOnly(); }
}


/// <summary> Messages of exceptions otherwise empty string. </summary>
public string ExceptionsAsString {
get {
if (null == _exceptions || _exceptions.Count == 0) { return string.Empty; }
return string.Join(Environment.NewLine, _exceptions.Select(e => e.Message).ToArray());
}
}


/// <summary>
/// Sets the error message.
/// </summary>
/// <param name="errorMessage"></param>
public void SetError(string errorMessage)
{
error = errorMessage;
internal void AddException(Exception ex) {
if (null == _exceptions) { _exceptions = new List<Exception>(); }
_exceptions.Add(ex);
}


/// <summary>
/// Gets the current state. When fully loaded, you must
/// check if the data actually arrived and if the tile
/// is accusing any error.
/// </summary>
/// <value> The tile state. </value>
public State CurrentState
{
get
{
return this.state;
public State CurrentState {
get {
return _state;
}
}


/// <summary>
/// Initializes the <see cref="T:Mapbox.Map.Tile"/> object. It will
/// start a network request and fire the callback when completed.
/// </summary>
/// <param name="param"> Initialization parameters. </param>
/// <param name="callback"> The completion callback. </param>
public void Initialize(Parameters param, Action callback)
{
this.Cancel();

this.state = State.Loading;
this.id = param.Id;
this.request = param.Fs.Request(this.MakeTileResource(param.MapId).GetUrl(), this.HandleTileResponse);
this.callback = callback;
public void Initialize(Parameters param, Action callback) {
Cancel();

_state = State.Loading;
_id = param.Id;
_request = param.Fs.Request(MakeTileResource(param.MapId).GetUrl(), HandleTileResponse);
_callback = callback;
}


/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current
/// <see cref="T:Mapbox.Map.Tile"/>.
Expand All @@ -107,11 +117,11 @@ public void Initialize(Parameters param, Action callback)
/// A <see cref="T:System.String"/> that represents the current
/// <see cref="T:Mapbox.Map.Tile"/>.
/// </returns>
public override string ToString()
{
return this.Id.ToString();
public override string ToString() {
return Id.ToString();
}


/// <summary>
/// Cancels the request for the <see cref="T:Mapbox.Map.Tile"/> object.
/// It will stop a network request and set the tile's state to Canceled.
Expand All @@ -121,7 +131,7 @@ public override string ToString()
/// // Do not request tiles that we are already requesting
/// // but at the same time exclude the ones we don't need
/// // anymore, cancelling the network request.
/// this.tiles.RemoveWhere((T tile) =>
/// tiles.RemoveWhere((T tile) =>
/// {
/// if (cover.Remove(tile.Id))
/// {
Expand All @@ -130,50 +140,52 @@ public override string ToString()
/// else
/// {
/// tile.Cancel();
/// this.NotifyNext(tile);
/// NotifyNext(tile);
/// return true;
/// }
/// });
/// </code>
/// </example>
public void Cancel()
{
if (this.request != null)
{
this.request.Cancel();
this.request = null;
public void Cancel() {
if (_request != null) {
_request.Cancel();
_request = null;
}

this.state = State.Canceled;
_state = State.Canceled;
}

public void SetState(State state) { this.state = state; }

// Get the tile resource (raster/vector/etc).
internal abstract TileResource MakeTileResource(string mapid);


// Decode the tile.
internal abstract bool ParseTileData(byte[] data);


// TODO: Currently the tile decoding is done on the main thread. We must implement
// a Worker class to abstract this, so on platforms that support threads (like Unity
// on the desktop, Android, etc) we can use worker threads and when building for
// the browser, we keep it single-threaded.
private void HandleTileResponse(Response response)
{
if (!string.IsNullOrEmpty(response.Error))
{
this.error = response.Error;
}
else if (this.ParseTileData(response.Data) == false)
{
this.error = "ParseError";
private void HandleTileResponse(Response response) {

if (response.HasError) {
response.Exceptions.ToList().ForEach(e => AddException(e));
} else {
// only try to parse if request was successful

// current implementation doesn't need to check if parsing is successful:
// * Mapbox.Map.VectorTile.ParseTileData() already adds any exception to the list
// * Mapbox.Map.RasterTile.ParseTileData() doesn't do any parsing
ParseTileData(response.Data);
}

this.state = State.Loaded;
this.callback();
_state = State.Loaded;
_callback();
}


/// <summary>
/// Parameters for initializing a Tile object.
/// </summary>
Expand All @@ -185,8 +197,7 @@ private void HandleTileResponse(Response response)
/// parameters.MapId = "mapbox.mapbox-streets-v7";
/// </code>
/// </example>
public struct Parameters
{
public struct Parameters {
/// <summary> The tile id. </summary>
public CanonicalTileId Id;

Expand All @@ -200,5 +211,7 @@ public struct Parameters
/// <summary> The data source abstraction. </summary>
public IFileSource Fs;
}


}
}
Loading