5
5
6
6
namespace Mapbox . BaseModule . Data . Platform . TileJSON
7
7
{
8
- public class TileJSON
9
- {
8
+ public class TileJSON
9
+ {
10
10
11
- private IFileSource _fileSource ;
12
- private int _timeout ;
11
+ private IFileSource _fileSource ;
12
+ private int _timeout ;
13
13
14
14
15
- public IFileSource FileSource { get { return _fileSource ; } }
15
+ public IFileSource FileSource { get { return _fileSource ; } }
16
16
17
17
18
- public TileJSON ( IFileSource fileSource , int timeout )
19
- {
20
- _fileSource = fileSource ;
21
- _timeout = timeout ;
22
- }
18
+ public TileJSON ( IFileSource fileSource , int timeout )
19
+ {
20
+ _fileSource = fileSource ;
21
+ _timeout = timeout ;
22
+ }
23
23
24
24
25
- public IAsyncRequest Get ( string tilesetName , Action < TileJSONResponse > callback )
26
- {
27
- string url = string . Format (
28
- "{0}v4/{1}.json?secure"
29
- , Constants . Map . BaseAPI
30
- , tilesetName
31
- ) ;
25
+ public IAsyncRequest Get ( string tilesetName , Action < TileJSONResponse > callback )
26
+ {
27
+ string url = string . Format (
28
+ "{0}v4/{1}.json?secure"
29
+ , Constants . Map . BaseAPI
30
+ , tilesetName
31
+ ) ;
32
32
33
- return _fileSource . Request (
34
- url
35
- , ( Response response ) =>
36
- {
37
- string json = Encoding . UTF8 . GetString ( response . Data ) ;
38
- TileJSONResponse tileJSONResponse = JsonConvert . DeserializeObject < TileJSONResponse > ( json ) ;
39
- if ( tileJSONResponse != null )
40
- {
41
- tileJSONResponse . Source = tilesetName ;
42
- }
43
- callback ( tileJSONResponse ) ;
44
- }
45
- , _timeout
46
- ) ;
47
- }
33
+ return _fileSource . Request (
34
+ url
35
+ , ( Response response ) =>
36
+ {
37
+ if ( response != null && response . Data != null && response . Data . Length > 0 )
38
+ {
39
+ string json = Encoding . UTF8 . GetString ( response . Data ) ;
40
+ TileJSONResponse tileJSONResponse = JsonConvert . DeserializeObject < TileJSONResponse > ( json ) ;
41
+ if ( tileJSONResponse != null )
42
+ {
43
+ tileJSONResponse . Source = tilesetName ;
44
+ }
45
+ callback ( tileJSONResponse ) ;
46
+ }
48
47
48
+ callback ( null ) ;
49
+ }
50
+ , _timeout
51
+ ) ;
52
+ }
49
53
50
54
51
55
52
- }
53
- }
56
+
57
+ }
58
+ }
0 commit comments