• RadMap地图缓存TileCache组织方式


    使用RadMap实现GIS效果中调用地图缓存,缓存都是PNG格式保存在文件夹中,以Y_X.png格式存放

    需要继承抽象类 TiledMapSource 并重写GetTile方法

    View Code
     1  public class TiledMapSource : MultiScaleTileSource, IMapSource
    2 {
    3 public static readonly DependencyProperty OpacityProperty;
    4
    5 protected TiledMapSource(int minZoomLevel, int maxZoomLevel, int tileWidth, int tileHeight);
    6
    7 public CultureInfo Culture { get; set; }
    8 protected int MaxZoomLevel { get; }
    9 protected int MinZoomLevel { get; }
    10 public double Opacity { get; set; }
    11 public string UniqueId { get; protected set; }
    12
    13 public event EventHandler IntializeCompleted;
    14
    15 protected virtual int ConvertTileToZoomLevel(int tileLevelDetail);
    16 protected virtual int ConvertZoomToTileLevel(int zoomLevel);
    17 protected virtual Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY);
    18 protected override void GetTileLayers(int tileLevel, int tilePositionX, int tilePositionY, IList<object> tileImageLayerSources);
    19 public virtual void Initialize();
    20 protected void InvalidateNullTiles();
    21 public virtual bool IsLevelSupported(int level);
    22 protected virtual bool IsValidTileLevel(int tileLevel);
    23 protected void RaiseIntializeCompleted();
    24 }

    重写方法:

                调用地址:TileMapnikUrlFormat = @"http://localhost/map/{zoom}/{y}_{x}.png";

    View Code
     1 /// <summary>
    2 /// Gets the image URI.
    3 /// </summary>
    4 /// <param name="tileLevel">Tile level.</param>
    5 /// <param name="tilePositionX">Tile X.</param>
    6 /// <param name="tilePositionY">Tile Y.</param>
    7 /// <returns>URI of image.</returns>
    8 protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
    9 {
    10 int zoomLevel = ConvertTileToZoomLevel(tileLevel);
    11
    12 string url = string.Empty;
    13   
    14 url = TileMapnikUrlFormat;
    15 url = ProtocolHelper.SetScheme(url);
    16 url = url.Replace("{zoom}", (zoomLevel).ToString(CultureInfo.InvariantCulture));
    17 url = url.Replace("{x}", (tilePositionX + 1).ToString(CultureInfo.InvariantCulture));
    18 url = url.Replace("{y}", (tilePositionY + 1).ToString(CultureInfo.InvariantCulture));
    19
    20 return new Uri(url);
    21 }

  • 相关阅读:
    Teamplate Workflow Architecture(Teamplate工作流架构)
    Las Vegas拉斯维加斯(赌城)游记
    初步尝试Teamplate Workflow Web Part for SharePoint Portal Server
    灵活管理Remote Objects生存期(lifetime)
    Wincv.exe类查看器工具(Class Viewer)
    重构(Refactoring)技巧读书笔记 之二
    重构(Refactoring)技巧读书笔记 之一
    尝试RemotingSqlHelper的若干问题
    关于ADO.Net连接池(Connection Pool)的一些个人见解
    SQL Server 最佳实践分析器使用小结
  • 原文地址:https://www.cnblogs.com/MR520/p/2134509.html
Copyright © 2020-2023  润新知