/// <summary>${Mapping_MBTilesLayer_method_Initialize_D}</summary> public override async void Initialize() { if (!_isInitializing&&!IsInitialized&&!string.IsNullOrEmpty(MBTilesPath)) { _parameter = await MBTilesHelper.GetMBTilesParameter(MBTilesPath); this.Resolutions = _parameter.Resolutions; this.Bounds = _parameter.Bounds; this.Origin = _parameter.Origin; this.TileSize = _parameter.TileHeight; if (_parameter.WKID > 0) { this.CRS = new Core.CoordinateReferenceSystem(_parameter.WKID); } base.Initialize(); } }
public static async Task<MBTilesParameters> GetMBTilesParameter(string path) { MBTilesParameters parameter = null; try { parameter = new MBTilesParameters(); SQLiteAsyncConnection connection = new SQLiteAsyncConnection(path); AsyncTableQuery<MBTilesInfoTable> table = connection.Table<MBTilesInfoTable>(); List<MBTilesInfoTable> list = await table.ToListAsync(); Dictionary<string, MBTilesInfoTable> paramDic = list.ToDictionary<MBTilesInfoTable, string>(c => c.Name); parameter.Bounds = StringToRectangle2D(paramDic["bounds"].Value); bool compatible = false; bool.TryParse(paramDic["compatible"].Value, out compatible); parameter.Compatible = compatible; parameter.Description = paramDic["description"].Value; FormatType format = FormatType.PNG; Enum.TryParse<FormatType>(paramDic["compatible"].Value, out format); parameter.Format = format; MBTilesLayerType layertype = MBTilesLayerType.Overlay; Enum.TryParse<MBTilesLayerType>(paramDic["type"].Value, out layertype); parameter.LayerType = layertype; parameter.MapParameter = paramDic["map_parameter"].Value; parameter.Name = paramDic["name"].Value; parameter.Origin = StringToPoint2D(paramDic["axis_origin"].Value); PositiveDirection positiveDirection = PositiveDirection.RightDown; Enum.TryParse<PositiveDirection>(paramDic["axis_positive_direction"].Value, out positiveDirection); parameter.PositiveDirection = positiveDirection; parameter.Resolutions = StringToDoubleArray(paramDic["resolutions"].Value).OrderByDescending(c=>c).ToArray(); parameter.Scales = StringToDoubleArray(paramDic["scales"].Value).OrderBy(c=>c).ToArray(); int height = 0; int.TryParse(paramDic["tile_height"].Value, out height); parameter.TileHeight = height; int width = 0; int.TryParse(paramDic["tile_width"].Value, out width); parameter.TileHeight = width; parameter.Version = paramDic["version"].Value; int wkid = 0; int.TryParse(paramDic["crs_wkid"].Value, out wkid); parameter.WKID = wkid; parameter.WKT = paramDic["crs_wkt"].Value; } catch (Exception ex) { } return parameter; }