void CatalogWorker::calcLatLon(const ICoordinateSystem& csyWgs84,Ilwis::Resource& resource, std::vector<Resource>& updatedResources){
    try{
        if ( !resource.hasProperty("latlonenvelope")){
            ICoverage cov(resource);
            if ( cov.isValid()){
                if ( cov->coordinateSystem()->isUnknown()) // we cant do anything with unknown
                    return;
                if ( cov->coordinateSystem()->isLatLon()){
                    QString envelope = cov->envelope().toString();
                    resource.addProperty("latlonenvelope",envelope);
                }else {
                    Envelope env = cov->envelope();
                    if ( env.isNull() || !env.isValid())
                        return;
                    Envelope llEnvelope = csyWgs84->convertEnvelope(cov->coordinateSystem(), env);
                    if ( llEnvelope.isNull() || !llEnvelope.isValid())
                        return;

                    resource.addProperty("latlonenvelope",llEnvelope.toString());
                }
                updatedResources.push_back(resource);
            }
        }
    } catch(const ErrorObject&){
    } catch( std::exception& ){
    }
}
SpreadSheetTableConnector::SpreadSheetTableConnector(const Ilwis::Resource &resource, bool load, const Ilwis::IOOptions &options) :  IlwisObjectConnector(resource, load, options)
{
    QFileInfo odsinfo = resource.toLocalFile();
    QString sheetName;
    QString suffix =  odsinfo.suffix();
    if ( suffix == "" && options.contains("format")){
        suffix = options["format"].toString();
    }
    if ( !knownSuffix(suffix)){
        int index  = odsinfo.absoluteFilePath().lastIndexOf("/");
        int index2 = odsinfo.absoluteFilePath().lastIndexOf(".");
        if ( index2 == -1 || index2 < index){
            sheetName = odsinfo.absoluteFilePath().mid(index + 1);
            odsinfo = QFileInfo(odsinfo.absolutePath());
        }else if ( index2 != -1){
            suffix = options["format"].toString();
            QString correctName = odsinfo.absolutePath() + "/" + odsinfo.baseName() + "." + suffix;
            QString correctUrl = QUrl::fromLocalFile(correctName).toString();
            sourceRef().setUrl(correctUrl);
            sourceRef().setUrl(correctUrl,true);
        }
    }
    if ( suffix.toLower() == "ods"){
        _spreadsheet.reset( new ODSFormat());
    } else if ( suffix.toLower() == "xls"){
        _spreadsheet.reset( new XLSFormat());
    } else if ( suffix.toLower() == "xlsx"){
        _spreadsheet.reset( new XLSXFormat());
    }

}
bool ProjectionImplFactory::canUse(const Ilwis::Resource &resource) const
{
    QString prj = resource.code();
    if ( prj == "PRJPC")
        return true;

    return false;
}
Exemple #4
0
void ResourceModel::resource(const Ilwis::Resource& res)
{
    Resource item = res;
    if ( item.name() == sUNDEF) {
        QString name  = res.url().toString(QUrl::RemoveScheme | QUrl::RemoveQuery | QUrl::RemovePassword | QUrl::StripTrailingSlash);
        name = name.mid(3);
        item.name(name, false);
    }

    _type = item.ilwisType();
    _item = item;
    if ( hasType(item.ilwisType(), itCOVERAGE)){
        QString dim = _item.dimensions();
        _is3d = dim.split(" ").size() == 3;
    }

    if ( item.url().toString() == "file://"){
        _displayName = "root";
        _isRoot = true;
    }
    else if ( item.url().scheme() == "file") {
        QFileInfo inf(_item.url().toLocalFile());
        QString path = inf.absolutePath();
        _isRoot = inf.isRoot();
        _displayName = item.name();
        QFileInfo thumbPath = path + "/thumbs/" + _displayName + ".png";
        if ( thumbPath.exists()) {
            _imagePath =  "file:///" +  thumbPath.absoluteFilePath();
        } else {
            if ( item.ilwisType() == itCATALOG) {
                _imagePath = "catalog.png";
            }
            if ( hasType(item.ilwisType(), itRASTER))
                 _imagePath = "remote.png";
            else if ( hasType(item.ilwisType(), itFEATURE))
                _imagePath = "polygon.png";
            else if ( hasType(item.ilwisType(), itCOORDSYSTEM))
                _imagePath = "csy.png";
            else if ( hasType(item.ilwisType(), itGEOREF))
                _imagePath = "grf.png";
            else if ( hasType(item.ilwisType(), itTABLE))
                _imagePath = "table.jpg";
            else if ( hasType(item.ilwisType(), itDOMAIN))
                _imagePath = "domainn.png";
            else if ( hasType(item.ilwisType(), itREPRESENTATION))
                _imagePath = "representation20.png";
            else
                _imagePath = "blank.png";
        }
    }else{
        if ( item.hasProperty("longname"))
            _displayName =  item["longname"].toString();
        else
            _displayName = item.name();
    }
}
bool PlateCaree::canUse(const Ilwis::Resource &resource)
{
    QString prj = resource.code();
    if ( prj == sUNDEF)
        return false;
    if ( prj == "PRJPC")
        return true;

    return false;
}
IlwisObjectModel::IlwisObjectModel(const Ilwis::Resource &source, QObject *parent) : ResourceModel(source, parent)
{
    try{
        if ( source.name() != "Global Layer"){ // special case for the dummy object of the global layer
            _ilwisobject.prepare(resource());
        }
    } catch (const ErrorObject& ){

    } catch ( std::exception& ex){
        kernel()->issues()->log(ex.what());
    }
}
GdalCatalogConnector::GdalCatalogConnector(const Ilwis::Resource &resource) : CatalogConnector(resource), _type(resource.ilwisType())
{
}