Ejemplo n.º 1
0
QQmlListProperty<ProjectionParameterModel> IlwisObjectModel::projectionItems()
{
    IlwisTypes objectype = _ilwisobject->ilwisType();
    if ( hasType( objectype, itPROJECTION | itCONVENTIONALCOORDSYSTEM)){
        IProjection proj;
        _projectionParmItems.clear();
        if ( hasType(objectype, itCONVENTIONALCOORDSYSTEM)){
            IConventionalCoordinateSystem csyProj = _ilwisobject.as<ConventionalCoordinateSystem>();
            if ( csyProj.isValid()){
                proj = csyProj->projection();
            }
        }else
            proj = _ilwisobject.as<Projection>();

        if ( proj.isValid()){
            if ( proj->isUsed(Projection::pvX0))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvX0, this));
            if ( proj->isUsed(Projection::pvY0))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvY0, this));
            if ( proj->isUsed(Projection::pvLON0))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvLON0, this));
            if ( proj->isUsed(Projection::pvLAT0))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvLAT0, this));
            if ( proj->isUsed(Projection::pvLAT1))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvLAT1, this));
            if ( proj->isUsed(Projection::pvLAT2))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvLAT2, this));
            if ( proj->isUsed(Projection::pvLATTS))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvLATTS, this));
            if ( proj->isUsed(Projection::pvK0))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvK0, this));
            if ( proj->isUsed(Projection::pvZONE))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvZONE, this));
            if ( proj->isUsed(Projection::pvHEIGHT))
                _projectionParmItems.append(new ProjectionParameterModel(proj, Projection::pvHEIGHT, this));
        }
        return QQmlListProperty<ProjectionParameterModel>(this, _projectionParmItems);
    }

    return QQmlListProperty<ProjectionParameterModel>();
}
Ejemplo n.º 2
0
QString IlwisObjectModel::getProperty(const QString &propertyname)
{
    try{
        QString property = ResourceModel::getProperty(propertyname);
        if ( property != sUNDEF)
            return property;
        if ( !_ilwisobject.isValid())
            return "";
        if ( propertyname == "latlonenvelope" || propertyname == "envelope"){
            if (hasType(_ilwisobject->ilwisType(), itCOVERAGE)){
                return _ilwisobject.as<Coverage>()->envelope(propertyname == "latlonenvelope").toString();
            } if ( hasType(_ilwisobject->ilwisType(), itCOORDSYSTEM)){
                return _ilwisobject.as<CoordinateSystem>()->envelope(propertyname == "latlonenvelope").toString();
            }
        }
        if ( propertyname == "pixelsize"){
            return pixSizeString();
        }
        if ( propertyname == "centerpixelboundingbox"){
            return centerPixelLocation();
        }
        if ( propertyname == "parentdomain"){
            return parentDomain();
        }
        if ( propertyname == "valuetype"){
            return valueType();
        }
        if ( propertyname == "recordcount"){
            if ( hasType(_ilwisobject->ilwisType(), itTABLE)){
                return QString::number(_ilwisobject.as<Table>()->recordCount());
            }
        }
        if ( propertyname == "columncount"){
            if ( hasType(_ilwisobject->ilwisType(), itTABLE)){
                return QString::number(_ilwisobject.as<Table>()->columnCount());
            }
        }
        if ( propertyname == "polygoncount"){
             if ( hasType(_ilwisobject->ilwisType(), itFEATURE)){
                IFeatureCoverage features = _ilwisobject.as<FeatureCoverage>();
                return QString::number(features->featureCount(itPOLYGON));
             }
        }
        if ( propertyname == "linecount"){
             if ( hasType(_ilwisobject->ilwisType(), itFEATURE)){
                IFeatureCoverage features = _ilwisobject.as<FeatureCoverage>();
                return QString::number(features->featureCount(itLINE));
             }
        }
        if ( propertyname == "pointcount"){
             if ( hasType(_ilwisobject->ilwisType(), itFEATURE)){
                IFeatureCoverage features = _ilwisobject.as<FeatureCoverage>();
                return QString::number(features->featureCount(itPOINT));
             }
        }
        if ( propertyname == "featurecount"){
             if ( hasType(_ilwisobject->ilwisType(), itFEATURE)){
                IFeatureCoverage features = _ilwisobject.as<FeatureCoverage>();
                return QString::number(features->featureCount());
             }
        }
        if ( propertyname == "majoraxis"){
             if ( hasType(_ilwisobject->ilwisType(), itELLIPSOID)){
                IEllipsoid ellipsoid = _ilwisobject.as<Ellipsoid>();
                return QString::number(ellipsoid->majorAxis());
             }
        }
        if ( propertyname == "minoraxis"){
             if ( hasType(_ilwisobject->ilwisType(), itELLIPSOID)){
                IEllipsoid ellipsoid = _ilwisobject.as<Ellipsoid>();
                return QString::number(ellipsoid->minorAxis());
             }
        }
        if ( propertyname == "flattening"){
             if ( hasType(_ilwisobject->ilwisType(), itELLIPSOID)){
                IEllipsoid ellipsoid = _ilwisobject.as<Ellipsoid>();
                return QString::number(ellipsoid->flattening());
             }
        }
        if ( propertyname == "excentricity"){
             if ( hasType(_ilwisobject->ilwisType(), itELLIPSOID)){
                IEllipsoid ellipsoid = _ilwisobject.as<Ellipsoid>();
                return QString::number(ellipsoid->excentricity());
             }
        }
        if (propertyname == "proj4def"){
            IlwisTypes objectype = _ilwisobject->ilwisType();
            if ( hasType( objectype, itPROJECTION | itCONVENTIONALCOORDSYSTEM)){
                IProjection proj;
                if ( hasType(objectype, itCONVENTIONALCOORDSYSTEM)){
                    IConventionalCoordinateSystem csyProj = _ilwisobject.as<ConventionalCoordinateSystem>();
                    if ( csyProj.isValid()){
                        proj = csyProj->projection();
                    }
                }else
                    proj = _ilwisobject.as<Projection>();
                if ( proj.isValid()){
                    return proj->toProj4();
                }
            }

        }

        return "";
    } catch(const ErrorObject& ){
        // no exceptions may escape here
    }
    return "";
}