随笔 - 91  文章 - 11  评论 - 12 

原理:

1.在后台拼接处一个命令行

2.用stdlib中的system调用来执行这个命令行

主要是对OsgDem的几个参数做了一下封装,方便调用而已.代码如下:

#include "StdAfx.h"
#include "HowtoVPB.h"

HowtoVPB::HowtoVPB(void):scales(9),files(4),pageLevel(3)
{
    scales.assign(9,1.0F);
    files.assign(5,"");    
}

HowtoVPB::~HowtoVPB(void)
{
}
int HowtoVPB::run()
{
    stringstream  ss;
    ss<<"osgdem ";
    float scalex=getScale(HowtoVPB::TEXTURE,HowtoVPB::X);
    if(scalex!=0.0)
        ss<<" --xx "<<scalex;
    float scaley=getScale(HowtoVPB::TEXTURE,HowtoVPB::Y);
    if(scaley!=0.0)
        ss<<" --yy "<<scaley;
    string file=getFile(HowtoVPB::TEXTURE);
    if(file.length()>0)
        ss<<" -t "<<file;
    scalex=getScale(HowtoVPB::DEM,HowtoVPB::X);
    if(scalex!=0.0)
        ss<<" --xx "<<scalex;
    scaley=getScale(HowtoVPB::DEM,HowtoVPB::Y);
    if(scaley!=0.0)        
        ss<<" --yy "<<scaley;
    file=getFile(HowtoVPB::DEM);
    if(file.length()>0)
        ss<<" -d "<<file;
    int level=getPageLevel();
    if(level<=0)level=3;
    ss<<" -l "<<level;
    float scalez=getScale(HowtoVPB::OUT,HowtoVPB::Z);
    if(scalez==0.0)scalez=1.0;
    ss<<" -v "<<scalez;
    ss<<" -o "<<getFile(HowtoVPB::OUT);
    string str=ss.str();
    int ret=::system(str.c_str());
    return ret;
}
调用代码如下:
HowtoVPB vpb;
    vpb.setScale (HowtoVPB::TEXTURE,HowtoVPB::X,1000);
    vpb.setScale(HowtoVPB::TEXTURE,HowtoVPB::Y,1000);
    vpb.setScale(HowtoVPB::DEM,HowtoVPB::X,1000);
    vpb.setScale(HowtoVPB::DEM ,HowtoVPB::Y,1000);
    vpb.setScale(HowtoVPB::OUT,HowtoVPB::Z,10);
    vpb.setFile(HowtoVPB::TEXTURE,"c:\\QisData\\ps\\ps_texture_4k.tif");
    vpb.setFile(HowtoVPB::DEM,"c:\\QisData\\ps\\ps_dem_4k.tif");
    vpb.setFile(HowtoVPB::OUT,"c:\\ps_out.ive");
    vpb.setPageLevel(8);
    return vpb.run();

代码太简单了,就不做解释了.

目前的问题就是在执行这个命令行的时候会有一个dos窗口存在,让人很不爽.

 

Ps:附上osgdem的参数表,免得到处乱找.

Parameter Description Default
General
-h or --help Display commandline arguments information
--task
-s Specify a VPB source file containing all commandline options.
--so Output the VPB source file for the current run.
--report
--cache Read the cache file to use a look up for locally cached files.
--version Print out version
--version-number Print out version number only.
--comment Added a comment/description string to the top most node in the dataset empty
--split Set the distributed build split level.
--splits Set the distributed build primary and secondary split levels.
--run-path Set the path that the build should be run from.
--notify-level Set the notify level when logging messages.
Input
-d Specify the digital elevation map input file to process
-t Specify the texture map input file to process
--building Specify building outlines using shapefiles.
--forest Specify forest outlines using shapefiles
--levels Specify the range of levels that the next source Texture or DEM will contribute to.
--layer Specify the layer that the next source Texture will contribute to..
Coordinate system
--cs Set the coordinates system of source imagery, DEM or destination database. The string may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPS
--wkt Set the coordinates system of source imagery, DEM or destination database in WellKownText form.
--wkt-file Set the coordinates system of source imagery, DEM or destination database by as file containing WellKownText definition.
Geocentric database
--geocentric Build a database in geocentric (i.e. whole earth) database.
--bluemarble-east Set the coordinates system for next texture or dem to represent the eastern hemisphere of the earth.
--bluemarble-west Set the coordinates system for next texture or dem to represent the western hemisphere of the earth.
--whole-globe Set the coordinates system for next texture or dem to represent the whole hemisphere of the earth.
Ellipsoid model
--radius-polar Set the polar radius of the ellipsoid model when building a geocentric database. 6356752.3142
--radius-equator Set the equatorial radius of the ellipsoid model when building a geocentric database. 6378137
--spherical Set the polar and equatorial radius both to the average of the two.
Flat database
--range Set the coordinates system for next texture or dem to the given range.
--xx
--xt
--yy
--yt
--zz
--zt
DataType?
--vector Interpret input as a vector data set
--raster Interpret input as a raster data set (default)
Output
--image-ext Specify the Image format to output to via its plugin name, i.e. rgb, dds, jp2, jpeg. .dds
-o Specify the output master file to generate
-a Specify the archive to place the generated database
--ibn Specify the intermediate build file name
-l Specify the number of PagedLOD levels to generate 30
-e Extents of the model to generate
-ge Geographic (Lat/Lon) Extents of the model to generate.
-b Bounds (similar to extents) of the model to generate. Max/Min order is not important.
-gb Geographic Bounds (similar to extents) of the model to generate. Max/Min order is not important.
--skirt-ratio Set the ratio of skirt height to tile size 0.02
-v Set the vertical multiplier 1.0
--no-terrain-simplification Switch off terrain simplification. true
--default-color Sets the default color of the terrain. (0.5, 0.5, 1.0, 1.0)
--radius-to-max-visible-distance-ratio Set the maximum visible distance ratio for all tiles apart from the top most tile. The maximum visible distance is computed from the ratio * tile radius. 7.0
--max-anisotropy Max anisotropy level to use when texturing 1.0
GeometryType?
--HEIGHT_FIELD Create a height field database
--POLYGONAL Create a height field database (default)
--TERRAIN Create a osgTerrain::Terrain database
DatabaseType?
--LOD Create a LOD'd database
--PagedLOD Create a PagedLOD'd database (default)
TextureType?
--compressed Use OpenGL compression on RGB destination imagery (default)
--RGBA-compressed Use OpenGL compression on RGBA destination imagery
--RGB-16 Use 16bit RGB destination imagery
--RGBA-24 Use 24bit RGB destination imagery
--RGB-16 Use 16bit RGBA destination imagery
--RGBA Use 32bit RGBA destination imagery
MipMappingMode?
--no-mip-mapping Disable mip mapping of textures
--mip-mapping-hardware Use mip mapped textures, and generate the mipmaps in hardware when available.
--mip-mapping-imagery Use mip mapped textures, and generate the mipmaps in imagery. (default)
--BuildOverlays [True/False] Switch on/off the building of overlay within the source imagery. Overlays can help reduce texture aliasing artifacts. false
--ReprojectSources [True/False] Switch on/off the reprojection of any source imagery that aren't in the correct projection for the database build. true
--GenerateTiles [True/False] Switch on/off the generation of the output database tiles. true
--tile-image-size Set the tile maximum image size 256
--tile-terrain-size Set the tile maximum terrain size 64
-O string option to pass to write plugins, use "" for multiple options
--subtile Set the subtile to begin the build from.
--record-subtile-on-leaf-tiles Enable the setting of the subtile file name of the leaf tiles. false
--type-attribute Set the type name which specify how the shapes should be interpreted in shapefile/dbase files. (empty signifies no type attribute has been defined) NAME
--height-attribute Set the attribute name for height attributes used in shapefile/dbase files. HGT
--height Set the height to use for associated shapefiles. (negative signifies that no height has been defined) -1.0
--mask Set the mask to assign indivual shapefile/model. 0xffffffff
--terrain-mask Set the overall mask to assign terrain. 0xffffffff
--read-threads-ratio Set the ratio number of read threads relative to number of cores to use. 0.0
--write-threads-ratio Set the ratio number of write threads relative to number of cores to use. 0.0
--build-options Set build options string.
DEM interpolation
--interpolate-terrain Enable the use of interpolation when sampling data from source DEMs. (default)
--no-interpolate-terrain Disable the use of interpolation when sampling data from source DEMs.
Imagery interpolation
--interpolate-imagery Enable the use of interpolation when sampling data from source imagery. (default)
--no-interpolate-imagery Disable the use of interpolation when sampling data from source imagery.

本人不保证文章内容之正确性与实时性.所有文章均可用于商业和非商业用途而无需通知本人.若修改后再发布,请保留原文之链接,以供读者参考.

本人联系方式如下,有问题可共同探讨:MSN:zhuliangxiong@hotmail.com QQ:348824773

0
0
(请您对文章做出评价)
« 上一篇:HowtoOSG:渲染到纹理
» 下一篇:HowtoSqlite 编译成功
posted on 2009-06-24 01:50 朱良雄 阅读(200) 评论(0)  编辑 收藏 网摘 所属分类: OpenSceneGraph