Пример #1
0
        private OfflineRegionDto Transform(OfflineRegion region)
        {
            var definition = region.Definition as OfflineTilePyramidRegionDefinition;
            var regionDto  = new OfflineRegionDto()
            {
                Id     = region.ID,
                Bounds = new LatLngBoundsDto()
                {
                    Ne = new Coordinate
                    {
                        Latitude  = definition.Bounds.NorthEast.Latitude,
                        Longitude = definition.Bounds.NorthEast.Longitude
                    },
                    Sw = new Coordinate
                    {
                        Latitude  = definition.Bounds.SouthWest.Latitude,
                        Longitude = definition.Bounds.SouthWest.Longitude
                    }
                },
                Style            = definition.StyleURL,
                MinimumZoomLevel = definition.MinZoom,
                MaximumZoomLevel = definition.MaxZoom
            };

            return(regionDto);
        }
Пример #2
0
        private Task <DownloadState> GetStatusRegionDto(OfflineRegion offlineRegion)
        {
            var tcs = new TaskCompletionSource <DownloadState>();

            offlineRegion.GetStatus(new OfflineRegionStatusCallback
            {
                OnStatusCallback = status =>
                {
                    if (status.IsComplete)
                    {
                        tcs.TrySetResult(DownloadState.Completed);
                    }
                    else if (status.RequiredResourceCount == status.CompletedResourceCount)
                    {
                        tcs.TrySetResult(DownloadState.Inactive);
                    }
                    else
                    {
                        tcs.TrySetResult(DownloadState.Inactive);
                    }
                }
            });

            return(tcs.Task);
        }
        public static OfflinePack ToFormsPack(this OfflineRegion mbRegion)
        {
            if (mbRegion == null)
            {
                return(null);
            }
            var output = new OfflinePack()
            {
                Handle = mbRegion.Handle
            };

            output.Id = mbRegion.ID;
            var definition = mbRegion.Definition;

            if (definition is OfflineTilePyramidRegionDefinition def)
            {
                output.Region = def.ToFormsRegion();
            }
            if (mbRegion.GetMetadata() is byte[] metadata)
            {
                String json = new String(metadata, OfflineStorageService.JSON_CHARSET);

                try
                {
                    JsonObject jsonObject = (JsonObject) new Gson().FromJson(json.ToString(), Java.Lang.Class.FromType(typeof(JsonObject)));
                    if (jsonObject != null)
                    {
                        var keys = jsonObject.KeySet();
                        output.Info = new Dictionary <string, string>(keys.Count);
                        foreach (string key in keys)
                        {
                            output.Info.Add(key, jsonObject.Get(key).AsString);
                        }
                    }
                }
                catch (Exception ex) {
                    System.Diagnostics.Debug.WriteLine("Failed to decode offline region metadata: " + ex.Message);
                }
            }
            return(output);
        }
 public void OnCreate(OfflineRegion offlineRegion)
 {
     OnCreateHandle?.Invoke(offlineRegion);
 }
 public void OnCreate(OfflineRegion region)
 {
     OnListCallback?.Invoke(region);
 }
 public void OnCreate(OfflineRegion p0)
 {
     OnCreateHandle?.Invoke(p0);
 }