Changeset 6211 for geovis


Ignore:
Timestamp:
Mar 27, 2016 7:17:04 AM (8 years ago)
Author:
ldelgass
Message:

When downloading shape file from idata, get auxiliary files as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Renderer.cpp

    r6110 r6211  
    30623062            osgDB::makeDirectory(dirPath);
    30633063        }
     3064        // If this is a shape file, get auxiliary files (e.g. .dbf, .shx, etc)
     3065        if (osgDB::getFileExtension(fileName) == "shp") {
     3066            // Check for files with same basename
     3067            std::vector<DirectoryItem> items;
     3068            std::string path = osgDB::getFilePath(fileName);
     3069            getContents(collection, path.c_str(), items);
     3070            // Get name without extension
     3071            std::string basename = osgDB::getStrippedName(fileName);
     3072            for (std::vector<DirectoryItem>::const_iterator itr = items.begin();
     3073                 itr != items.end(); ++itr) {
     3074                if (!itr->isDir &&
     3075                    osgDB::getStrippedName(itr->name) == basename) {
     3076                    std::string localName;
     3077                    {
     3078                        std::ostringstream oss;
     3079                        oss << getCacheDirectory() << "/" << itr->name;
     3080                        localName = oss.str();
     3081                    }
     3082                    if (!localName.empty() && !osgDB::fileExists(localName)) {
     3083                        IData::Buffer buf;
     3084                        {
     3085                            std::ostringstream oss;
     3086                            oss << "//" << itr->name;
     3087                            IData::getFile(collection, oss.str().c_str(), &buf);
     3088                        }
     3089                        std::ofstream file(localName.c_str());
     3090                        file.write((char *)buf.data, buf.size);
     3091                        file.close();
     3092                    }
     3093                }
     3094            }
     3095        }
    30643096        if (!osgDB::fileExists(retStr)) {
    30653097            std::ostringstream oss;
Note: See TracChangeset for help on using the changeset viewer.