private static TileSchema CreateSchema(TileMap tileMap) { var schema = new TileSchema(); schema.OriginX = double.Parse(tileMap.Origin.x, CultureInfo.InvariantCulture); schema.OriginY = double.Parse(tileMap.Origin.y, CultureInfo.InvariantCulture); schema.Srs = tileMap.SRS; var tileWidth = int.Parse(tileMap.TileFormat.width); var tileHeight = int.Parse(tileMap.TileFormat.height); schema.Name = tileMap.Title; schema.Format = tileMap.TileFormat.extension; schema.YAxis = YAxis.TMS; schema.Extent = new Extent( double.Parse(tileMap.BoundingBox.minx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.miny, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxy, CultureInfo.InvariantCulture)); foreach (var tileSet in tileMap.TileSets.TileSet) { double unitsPerPixel = double.Parse(tileSet.unitsperpixel, CultureInfo.InvariantCulture); schema.Resolutions[tileSet.order] = new Resolution ( tileSet.order, unitsPerPixel, tileWidth, tileHeight ); } return(schema); }
private void InitializeTransform(TileSchema schema) { map.Transform.Center = new Point(16384d, -16384d); map.Transform.Resolution = schema.Resolutions.Last(); schema.Resolutions.Add(2); schema.Resolutions.Add(1); }
private ITileSchema CreateTileSchema() { var schema = new TileSchema { Name = "OpenStreetMap", OriginX = -20037508.342789, OriginY = 20037508.342789, YAxis = YAxis.OSM, Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789), Format = "png", Srs = "EPSG:900913" }; var i = 0; foreach (var unitsPerPixel in _unitsPerPixelArray) { var levelId = i++.ToString(CultureInfo.InvariantCulture); schema.Resolutions[levelId] = new Resolution ( levelId, unitsPerPixel, TileSize, TileSize ); } return schema; }
/// <summary> /// Generate BruTile TileSchema based on ArcGIS Capabilities /// </summary> /// <returns>TileSchema, returns null if service is not tiled</returns> public static ITileSchema GetTileSchema(Capabilities capabilities) { //TODO: Does this belong in Mapsui.Providers? if (capabilities.tileInfo == null) { return(null); } var schema = new TileSchema(); var count = 0; foreach (var lod in capabilities.tileInfo.lods) { schema.Resolutions.Add(new Resolution { Id = count.ToString(), UnitsPerPixel = lod.resolution }); count++; } schema.Height = capabilities.tileInfo.cols; schema.Width = capabilities.tileInfo.rows; schema.Extent = new BruTile.Extent(capabilities.fullExtent.xmin, capabilities.fullExtent.ymin, capabilities.fullExtent.xmax, capabilities.fullExtent.ymax); schema.OriginX = capabilities.tileInfo.origin.x; schema.OriginY = capabilities.tileInfo.origin.y; schema.Name = "ESRI"; schema.Format = capabilities.tileInfo.format; schema.Axis = AxisDirection.InvertedY; schema.Srs = string.Format("EPSG:{0}", capabilities.tileInfo.spatialReference.wkid); return(schema); }
public IList <TileInfo> GetTilesWanted(TileSchema schema, Extent extent, int level) { IList <TileInfo> infos = new List <TileInfo>(); int step = 1; // Iterating through all levels from current to zero. If lower levels are // not availeble the renderer can fall back on higher level tiles. while (level >= 0) { IList <TileInfo> infosOfLevel = schema.GetTilesInView(extent, level); infosOfLevel = PrioritizeTiles(infosOfLevel, extent.CenterX, extent.CenterY, sorter); foreach (TileInfo info in infosOfLevel) { if ((info.Index.Row >= 0) && (info.Index.Col >= 0)) { infos.Add(info); } } level = level - step; step++; } return(infos); }
private ITileSchema CreateTileSchema() { var schema = new TileSchema { Name = "OpenStreetMap", OriginX = -20037508.342789, OriginY = 20037508.342789, YAxis = YAxis.OSM, Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789), Format = "png", Srs = "EPSG:900913" }; var i = 0; foreach (var unitsPerPixel in _unitsPerPixelArray) { var levelId = i++.ToString(CultureInfo.InvariantCulture); schema.Resolutions[levelId] = new Resolution ( levelId, unitsPerPixel ); } return(schema); }
public static WmsTileSource Create(WmsInfo info) { var schema = new TileSchema { Format = "image/png", Srs = info.CRS, Height = 256, Width = 256, }; var onlineResource = info.WmsCapabilities.Capability.Request.GetCapabilities.DCPType[0].Http.Get.OnlineResource.Href; return(new WmsTileSource(new WebTileProvider(new WmsRequest(new Uri(onlineResource), schema, new List <string> { info.Layer.Name }, info.Style == null? null : new List <string> { info.Style }, info.CustomParameters, info.WmsCapabilities.Version.VersionString), fetchTile: d => RequestHelper.FetchImage(d, info.Credentials) ), schema)); }
/// <summary> /// Creates a new WmsTileSource /// </summary> /// <param name="info">WmsInfo with the data needed for creation.</param> /// <returns>The created WmsTileSource</returns> public static WmsTileSource Create(WmsInfo info) { var schema = new TileSchema { Format = "image/png", Srs = info.Crs, }; const int tileWidth = 256; const int tileHeight = 256; var request = new WmsRequest( new Uri(info.WmsCapabilities.Capability.Request.GetMap.DCPType[0].Http.Get.OnlineResource.Href), schema, tileWidth, tileHeight, new List <string> { info.Layer.Name }, info.Style == null ? null : new List <string> { info.Style }, info.CustomParameters, info.WmsCapabilities.Version.VersionString); return(new WmsTileSource(new HttpTileProvider(request, fetchTile: d => RequestHelper.FetchImage(d, info.Credentials)), schema)); }
private static TileSchema CreateSchema(TileMap tileMap) { var schema = new TileSchema(); schema.OriginX = double.Parse(tileMap.Origin.x, CultureInfo.InvariantCulture); schema.OriginY = double.Parse(tileMap.Origin.y, CultureInfo.InvariantCulture); schema.Srs = tileMap.SRS; schema.Width = int.Parse(tileMap.TileFormat.width); schema.Height = int.Parse(tileMap.TileFormat.height); schema.Name = tileMap.Title; schema.Format = tileMap.TileFormat.extension; schema.Axis = AxisDirection.Normal; schema.Extent = new Extent( double.Parse(tileMap.BoundingBox.minx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.miny, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxy, CultureInfo.InvariantCulture)); var count = 0; foreach (var tileSet in tileMap.TileSets.TileSet) { double resolution = double.Parse(tileSet.unitsperpixel, CultureInfo.InvariantCulture); schema.Resolutions[count] = new Resolution { Id = tileSet.order, UnitsPerPixel = resolution }; count++; } return(schema); }
private ITileSchema CreateTileSchema() { var resolutions = new[] { 156543.033900000, 78271.516950000, 39135.758475000, 19567.879237500, 9783.939618750, 4891.969809375, 2445.984904688, 1222.992452344, 611.496226172, 305.748113086, 152.874056543, 76.437028271, 38.218514136, 19.109257068, 9.554628534, 4.777314267, 2.388657133, 1.194328567, 0.597164283 }; var tileSchema = new TileSchema { Name = "OpenStreetMap" }; foreach (float resolution in resolutions) { tileSchema.Resolutions.Add(resolution); } tileSchema.OriginX = -20037508.342789; tileSchema.OriginY = 20037508.342789; tileSchema.Axis = AxisDirection.InvertedY; tileSchema.Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789); tileSchema.Height = 256; tileSchema.Width = 256; tileSchema.Format = "png"; tileSchema.Srs = "EPSG:900913"; return(tileSchema); }
private static TileSchema CreateSchema(TileMap tileMap) { var schema = new TileSchema(); schema.OriginX = double.Parse(tileMap.Origin.x, CultureInfo.InvariantCulture); schema.OriginY = double.Parse(tileMap.Origin.y, CultureInfo.InvariantCulture); schema.Srs = tileMap.SRS; schema.Width = int.Parse(tileMap.TileFormat.width); schema.Height = int.Parse(tileMap.TileFormat.height); schema.Name = tileMap.Title; schema.Format = tileMap.TileFormat.extension; schema.Axis = AxisDirection.Normal; schema.Extent = new Extent( double.Parse(tileMap.BoundingBox.minx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.miny, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxy, CultureInfo.InvariantCulture)); var count = 0; foreach (var tileSet in tileMap.TileSets.TileSet) { double resolution = double.Parse(tileSet.unitsperpixel, CultureInfo.InvariantCulture); schema.Resolutions[count] = new Resolution { Id = tileSet.order, UnitsPerPixel = resolution }; count++; } return schema; }
/// <summary> /// Generate BruTile TileSchema based on ArcGIS Capabilities /// </summary> /// <returns>TileSchema, returns null if service is not tiled</returns> public static ITileSchema GetTileSchema(ArcGISDynamicCapabilities arcGisDynamicCapabilities) { //TODO: Does this belong in Mapsui.Providers? if (arcGisDynamicCapabilities.tileInfo == null) { return(null); } var schema = new TileSchema(); var count = 0; foreach (var lod in arcGisDynamicCapabilities.tileInfo.lods) { var levelId = count.ToString(); schema.Resolutions[levelId] = new Resolution(levelId, lod.resolution, arcGisDynamicCapabilities.tileInfo.cols, arcGisDynamicCapabilities.tileInfo.rows); count++; } schema.Extent = new BruTile.Extent(arcGisDynamicCapabilities.fullExtent.xmin, arcGisDynamicCapabilities.fullExtent.ymin, arcGisDynamicCapabilities.fullExtent.xmax, arcGisDynamicCapabilities.fullExtent.ymax); schema.OriginX = arcGisDynamicCapabilities.tileInfo.origin.x; schema.OriginY = arcGisDynamicCapabilities.tileInfo.origin.y; schema.Name = "ESRI"; schema.Format = arcGisDynamicCapabilities.tileInfo.format; schema.YAxis = YAxis.OSM; schema.Srs = $"EPSG:{arcGisDynamicCapabilities.tileInfo.spatialReference.wkid}"; return(schema); }
private void DrawRecursive(Canvas canvas, TileSchema schema, ITransform transform, MemoryCache <MemoryStream> memoryCache, Extent extent, int level) { IList <TileInfo> tiles = schema.GetTilesInView(extent, level); foreach (TileInfo tile in tiles) { MemoryStream image = memoryCache.Find(tile.Index); if (image == null) { if (level > 0) { DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1); } } else { Rect dest = MapTransformHelper.WorldToMap(tile.Extent, transform); double opacity = DrawImage(canvas, image, dest, tile); if ((opacity < 1) && (level > 0)) { DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1); } } } }
public void Render(Canvas canvas, TileSchema schema, ITransform transform, MemoryCache <MemoryStream> cache, List <Marker> markerCache) { CollapseAll(canvas); int level = BruTile.Utilities.GetNearestLevel(schema.Resolutions, transform.Resolution); DrawRecursive(canvas, schema, transform, cache, transform.Extent, level); DrawMarkers(canvas, schema, transform, markerCache, transform.Extent, level); RemoveCollapsed(canvas); }
internal static T Reflect <T>(TileSchema schema, string field) { var fi = typeof(TileSchema).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); if (fi == null) { throw new ArgumentException("TileSchema does not have a private field '" + field + "'", "field"); } return((T)fi.GetValue(schema)); }
public MGLBackgroundTileSource() { var schema = new TileSchema(); schema.Extent = new Extent(-20037508, -34662080, 20037508, 34662080); Schema = schema; for (var i = 0; i <= 30; i++) { Schema.Resolutions.Add(i.ToString(), new BruTile.Resolution(i.ToString(), i.ToResolution())); } }
public Task <BackgroundLayerSet> GetKWater() { var baseUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer"; var schema = new TileSchema { OriginX = -5423200, OriginY = 6294600, Format = "image/jpgpng", YAxis = YAxis.OSM, Srs = "EPSG:5181", Extent = new Extent(-956717.4541277827, -341633.6944546023, 1690051.884713592, 1587544.6432406649) }; schema.Resolutions["0"] = new Resolution(id: "0", unitsPerPixel: 926.0435187537042, scaledenominator: 3500000); schema.Resolutions["1"] = new Resolution(id: "1", unitsPerPixel: 529.1677250021168, scaledenominator: 2000000); schema.Resolutions["2"] = new Resolution(id: "2", unitsPerPixel: 264.5838625010584, scaledenominator: 1000000); schema.Resolutions["3"] = new Resolution(id: "3", unitsPerPixel: 132.2919312505292, scaledenominator: 500000); schema.Resolutions["4"] = new Resolution(id: "4", unitsPerPixel: 66.1459656252646, scaledenominator: 250000); schema.Resolutions["5"] = new Resolution(id: "5", unitsPerPixel: 33.0729828126323, scaledenominator: 125000); schema.Resolutions["6"] = new Resolution(id: "6", unitsPerPixel: 16.933367200067735, scaledenominator: 64000); schema.Resolutions["7"] = new Resolution(id: "7", unitsPerPixel: 8.466683600033868, scaledenominator: 32000); schema.Resolutions["8"] = new Resolution(id: "8", unitsPerPixel: 4.233341800016934, scaledenominator: 16000); schema.Resolutions["9"] = new Resolution(id: "9", unitsPerPixel: 2.116670900008467, scaledenominator: 8000); schema.Resolutions["10"] = new Resolution(id: "10", unitsPerPixel: 1.0583354500042335, scaledenominator: 4000); schema.Resolutions["11"] = new Resolution(id: "11", unitsPerPixel: 0.5291677250021167, scaledenominator: 2000); schema.Resolutions["12"] = new Resolution(id: "12", unitsPerPixel: 0.26458386250105836, scaledenominator: 1000); schema.Resolutions["13"] = new Resolution(id: "13", unitsPerPixel: 0.13229193125052918, scaledenominator: 500); schema.Resolutions["14"] = new Resolution(id: "14", unitsPerPixel: 0.06614596562526459, scaledenominator: 250); schema.Resolutions["15"] = new Resolution(id: "15", unitsPerPixel: 0.033072982812632296, scaledenominator: 125); schema.Resolutions["16"] = new Resolution(id: "16", unitsPerPixel: 0.016668783337566676, scaledenominator: 63); schema.Resolutions["17"] = new Resolution(id: "17", unitsPerPixel: 0.008466683600033867, scaledenominator: 32); schema.Resolutions["18"] = new Resolution(id: "18", unitsPerPixel: 0.004233341800016934, scaledenominator: 16); schema.Resolutions["19"] = new Resolution(id: "19", unitsPerPixel: 0.002116670900008467, scaledenominator: 8); schema.Resolutions["20"] = new Resolution(id: "20", unitsPerPixel: 0.0010583354500042334, scaledenominator: 4); schema.Resolutions["21"] = new Resolution(id: "21", unitsPerPixel: 0.000529167725002116, scaledenominator: 2); var request = new BasicRequest($"{baseUrl}/tile/{"{0}/{2}/{1}"}"); var provider = new HttpTileProvider(request, null, null); var tileSource = new TileSource(provider, schema); //var set = new BackgroundLayerSet(new [] { new BackgroundLayer(tileSource, "일반", order: 0) }); var set = new BackgroundLayerSet(new[] { new BackgroundLayer(tileSource, null) { LegendText = "일반" } }) { "없음", { "일반", "일반" } }; return(Task.FromResult(set)); }
public static ITileSchema GetSchema() { var resolutions = new[] { 156543.033928, 78271.5169639999, 39135.7584820001, 19567.8792409999, 9783.93962049996, 4891.96981024998, 2445.98490512499, 1222.99245256249, 611.49622628138, 305.748113140558, 152.874056570411, 76.4370282850732, 38.2185141425366, 19.1092570712683, 9.55462853563415, 4.77731426794937, 2.38865713397468, 1.19432856685505, 0.597164283559817, 0.298582141647617 }; var schema = new TileSchema(); var counter = 0; foreach (var resolution in resolutions) { schema.Resolutions.Add(new Resolution { UnitsPerPixel = resolution, Id = counter++.ToString(CultureInfo.InvariantCulture) }); } schema.Height = 256; schema.Width = 256; schema.Extent = new Extent(-20037507.2295943, -19971868.8804086, 20037507.2295943, 19971868.8804086); schema.OriginX = -20037508.342787; schema.OriginY = 20037508.342787; schema.Name = "ESRI"; schema.Format = "JPEG"; schema.Axis = AxisDirection.InvertedY; schema.Srs = string.Format("EPSG:{0}", 102100); return(schema); }
public void Render(DateTimeOffset time, Canvas canvas, Canvas canvas2, TileSchema schema, ITransform transform, MemoryCache <MemoryStream> cache, List <Ellipse> ellipseCache, List <Marker> markerCache, List <Marker> eventCache) { CollapseAll(canvas); CollapseAll(canvas2); int level = BruTile.Utilities.GetNearestLevel(schema.Resolutions, transform.Resolution); DrawRecursive(canvas, schema, transform, cache, transform.Extent, level); // DrawMarkers(canvas, schema, transform, markerCache, transform.Extent, level); DrawLines(canvas, schema, transform, markerCache, transform.Extent, time, level); // DrawCircle(canvas, schema, transform, ellipseCache, transform.Extent, level); DrawEvents(canvas2, schema, transform, eventCache, transform.Extent, time, level); RemoveCollapsed(canvas); RemoveCollapsed(canvas2); }
public Task <BackgroundLayerSet> GetKWaterMapLayers() { var baseUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer"; //var capabilitiesUrl = "http://kommap.kwater.or.kr/arcgis/rest/services/public/BaseMap_2018/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"; //var svrSource = await GetTileSourcesFromCapabilities(new Uri(capabilitiesUrl)); //var svrSchema = svrSource.FirstOrDefault().Schema; var schema = new TileSchema(); schema.OriginX = -5423200; schema.OriginY = 6294600; schema.Format = "image/jpgpng"; schema.YAxis = YAxis.OSM; schema.Srs = "EPSG:5181"; schema.Extent = new Extent(-956717.4541277827, -341633.6944546023, 1690051.884713592, 1587544.6432406649); //foreach (var r in svrSchema.Resolutions) // schema.Resolutions[r.Key] = r.Value; schema.Resolutions["0"] = new Resolution(id: "0", unitsPerPixel: 926.0435187537042, scaledenominator: 3500000); schema.Resolutions["1"] = new Resolution(id: "1", unitsPerPixel: 529.1677250021168, scaledenominator: 2000000); schema.Resolutions["2"] = new Resolution(id: "2", unitsPerPixel: 264.5838625010584, scaledenominator: 1000000); schema.Resolutions["3"] = new Resolution(id: "3", unitsPerPixel: 132.2919312505292, scaledenominator: 500000); schema.Resolutions["4"] = new Resolution(id: "4", unitsPerPixel: 66.1459656252646, scaledenominator: 250000); schema.Resolutions["5"] = new Resolution(id: "5", unitsPerPixel: 33.0729828126323, scaledenominator: 125000); schema.Resolutions["6"] = new Resolution(id: "6", unitsPerPixel: 16.933367200067735, scaledenominator: 64000); schema.Resolutions["7"] = new Resolution(id: "7", unitsPerPixel: 8.466683600033868, scaledenominator: 32000); schema.Resolutions["8"] = new Resolution(id: "8", unitsPerPixel: 4.233341800016934, scaledenominator: 16000); schema.Resolutions["9"] = new Resolution(id: "9", unitsPerPixel: 2.116670900008467, scaledenominator: 8000); schema.Resolutions["10"] = new Resolution(id: "10", unitsPerPixel: 1.0583354500042335, scaledenominator: 4000); schema.Resolutions["11"] = new Resolution(id: "11", unitsPerPixel: 0.5291677250021167, scaledenominator: 2000); schema.Resolutions["12"] = new Resolution(id: "12", unitsPerPixel: 0.26458386250105836, scaledenominator: 1000); schema.Resolutions["13"] = new Resolution(id: "13", unitsPerPixel: 0.13229193125052918, scaledenominator: 500); schema.Resolutions["14"] = new Resolution(id: "14", unitsPerPixel: 0.06614596562526459, scaledenominator: 250); schema.Resolutions["15"] = new Resolution(id: "15", unitsPerPixel: 0.033072982812632296, scaledenominator: 125); schema.Resolutions["16"] = new Resolution(id: "16", unitsPerPixel: 0.016668783337566676, scaledenominator: 63); schema.Resolutions["17"] = new Resolution(id: "17", unitsPerPixel: 0.008466683600033867, scaledenominator: 32); schema.Resolutions["18"] = new Resolution(id: "18", unitsPerPixel: 0.004233341800016934, scaledenominator: 16); schema.Resolutions["19"] = new Resolution(id: "19", unitsPerPixel: 0.002116670900008467, scaledenominator: 8); schema.Resolutions["20"] = new Resolution(id: "20", unitsPerPixel: 0.0010583354500042334, scaledenominator: 4); schema.Resolutions["21"] = new Resolution(id: "21", unitsPerPixel: 0.000529167725002116, scaledenominator: 2); var request = new BasicRequest($"{baseUrl}/tile/{"{0}/{2}/{1}"}"); var provider = new HttpTileProvider(request, null, null); var tileSource = new TileSource(provider, schema); var set = new BackgroundLayerSet(new [] { new BackgroundLayer(tileSource, "일반", order: 0) }); set.Add("없음"); set.Add("일반", "일반"); return(Task.FromResult(set)); }
private void SetResolution(TileSchema schema, int firstLevel, bool isReversed, IEnumerable <double> resolutions) { var level = firstLevel; var rs = isReversed ? resolutions.Reverse().ToArray() : resolutions.ToArray(); foreach (var resolution in rs) { var key = level.ToString(); schema.Resolutions[key] = new Resolution(id: key, unitsPerPixel: resolution); level++; } }
/// <summary> /// Initializes a new instance of the <see cref="WmsRequest"/> class. /// </summary> /// <param name="baseUrl">The base url.</param> /// <param name="schema">The tile schema.</param> /// <param name="tileWidth">The width of the requested tiles.</param> /// <param name="tileHeight">The height of the requested tiles.</param> /// <param name="layers">The layers.</param> /// <param name="styles">The styles.</param> /// <param name="customParameters">The custom parameters.</param> /// <param name="version">The version.</param> public WmsRequest(Uri baseUrl, TileSchema schema, int tileWidth, int tileHeight, IEnumerable <string> layers, IEnumerable <string> styles, IDictionary <string, string> customParameters, string version) { // Prepare url string var au = baseUrl.AbsoluteUri; if (!au.Contains("SERVICE=WMS", StringComparison.OrdinalIgnoreCase)) { if (au.EndsWith("?") || au.EndsWith("&")) { au += "SERVICE=WMS"; } else if (au.Contains('?')) { au += "&SERVICE=WMS"; } else { au += "?SERVICE=WMS"; } } var url = new StringBuilder(au); if (!string.IsNullOrEmpty(version)) { url.AppendFormat("&VERSION={0}", version); } url.Append("&REQUEST=GetMap"); url.AppendFormat("&FORMAT={0}", schema.Format); var crsFormat = !string.IsNullOrEmpty(version) && string.CompareOrdinal(version, "1.3.0") >= 0 ? "&CRS={0}" : "&SRS={0}"; url.AppendFormat(crsFormat, schema.Srs); url.AppendFormat("&LAYERS={0}", ToCommaSeparatedValues(layers)); url.AppendFormat("&STYLES={0}", ToCommaSeparatedValues(styles)); url.AppendFormat("&WIDTH={0}", tileWidth); url.AppendFormat("&HEIGHT={0}", tileHeight); if (customParameters != null) { foreach (var name in customParameters.Keys) { url.AppendFormat("&{0}={1}", name, customParameters[name]); } } _fixedUrl = url.ToString(); }
private static ITileSchema CreateSchema() { var resoltions = new[] { 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 0.0006866455078125, 0.00034332275390625, 0.000171661376953125, 0.0000858306884765629, 0.0000429153442382814, 0.0000214576721191407, 0.0000107288360595703 }; const string format = "jpeg"; var schema = new TileSchema(); var count = 0; foreach (double resolution in resoltions) { var levelId = count.ToString(); schema.Resolutions[levelId] = new Resolution { Id = levelId, UnitsPerPixel = resolution }; count++; } schema.Height = 512; schema.Width = 512; schema.Extent = new Extent(-180, -90, 180, 90); schema.OriginX = -180; schema.OriginY = 90; schema.Name = "ESRI"; schema.Format = format; schema.Axis = AxisDirection.InvertedY; schema.Srs = "EPSG:4326"; return(schema); }
private void DrawCircle(Canvas canvas, TileSchema schema, ITransform transform, List <BruTile.UI.Ellipse> cache, Extent extent, int level) { foreach (var ellipse in cache) { double xt = ellipse.X; double yt = ellipse.Y; double radiust = transform.RadiusToMap(ellipse.Radius); Circle circle = new Circle() { Width = radiust, Height = radiust, StrokeThickness = 2, }; if (ellipse.Type == Ellipse.ZoneType.Red_Zone) { circle.Stroke = Brushes.Red; // circle.Fill = Brushes.Red; } else { // circle.Fill = Brushes.Blue; circle.Stroke = Brushes.Blue; } if (!canvas.Children.Contains(circle)) { canvas.Children.Add(circle); } Rect dest = MapTransformHelper.WorldToMap(extent, transform); Point p = transform.WorldToMap(xt, yt); if (dest.Contains(p)) { Canvas.SetZIndex(circle, 200); Canvas.SetLeft(circle, p.X); Canvas.SetTop(circle, p.Y); } } }
private TileSchema GetKakaomapSchema() { var schema = new TileSchema(); schema.OriginX = -30000; schema.OriginY = -60000; schema.Name = "KakaoMap"; schema.Format = "png"; schema.YAxis = YAxis.TMS; schema.Srs = "EPSG:5181"; var minX = -219825.99; var minY = -535028.96; var maxX = 819486.07; var maxY = 777525.22; schema.Extent = new Extent(minX, minY, maxX, maxY); var resolutions = new[] { 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25 }; SetResolution(schema, firstLevel: 1, isReversed: true, resolutions: resolutions); return(schema); }
private static TileSchema GetKakaomapSchema() { var schema = new TileSchema { OriginX = -30000, OriginY = -60000, Name = "KakaoMap", Format = "png", YAxis = YAxis.TMS, Srs = "EPSG:5181" }; var minX = -605706; var maxX = 1202287; var minY = -37859; var maxY = 1160527; schema.Extent = new Extent(minX, minY, maxX, maxY); var resolutions = new[] { 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25 }; SetResolution(schema, firstLevel: 1, isReversed: true, resolutions: resolutions); return(schema); }
public void TileTransformWithDifferentTileWidthAndHeight() { // arrange var tileWidth = 10; var tileHeight = 5; // Note, tile tileHeight is half the tileWidth var expectedColCount = 10; var expectedRowCount = 20; // Because tileHeight is half the tileHeight there is a double number of rows var schema = new TileSchema { Extent = new Extent(0, 0, 100, 100), OriginX = 0, OriginY = 0 }; schema.Resolutions.Add(0, new Resolution(0, 1, tileWidth, tileHeight, 0, 0, 10, 10, 1)); var requestedExtent = new Extent(0, 0, 100, 100); // act var range = TileTransform.WorldToTile(requestedExtent, 0, schema); // assert Assert.AreEqual(expectedColCount, range.ColCount, "ColCount"); Assert.AreEqual(expectedRowCount, range.RowCount, "RowCount"); }
private ITileSchema CreateTileSchema() { var schema = new TileSchema(); schema.Name = "OpenStreetMap"; int i = 0; foreach (var resolution in resolutions) { schema.Resolutions.Add(new Resolution { UnitsPerPixel = resolution, Id = i++.ToString() }); } schema.OriginX = -20037508.342789; schema.OriginY = 20037508.342789; schema.Axis = AxisDirection.InvertedY; schema.Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789); schema.Height = 256; schema.Width = 256; schema.Format = "png"; schema.Srs = "EPSG:900913"; return(schema); }
private void BuildEdges() { /* * ^----> | | | | | | | <----v */ Edges = new List <string>(); Edges.Add(new string(TileSchema.First().ToArray())); //Top Edges.Add(new string(TileSchema.Select(row => row.Last()).ToArray())); //Right Edges.Add(new string(TileSchema.Last().Reverse <char>().ToArray())); //Bottom Edges.Add(new string(TileSchema.Select(row => row.First()).Reverse <char>().ToArray())); //Left //Flip var flippedEdges = Edges.Select(s => new string(s.Reverse().ToArray())).ToList(); Edges.Add(flippedEdges[2]); // Former Bottom; now top Edges.Add(flippedEdges[1]); Edges.Add(flippedEdges[0]); // Former Top, now bottom Edges.Add(flippedEdges[3]); }
private ITileSchema RestoreSchema() { var schema = new TileSchema { YAxis = _axis, Extent = new Extent(_minX, _minY, _maxX, _maxY), Format = _format, /* * Height = _height, * Width = _width, */ Name = _schemaName, OriginX = _originX, OriginY = _originY, Srs = _srs }; foreach (var resolution in _resolutions) { schema.Resolutions.Add(resolution); } return(schema); }
private static TileSchema CreateSchema(TileMap tileMap) { var schema = new TileSchema(); schema.OriginX = Double.Parse(tileMap.Origin.x, CultureInfo.InvariantCulture); schema.OriginY = Double.Parse(tileMap.Origin.y, CultureInfo.InvariantCulture); schema.Srs = tileMap.SRS; schema.Width = Int32.Parse(tileMap.TileFormat.width); schema.Height = Int32.Parse(tileMap.TileFormat.height); schema.Name = tileMap.Title; schema.Format = tileMap.TileFormat.extension; schema.Axis = AxisDirection.Normal; schema.Extent = new Extent( Double.Parse(tileMap.BoundingBox.minx, CultureInfo.InvariantCulture), Double.Parse(tileMap.BoundingBox.miny, CultureInfo.InvariantCulture), Double.Parse(tileMap.BoundingBox.maxx, CultureInfo.InvariantCulture), Double.Parse(tileMap.BoundingBox.maxy, CultureInfo.InvariantCulture)); for (int i = 0; i < tileMap.TileSets.TileSet.Length; i++) { double resolution = Double.Parse(tileMap.TileSets.TileSet[i].unitsperpixel, CultureInfo.InvariantCulture); schema.Resolutions.Add(resolution); } return(schema); }
public void DrawLines(Canvas canvas, TileSchema schema, ITransform transform, List <Marker> cachemarker, Extent extent, DateTimeOffset time, int level) { cachemarker.Sort(delegate(Marker p1, Marker p2) { return(p1.timeOffset.CompareTo(p2.timeOffset)); }); for (int i = 0; i < cachemarker.Count - 1; i++) { if (cachemarker.Count == 0 || cachemarker[i].timeOffset > time || (!MapControl.warmuplog && cachemarker[i].ElapsedTime <= 0)) { continue; } Point p = transform.WorldToMap(cachemarker[i].X, cachemarker[i].Y); Point p2 = transform.WorldToMap(cachemarker[i + 1].X, cachemarker[i + 1].Y); var line = new System.Windows.Shapes.Line(); //if (cachemarker[i].Type == "Vehicle leave") // line.Stroke = Brushes.Blue; //else line.Stroke = System.Windows.Media.Brushes.Red; line.X1 = p.X; line.X2 = p2.X; line.Y1 = p.Y; line.Y2 = p2.Y; line.StrokeThickness = 2; line.Visibility = Visibility.Collapsed; if (!canvas.Children.Contains(line)) { canvas.Children.Add(line); } Rect dest = MapTransformHelper.WorldToMap(extent, transform); //if (dest.Contains(p) && dest.Contains(p2)) //{ Canvas.SetZIndex(line, 200); // } line.Visibility = Visibility.Visible; } }
private static TileSchema ToTileSchema(XElement xTileSet, string name) { var schema = new TileSchema { Name = name }; int width; int height; var xSrs = xTileSet.Element("SRS"); if (xSrs != null) schema.Srs = xSrs.Value; var xWidth = xTileSet.Element("Width"); if (xWidth == null) throw new System.Exception("'Width' field not found in xml"); if (!Int32.TryParse(xWidth.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out width)) throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'"); var xHeight = xTileSet.Element("Height"); if (xHeight == null) throw new System.Exception("'Height' field not found in xml"); if (!Int32.TryParse(xHeight.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out height)) throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'"); var xFormat = xTileSet.Element("Format"); if (xFormat != null) schema.Format = xFormat.Value; var xBoundingBox = xTileSet.Element("BoundingBox"); if (xBoundingBox != null) { double minx, miny, maxx, maxy; if ( !double.TryParse(xBoundingBox.Attribute("minx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) & !double.TryParse(xBoundingBox.Attribute("miny").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) & !double.TryParse(xBoundingBox.Attribute("maxx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) & !double.TryParse(xBoundingBox.Attribute("maxy").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy)) { throw new ArgumentException("Invalid LatLonBoundingBox on tileset '" + schema.Name + "'"); } schema.Extent = new Extent(minx, miny, maxx, maxy); //In WMS-C the origin is defined as the lower left corner of the boundingbox schema.OriginX = minx; schema.OriginY = miny; } var xResolutions = xTileSet.Element("Resolutions"); if (xResolutions != null) { var count = 0; string[] resolutions = xResolutions.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var resolution in resolutions) { double unitsPerPixel; if (!Double.TryParse(resolution, NumberStyles.Any, CultureInfo.InvariantCulture, out unitsPerPixel)) throw new ArgumentException("Invalid resolution on tileset '" + schema.Name + "'"); var levelId = count.ToString(CultureInfo.InvariantCulture); schema.Resolutions[levelId] = new Resolution ( levelId, unitsPerPixel, width, height); count++; } } return schema; }
private static ITileSource ParseTileSetNode(XElement xnlTileSet, OnlineResource onlineResource) { var schema = new TileSchema(); var xnStyles = xnlTileSet.Elements("Styles"); var styles = xnStyles.Select(xnStyle => xnStyle.Value).ToList(); var xnLayers = xnlTileSet.Elements("Layers"); var layers = xnLayers.Select(xnLayer => xnLayer.Value).ToList(); schema.Name = CreateDefaultName(layers); var xnSrs = xnlTileSet.Element("SRS"); if (xnSrs != null) schema.Srs = xnSrs.Value; var xnWidth = xnlTileSet.Element("Width"); if (xnWidth != null) { int width; if (!Int32.TryParse(xnWidth.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out width)) throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'"); schema.Width = width; } var xnHeight = xnlTileSet.Element("Height"); if (xnHeight != null) { int height; if (!Int32.TryParse(xnHeight.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out height)) throw new ArgumentException("Invalid width on tileset '" + schema.Name + "'"); schema.Height = height; } var xnFormat = xnlTileSet.Element("Format"); if (xnFormat != null) schema.Format = xnFormat.Value; var xnBoundingBox = xnlTileSet.Element("BoundingBox"); if (xnBoundingBox != null) { double minx, miny, maxx, maxy; if (!double.TryParse(xnBoundingBox.Attribute("minx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) & !double.TryParse(xnBoundingBox.Attribute("miny").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) & !double.TryParse(xnBoundingBox.Attribute("maxx").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) & !double.TryParse(xnBoundingBox.Attribute("maxy").Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy)) { throw new ArgumentException("Invalid LatLonBoundingBox on tileset '" + schema.Name + "'"); } schema.Extent = new Extent(minx, miny, maxx, maxy); //In WMS-C the origin is defined as the lower left corner of the boundingbox schema.OriginX = minx; schema.OriginY = miny; } var xnResolutions = xnlTileSet.Element("Resolutions"); if (xnResolutions != null) { var count = 0; string[] resolutions = xnResolutions.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var resolutionStr in resolutions) { double resolution; if (!Double.TryParse(resolutionStr, NumberStyles.Any, CultureInfo.InvariantCulture, out resolution)) throw new ArgumentException("Invalid resolution on tileset '" + schema.Name + "'"); schema.Resolutions[count] = new Resolution { Id = count.ToString(), UnitsPerPixel = resolution }; count++; } } return new WmscTileSource(schema, new WebTileProvider(new WmscRequest(new Uri(onlineResource.Href), schema, layers, styles, new Dictionary<string, string>()))); }
private static TileSchema CreateSchema(TileMap tileMap) { var schema = new TileSchema(); schema.OriginX = double.Parse(tileMap.Origin.x, CultureInfo.InvariantCulture); schema.OriginY = double.Parse(tileMap.Origin.y, CultureInfo.InvariantCulture); schema.Srs = tileMap.SRS; var tileWidth = int.Parse(tileMap.TileFormat.width); var tileHeight = int.Parse(tileMap.TileFormat.height); schema.Name = tileMap.Title; schema.Format = tileMap.TileFormat.extension; schema.YAxis = YAxis.TMS; schema.Extent = new Extent( double.Parse(tileMap.BoundingBox.minx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.miny, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxx, CultureInfo.InvariantCulture), double.Parse(tileMap.BoundingBox.maxy, CultureInfo.InvariantCulture)); foreach (var tileSet in tileMap.TileSets.TileSet) { double unitsPerPixel = double.Parse(tileSet.unitsperpixel, CultureInfo.InvariantCulture); schema.Resolutions[tileSet.order] = new Resolution ( tileSet.order, unitsPerPixel, tileWidth, tileHeight ); } return schema; }