[World Wind学习]21.影像切割

[World Wind学习]21.影像切割

[World Wind学习]21.影像切割

[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);

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

[World Wind学习]21.影像切割

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

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

你可能感兴趣的:(学习)