zoukankan      html  css  js  c++  java
  • [World Wind学习]21.影像切割

    本来希望从GlobeMapper中生成切片直接加载到WorldWind中,但是没有成功!所以想比较一下和dstile生成的瓦片到底有什么区别?

    所以这才第一次生成并加载了影像瓦片。貌似和GlobeMapper中的区别是路径的命名方式不一样!GlobeMapper是xx_xx.jpg,文件夹也都是两位。而dstile或者说WW需要的是4位,即xxxx_xxxx.jpg。

    ——2013.10.24-------------------------------------

    今天又测试了一下,证明了GlobeMapper中制作的切片确实可以在WorldWind中显示。

    跟踪代码QuadTile类Initialize()中Texture newTexture = QuadTileSet.ImageStores[i].LoadFile(this);

    调用了WorldWind.ImageStore类中的Texture LoadFile(QuadTile qt)方法,内部string filePath = GetLocalPath(qt);

    调用public virtual string GetLocalPath(QuadTile qt)。

     1 public virtual string GetLocalPath(QuadTile qt)
     2         {
     3             if(qt.Level >= m_levelCount)
     4                 throw new ArgumentException(string.Format("Level {0} not available.", 
     5                     qt.Level));
     6 
     7             string relativePath = String.Format(@"{0}{1:D4}{1:D4}_{2:D4}.{3}",
     8                 qt.Level, qt.Row, qt.Col, m_imageFileExtension);
     9             //string relativePath = String.Format(@"{0}{1}{1}_{2}.{3}",
    10             //    qt.Level, qt.Row, qt.Col, m_imageFileExtension);
    11             //string relativePath = String.Format(@"{0}{1}{1}_{2}.{3}",
    12             //    3, 25, 53, m_imageFileExtension);
    13             if(m_dataDirectory != null)
    14             {
    15                 // Search data directory first
    16                 string rawFullPath = Path.Combine( m_dataDirectory, relativePath );
    17                 if(File.Exists(rawFullPath))
    18                     return rawFullPath;
    19             }
    20 
    21             // If cache doesn't exist, fall back to duplicate texture path.
    22             if (m_cacheDirectory == null)
    23                 return m_duplicateTexturePath;
    24     
    25             // Try cache with default file extension
    26             string cacheFullPath = Path.Combine( m_cacheDirectory, relativePath );
    27             if(File.Exists(cacheFullPath))
    28                 return cacheFullPath;
    29 
    30             // Try cache but accept any valid image file extension
    31             const string ValidExtensions = ".bmp.dds.dib.hdr.jpg.jpeg.pfm.png.ppm.tga.gif.tif";
    32             
    33             string cacheSearchPath = Path.GetDirectoryName(cacheFullPath);
    34             if(Directory.Exists(cacheSearchPath))
    35             {
    36                 foreach( string imageFile in Directory.GetFiles(
    37                     cacheSearchPath, 
    38                     Path.GetFileNameWithoutExtension(cacheFullPath) + ".*") )
    39                 {
    40                     string extension = Path.GetExtension(imageFile).ToLower();
    41                     if(ValidExtensions.IndexOf(extension)<0)
    42                         continue;
    43 
    44                     return imageFile;
    45                 }
    46             }
    47 
    48             return cacheFullPath;
    49         }
    View Code

    可以看到相对路径的组织方式, 

    string relativePath = String.Format(@"{0}{1:D4}{1:D4}_{2:D4}.{3}",qt.Level, qt.Row, qt.Col, m_imageFileExtension);

    于是我干脆写死路径,出现如下结果。

    GlobeMapper和dstile生成的瓦片并无本质区别,只是路径,或者说文件的命名方式有差别。只要能正确组织数据就可以加载。

    GlobeMapper默认生成的xml文件估计是用于服务器端发布的吧。我还是从新写的影像的配置文件,和dstile一样。

  • 相关阅读:
    Swift流程控制之循环语句和判断语句详解
    框架内的文件集合
    十分钟让你明白Objective-C的语法(和Java、C++的对比)
    Swift版音乐播放器(简化版),swift音乐播放器
    通过数字电视通过宽带网络取代互联网电视机顶盒应用
    JS学习笔记-OO创建怀疑的对象
    如果不能显示真正的考验个别车型toast问题解决
    swift 它们的定义TabBarItem
    NSUserDefaults API简单的介绍和使用英文文件
    FZU 1686 龙之谜 重复覆盖
  • 原文地址:https://www.cnblogs.com/yhlx125/p/3385015.html
Copyright © 2011-2022 走看看