本文整理汇总了C++中ITable::ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ ITable::ptr方法的具体用法?C++ ITable::ptr怎么用?C++ ITable::ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable::ptr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadData
bool GdalFeatureConnector::loadData(IlwisObject* data, const IOOptions &){
if(!GdalConnector::loadMetaData(data, IOOptions()))
return false;
bool ok = true;
FeatureCoverage *fcoverage = static_cast<FeatureCoverage *>(data);
if ( fcoverage->isValid() ) {
ITable attTable = fcoverage->attributeTable();
if (!attTable.isValid()){
ERROR2(ERR_NO_INITIALIZED_2,"attribute table",_filename.toString());
return false;
}
fcoverage->setFeatureCount(itFEATURE, iUNDEF, FeatureInfo::ALLFEATURES); // metadata already set it to correct number, creating new features will up the count agains; so reset to 0.
OGRLayerH hLayer = getLayerHandle();
if ( hLayer) {
GdalTableLoader loader;
attTable->dataLoaded(true); // new table, dont want any loading behaviour
loader.setColumnCallbacks(attTable.ptr(), hLayer);
std::vector<QVariant> record(attTable->columnCount());
OGRFeatureH hFeature = 0;
gdal()->resetReading(hLayer);
//each FEATURE
try {
while( (hFeature = gdal()->getNextFeature(hLayer)) != NULL){
loader.loadRecord(attTable.ptr(), hFeature, record);
geos::geom::Geometry * geometry = fillFeature(fcoverage, gdal()->getGeometryRef(hFeature));
if (geometry){
auto feature = fcoverage->newFeature(geometry, false);
feature->record(record);
}else{
ERROR1("GDAL error during load of binary data: no geometry detected for feature in %1", _filename.toString());
}
gdal()->destroyFeature( hFeature );
}
} catch (FeatureCreationError& ) {
gdal()->destroyFeature( hFeature );
ok = false;
}
}
//layer envelopes/extents
Envelope bbox;
OGREnvelope envelope;//might sometimes be supported as 3D now only posssible from OGRGeometry
OGRErr err = gdal()->getLayerExtent(hLayer, &envelope , TRUE);//TRUE to FORCE
if (err != OGRERR_NONE && fcoverage->featureCount() != 0){
ERROR0(QString("Couldn't load extent of a layer from %1 after binary was loaded: %2").arg(_filename.toString()).arg(gdal()->translateOGRERR(err)));
}else{
bbox = Envelope(Coordinate(envelope.MinX,envelope.MinY),Coordinate(envelope.MaxX,envelope.MaxY));
}
fcoverage->envelope(bbox);
}
gdal()->closeFile(sourceRef().toLocalFile(), data->id());
_binaryIsLoaded = ok;
return ok;
}
示例2: loadData
bool PostgresqlFeatureCoverageLoader::loadData(FeatureCoverage *fcoverage) const
{
//qDebug() << "PostgresqlFeatureCoverageLoader::loadData()";
ITable table;
PostgresqlDatabaseUtil pgUtil(_resource,_options);
Resource tableResource = pgUtil.resourceForType(itFLATTABLE);
table.prepare(tableResource, _options);
PostgresqlTableLoader tableLoader(table->source(), _options);
if (!tableLoader.loadData(table.ptr())) {
ERROR1("Could not load table data for table '%1'", table->name());
return false;
}
// metadata already set it to correct number, creating new features will up the count agains; so reset to 0.
fcoverage->setFeatureCount(itFEATURE, iUNDEF, FeatureInfo::ALLFEATURES);
QList<MetaGeometryColumn> metaGeometries;
pgUtil.getMetaForGeometryColumns(metaGeometries);
QSqlQuery query = pgUtil.doQuery(selectGeometries(metaGeometries), "featurecoverageloader");
quint32 geometriesPerFeature = metaGeometries.size();
IDomain semantics;
pgUtil.prepareSubFeatureSemantics(semantics, metaGeometries);
while (query.next()) {
if (geometriesPerFeature == 0) {
fcoverage->newFeature(0);
} else {
// index 0 is root, indeces > 0 are subfeatures of root
bool atRoot = true;
SPFeatureI rootFeature;
// iterate semantics to keep predefined order
ItemRangeIterator iter(semantics->range<>().data());
while (iter.isValid()) {
QString geomName = (*iter)->name();
ICoordinateSystem crs;
std::for_each(metaGeometries.begin(), metaGeometries.end(), [&crs,geomName](MetaGeometryColumn c) {
if (c.geomColumn == geomName) {
crs = c.crs;
}
});
if (atRoot) {
atRoot = false;
geos::geom::Geometry *rootGeometry = createGeometry(query, geomName, crs);
rootFeature = fcoverage->newFeature(rootGeometry, false);
} else {
geos::geom::Geometry *subGeometry = createGeometry(query, geomName, crs);
rootFeature->createSubFeature(geomName,subGeometry);
}
++iter;
}
}
}
fcoverage->attributesFromTable(table);
return true;
}
示例3: storeBinaryData
bool CoverageConnector::storeBinaryData(IlwisObject *obj, IlwisTypes tp)
{
Coverage *coverage = static_cast<Coverage *>(obj);
ITable attTable = coverage->attributeTable();
if ( attTable.isValid()) {
QScopedPointer<TableConnector> conn(createTableConnector(attTable, coverage, tp));
return conn->storeBinaryData(attTable.ptr());
}
return false;
}
示例4: storeBinaryDataTable
bool FeatureConnector::storeBinaryDataTable(IlwisObject *obj, IlwisTypes tp, const QString& baseName)
{
FeatureCoverage *fcoverage = static_cast<FeatureCoverage *>(obj);
ITable attTable = fcoverage->attributeTable();
if ( attTable.isValid() && attTable->columnCount() > 0) {
QFileInfo basename (baseName);
QScopedPointer<TableConnector> conn(createTableStoreConnector(attTable, fcoverage, tp, basename.baseName()));
IFeatureCoverage cov(fcoverage);
FeatureIterator iter(cov);
quint32 i = 0;
std::vector<quint32> recordnr(fcoverage->featureCount(tp));
for(quint32 rec=0; rec < fcoverage->featureCount(); ++rec){
if ( hasType((*iter)->geometryType(), tp))
recordnr[i++] = rec;
++iter;
};
conn->selectedRecords(recordnr);
return conn->storeBinaryData(attTable.ptr());
}
return true; // no store needed
}
示例5: storeData
bool PostgresqlFeatureCoverageLoader::storeData(FeatureCoverage *fcoverage) const
{
bool queryOk = true;
ITable baseData = fcoverage->attributeTable();
PostgresqlParameters params (_resource.url(true).toString());
PostgresqlDatabaseUtil pgUtil(params);
SqlStatementHelper sqlHelper(params);
bool newTable = false;
if ( !pgUtil.tableExists()){
if(!pgUtil.createTable(fcoverage)){
return false;
}
newTable = true;
}
IDomain semantics; // subfeature semantics
QList<QString> primaryKeys; // readonly keys
QList<MetaGeometryColumn> metaGeomColumns; // geometry columns
pgUtil.getMetaForGeometryColumns(metaGeomColumns);
pgUtil.prepareSubFeatureSemantics(semantics, metaGeomColumns, _options);
pgUtil.getPrimaryKeys(primaryKeys);
// add geoms to update/insert data table
FeatureIterator featureIter(fcoverage);
featureIter.flow(FeatureIterator::fDEPTHFIRST);
QString columnNamesCommaSeparated = sqlHelper.columnNamesCommaSeparated(baseData.ptr());
QString code = fcoverage->coordinateSystem()->code();
QString srid = code.right(code.indexOf(":"));
QString qtablename = params.table().toLower();
while(featureIter != featureIter.end()) {
SPFeatureI feature = (*featureIter);
bool newFeature = newTable ? true : !pgUtil.exists(feature);
QString columnValuesCommaSeparated = sqlHelper.columnValuesCommaSeparated(feature);
QString sqlStmt;
if (newFeature) {
sqlStmt = "INSERT INTO ";
sqlStmt.append(qtablename);
sqlStmt.append(" ( ");
sqlStmt.append(columnNamesCommaSeparated);
foreach (MetaGeometryColumn geomMeta, metaGeomColumns) {
sqlStmt.append(", ");
sqlStmt.append(geomMeta.geomColumn);
}
sqlStmt.append(" ) ");
sqlStmt.append(" VALUES ( ");
sqlStmt.append(columnValuesCommaSeparated);
sqlStmt.append(", ");
// add geometry values
/*
// TODO storing level n data only makes sense
// if subfeatures are stored in separate
// tables related via foreign keys, but
// separate tables aren't supported now
ITabel levelData = fcoverage->attributeTable(level);
PostgresqlTableConnector connector(_resource,false);
tableOk = connector.store(levelData.ptr(), options);
*/
QString rootGeomColumn = fcoverage->attributeDefinitionsRef().index((quint32)0);
// have to iterate the order of given geom columns
foreach (MetaGeometryColumn geomMeta, metaGeomColumns) {
QString wkt = "NULL";
QString geomColumn = geomMeta.geomColumn;
if (rootGeomColumn == geomColumn || rootGeomColumn == sUNDEF) {
if (feature->geometry() != nullptr){
wkt = QString("'%1'").arg(GeometryHelper::toWKT(feature->geometry().get()));
}
} else if (feature[geomColumn]->geometry() != nullptr){
// access subfeature geometries
SPFeatureI subfeature = feature[geomColumn];
wkt = QString("'%1'").arg(GeometryHelper::toWKT(subfeature->geometry().get()));
}
sqlStmt.append("st_geomfromtext(").append(wkt);
sqlStmt.append(", ").append(srid).append(")");
sqlStmt.append(",");
// skip subfeature's geometries, as accessed already via domain
++featureIter;
}
sqlStmt = sqlHelper.trimAndRemoveLastCharacter(sqlStmt);
sqlStmt.append(" ); ");
} else {
示例6: storeMetaData
//.........这里部分代码省略.........
return false;
Coverage *coverage = static_cast<Coverage *>(obj);
const ICoordinateSystem csy = coverage->coordinateSystem();
if (!csy.isValid())
return ERROR2(ERR_NO_INITIALIZED_2, "CoordinateSystem", coverage->name());
QString localName = Resource::toLocalFile(csy->source().url(),true);
if ( localName == sUNDEF) {
localName = CoordinateSystemConnector::createCsyFromCode(csy->code());
}
if ( localName == sUNDEF) {
return ERROR2(ERR_NO_INITIALIZED_2, "CoordinateSystem", coverage->name());
}
_odf->setKeyValue("BaseMap","CoordSystem", localName);
Box2D<double> bounds = coverage->envelope();
if(!bounds.isValid())
return ERROR2(ERR_NO_INITIALIZED_2, "Bounds", coverage->name());
_odf->setKeyValue("BaseMap","CoordBounds",QString("%1 %2 %3 %4").
arg(bounds.min_corner().x(),10,'f').
arg(bounds.min_corner().y(),10,'f').
arg(bounds.max_corner().x(),10,'f').
arg(bounds.max_corner().y(),10,'f'));
const IDomain dom = datadef.domain();
if (!dom.isValid())
return ERROR2(ERR_NO_INITIALIZED_2, "Domain", coverage->name());
calcStatics(obj,NumericStatistics::pBASIC);
if ( dom->ilwisType() == itNUMERICDOMAIN) {
quint16 digits = coverage->statistics().significantDigits();
qint32 delta = coverage->statistics()[NumericStatistics::pDELTA];
if ( delta >= 0 && delta < 256 && digits == 0){
if ( delta >= 0 && delta < 256 && digits == 0){
if ( datadef.domain()->code() == "boolean"){
QString domInfo = QString("bool.dom;Byte;bool;0;;");
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
_odf->setKeyValue("BaseMap","Range","0:1:offset=-1");
_odf->setKeyValue("BaseMap","Domain","bool.dom");
}
else{
QString domInfo = QString("Image.dom;Byte;image;0;;");
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
_odf->setKeyValue("BaseMap","Range","0:255:offset=0");
_odf->setKeyValue("BaseMap","MinMax","0:255");
_odf->setKeyValue("BaseMap","Domain","Image.dom");
}
}
}
else {
const NumericStatistics& stats = coverage->statistics();
int digits = stats.significantDigits();
RawConverter conv(stats[NumericStatistics::pMIN], stats[NumericStatistics::pMAX],pow(10, - digits));
QString rangeString = QString("%1:%2:%3:offset=%4").arg(stats[NumericStatistics::pMIN]).arg(stats[NumericStatistics::pMAX]).arg(conv.scale()).arg(conv.offset());
_odf->setKeyValue("BaseMap","Range",rangeString);
_odf->setKeyValue("BaseMap","Domain","value.dom");
_odf->setKeyValue("BaseMap","MinMax",QString("%1:%2").arg(stats[NumericStatistics::pMIN]).arg(stats[NumericStatistics::pMAX]));
QString domInfo = QString("value.dom;Long;value;0;-9999999.9:9999999.9:0.1:offset=0");
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
}
} if ( dom->ilwisType() == itITEMDOMAIN) {
QString source = Resource::toLocalFile(dom->source().url(), true);
if ( dom->valueType() == itTHEMATICITEM && coverage->ilwisType() == itRASTER) {
IThematicDomain themdom = dom.get<ThematicDomain>();
if ( themdom.isValid()) {
QString domInfo = QString("%1;Byte;class;%2;;").arg(source).arg(themdom->count());
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
_odf->setKeyValue("BaseMap","Domain",source);
}
} else if(dom->valueType() == itINDEXEDITEM) {
QString domName = _odf->fileinfo().fileName();
QString domInfo = QString("%1;Long;UniqueID;0;;").arg(domName);
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
_odf->setKeyValue("BaseMap","Domain",domName);
} else if ( dom->valueType() == itNAMEDITEM) {
INamedIdDomain iddom = dom.get<NamedIdDomain>();
QString domName = _odf->fileinfo().fileName();
int index;
if ( (index=domName.lastIndexOf("."))!= -1) {
domName = domName.left(index);
}
QString domInfo = QString("%1;;Int;id;%2;;").arg(domName).arg(iddom->count());
_odf->setKeyValue("BaseMap","DomainInfo",domInfo);
_odf->setKeyValue("BaseMap","Domain",domName);
iddom->connectTo(QUrl(),"domain","ilwis3", IlwisObject::cmOUTPUT);
iddom->store(Ilwis::IlwisObject::smMETADATA | Ilwis::IlwisObject::smBINARYDATA);
}
}
ITable attTable = coverage->attributeTable();
if ( attTable.isValid()) {
QScopedPointer<TableConnector> conn(createTableConnector(attTable, coverage, type));
conn->storeMetaData(attTable.ptr());
}
return true;
}
示例7: storeMetaData
bool FeatureConnector::storeMetaData(FeatureCoverage *fcov, IlwisTypes type) {
if ( type == itUNKNOWN)
return true;//if type is itUNKNOWN we dont store
DataDefinition datadef;
ITable attTable = fcov->attributeTable();
QString primkey = attTable->primaryKey();
if (primkey == sUNDEF)
primkey = COVERAGEKEYCOLUMN;
int index = attTable->columnIndex(primkey);
if ( index != iUNDEF ) {
const ColumnDefinition& coldef = attTable->columndefinitionRef(index);
if ( coldef.datadef().domain<>()->ilwisType() == itITEMDOMAIN)
datadef = DataDefinition(coldef.datadef().domain(),coldef.datadef().range()->clone());
}
if ( !datadef.isValid()) {
INamedIdDomain indexdom;
indexdom.prepare();
indexdom->name(fcov->name());
NamedIdentifierRange range;
for(quint32 i=0; i < fcov->featureCount(type); ++i){
QStringList parts = Ilwis3Connector::ilwis3ClassName(type).split(" ");
QString itemname = QString("%1_%2").arg(parts[0]).arg(i);
range << itemname;
}
indexdom->setRange(range);
datadef.domain(indexdom);
QFileInfo inf ( _resource.url(true).toLocalFile());
QString filename = context()->workingCatalog()->filesystemLocation().toLocalFile() + "/" + inf.baseName() + ".dom";
indexdom->connectTo(filename,"domain","ilwis3", Ilwis::IlwisObject::cmOUTPUT);
indexdom->store();
}
bool isMulti = (fcov->featureTypes() & (fcov->featureTypes() - 1)) != 0;
QString baseName = Ilwis3Connector::outputNameFor(fcov, isMulti, type);
index = baseName.lastIndexOf(".");
if ( index != -1) {
baseName = baseName.left(index);
}
bool ok = CoverageConnector::storeMetaData(fcov, type, datadef, baseName);
if ( !ok)
return false;
if ( datadef.domain()->valueType() == itINDEXEDITEM) {
_odf->setKeyValue("Domain","Type","DomainUniqueID");
_odf->setKeyValue("DomainSort","Sorting","AlphaNumeric");
_odf->setKeyValue("DomainSort","Prefix","feature");
_odf->setKeyValue("DomainSort","Class","Domain UniqueID");
_odf->setKeyValue("DomainIdentifier","Nr",IniFile::FormatElement(fcov->featureCount(type)));
}
Envelope bounds = fcov->envelope();
if ( bounds.isNull() || !bounds.isValid())
bounds = fcov->coordinateSystem()->envelope();
_odf->setKeyValue("BaseMap","CoordBounds",QString("%1 %2 %3 %4").
arg(bounds.min_corner().x,0,'f',10).
arg(bounds.max_corner().y,0,'f',10).
arg(bounds.max_corner().x,0,'f',10).
arg(bounds.min_corner().y,0,'f',10));
QString ext = "mpa";
if ( hasType(type, itPOLYGON)){
ok = storeMetaPolygon(fcov, baseName);
}
if ( hasType(type, itLINE)){
ok = storeMetaLine(fcov, baseName);
ext = "mps";
}
if ( hasType(type, itPOINT)){
ok = storeMetaPoint(fcov, baseName);
ext = "mpp";
}
if ( attTable.isValid() && attTable->columnCount() > 0) {
QFileInfo basename (baseName);
QScopedPointer<TableConnector> conn(createTableStoreConnector(attTable, fcov, type, basename.baseName()));
std::vector<quint32> recs(_itemCount);
conn->selectedRecords(recs);
conn->storeMetaData(attTable.ptr());
}
_odf->store(ext, QFileInfo(baseName));
return ok;
}