本文整理汇总了C++中ITable::prepare方法的典型用法代码示例。如果您正苦于以下问题:C++ ITable::prepare方法的具体用法?C++ ITable::prepare怎么用?C++ ITable::prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable::prepare方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: histogramAsTable
ITable RasterCoverage::histogramAsTable()
{
std::vector<NumericStatistics::HistogramBin> hist;
if ( histogramCalculated())
hist = statistics().histogram();
else {
hist = statistics(ContainerStatistics<PIXVALUETYPE>::pHISTOGRAM).histogram();
}
int count = 0;
ITable histogram;
histogram.prepare();
histogram->addColumn("min", IDomain("value"), true);
histogram->addColumn("max", IDomain("value"), true);
histogram->addColumn("counts", IDomain("count"));
count = 0;
PIXVALUETYPE vstart = datadef().range<NumericRange>()->min();
if (hist.size() > 0) {
for (int i = 0; i < hist.size() - 1; ++i) {
auto& h = hist[i];
histogram->record(count, { vstart, h._limit, h._count });
vstart = h._limit;
++count;
}
}
return histogram;
}
示例2: loadBinaryData
bool FeatureConnector::loadBinaryData(Ilwis::IlwisObject *obj) {
if ( obj == nullptr)
return false;
FeatureCoverage *fcoverage = static_cast<FeatureCoverage *>(obj);
QString file = _odf->value("BaseMap", "AttributeTable");
ITable extTable;
if ( file != sUNDEF) {
if(!extTable.prepare(file)){
kernel()->issues()->log(file,TR(ERR_NO_INITIALIZED_1).arg(file),IssueObject::itWarning);
return false;
}
}
bool ok = false;
if (fcoverage->featureTypes() == itPOINT)
ok = loadBinaryPoints(fcoverage);
else if (fcoverage->featureTypes() == itLINE)
ok = loadBinarySegments(fcoverage);
else if (fcoverage->featureTypes() == itPOLYGON)
ok = loadBinaryPolygons(fcoverage);
if ( ok && extTable.isValid()) {
ITable attTbl = fcoverage->attributeTable();
quint32 keyIndex = attTbl->columnIndex(COVERAGEKEYCOLUMN);
for(quint32 rowExt=0; rowExt < extTable->records(); ++rowExt) {
vector<QVariant> rec = extTable->record(rowExt);
for(quint32 rowAtt = 0; rowAtt < attTbl->records(); ++rowAtt ) {
if ( attTbl->cell(keyIndex, rowAtt) == rowExt + 1) {
attTbl->record(rowAtt,rec);
}
}
}
}
return ok;
}
示例3: 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;
}
示例4: prepareAttributeTable
ITable CoverageConnector::prepareAttributeTable(const QString& file, const QString& basemaptype) const{
ITable extTable;
if ( file != sUNDEF) {
if(!extTable.prepare(file)){
kernel()->issues()->log(file,TR(ERR_NO_INITIALIZED_1).arg(file),IssueObject::itWarning);
return ITable();
}
}
IDomain covdom;
if (!covdom.prepare("count")){
return ITable();
}
ITable attTable;
if ( basemaptype != "Map" ) {
Resource resource(QUrl(QString("ilwis://internal/%1").arg(_odf->fileinfo().baseName())), itFLATTABLE);
if(!attTable.prepare(resource)) {
ERROR1(ERR_NO_INITIALIZED_1,resource.name());
return ITable();
}
if ( extTable.isValid()) {
for(int i=0; i < extTable->columns(); ++i) {
attTable->addColumn(extTable->columndefinition(i));
}
}
} else {
attTable = extTable;
}
if ( attTable->columnIndex(FEATUREIDCOLUMN) == iUNDEF) { // external tables might already have these
attTable->addColumn(COVERAGEKEYCOLUMN,covdom);
attTable->addColumn(FEATUREIDCOLUMN,covdom);
}
bool isNumeric = _odf->value("BaseMap","Range") != sUNDEF;
if ( isNumeric) {
IDomain featuredom;
if (!featuredom.prepare("value")){
return ITable();
}
attTable->addColumn(FEATUREVALUECOLUMN,featuredom);
}
return attTable;
}
示例5: loadMetaData
bool GdalFeatureConnector::loadMetaData(Ilwis::IlwisObject *data,const IOOptions& options){
if(!CoverageConnector::loadMetaData(data, options))
return false;
FeatureCoverage *fcoverage = static_cast<FeatureCoverage *>(data);
fcoverage->setFeatureCount(itFEATURE, iUNDEF, FeatureInfo::ALLFEATURES);
OGRLayerH hLayer = getLayerHandle();
if ( hLayer) {
//feature types
IlwisTypes type = translateOGRType(gdal()->getLayerGeometry(hLayer));
if (type == itUNKNOWN){
WARN(QString("Unknown feature type of layer %1 from: %2").arg(0).arg(_filename.toString()));
}else{
fcoverage->featureTypes(type);
}
//feature counts
int temp = gdal()->getFeatureCount(hLayer, FALSE);//TRUE to FORCE databases to scan whole layer, FALSe can end up in -1 for unknown result
if (temp == -1){
WARN(QString("Couldn't determine feature count of layer %1 from meta data of %2").arg(0).arg(_filename.toString()));
}else{
int featureCount = fcoverage->featureCount(type);
featureCount += temp;
fcoverage->setFeatureCount(type, featureCount,0); // subgeometries are not known at this level
}
//attribute table
ITable attTable;
Resource resource(_filename, itFLATTABLE);
if(!attTable.prepare(resource,{"asflattable", true})) {//will load whole meta data of the table
ERROR1(ERR_NO_INITIALIZED_1,resource.name());
return false;
}
fcoverage->setAttributes(attTable);
//layer envelopes/extents
Envelope bbox;
OGREnvelope envelope;//might sometimes be supported as 3D now only posssible from OGRGeometry
OGRErr err = gdal()->getLayerExtent(hLayer, &envelope , FALSE);//TRUE to FORCE
if (err != OGRERR_NONE){
if (err == OGRERR_FAILURE){//on an empty layer or if simply too expensive(FORECE=FALSE) OGR_L_GetExtent may return OGRERR_FAILURE
WARN(QString("Couldn't determine the extent of layer %1 from meta data of %2").arg(0).arg(_filename.toString()));
}else{
ERROR0(QString("Couldn't load extent of layer %1 from %2: %3").arg(0).arg(_filename.toString()).arg(gdal()->translateOGRERR(err)));
}
}else{
bbox = Envelope(Coordinate(envelope.MinX,envelope.MinY),Coordinate(envelope.MaxX,envelope.MaxY));
}
fcoverage->envelope(bbox);
// fcoverage->coordinateSystem()->envelope(bbox);
}
gdal()->closeFile(sourceRef().toLocalFile(), data->id());
return true;
}
示例6: loadData
bool FeatureConnector::loadData(Ilwis::IlwisObject *obj, const IOOptions &) {
if ( obj == nullptr)
return false;
FeatureCoverage *fcoverage = static_cast<FeatureCoverage *>(obj);
QString file = _odf->value("BaseMap", "AttributeTable");
ITable extTable;
if ( file != sUNDEF) {
if(!extTable.prepare(file)){
kernel()->issues()->log(file,TR(ERR_NO_INITIALIZED_1).arg(file),IssueObject::itWarning);
return false;
}
}
bool ok = false;
try {
_binaryIsLoaded = true; // to prevent any subsequent calls to this routine while loading (which mat trigger it).
if (fcoverage->featureTypes() == itPOINT)
ok = loadBinaryPoints(fcoverage);
else if (fcoverage->featureTypes() == itLINE)
ok = loadBinarySegments(fcoverage);
else if (fcoverage->featureTypes() == itPOLYGON)
ok = loadBinaryPolygons(fcoverage);
_binaryIsLoaded = ok;
if ( ok && extTable.isValid()) {
ITable attTbl = fcoverage->attributeTable();
quint32 nrAttrCols = std::min(attTbl->columnCount(),extTable->columnCount());
// quint32 keyIndex = extTable->columnIndex(COVERAGEKEYCOLUMN);
for(quint32 rowExt=0; rowExt < extTable->recordCount(); ++rowExt) {
if ( rowExt < fcoverage->featureCount()){
vector<QVariant> rec = extTable->record(rowExt);
rec.resize(nrAttrCols); // extTable received an extra "Domain" column, which is not there (and will not be there) in attTbl
attTbl->record(rowExt,rec);
}
}
}
} catch (FeatureCreationError& ) {
}
if ( ok)
_binaryIsLoaded = true;
return ok;
}
示例7: loadMetadata
bool PostgresqlFeatureCoverageLoader::loadMetadata(FeatureCoverage *fcoverage) const
{
//qDebug() << "PostgresqlFeatureCoverageLoader::loadMetadata()";
ITable featureTable;
if(!featureTable.prepare(_resource.url().toString(), itFLATTABLE, _options)) {
ERROR1(ERR_NO_INITIALIZED_1, _resource.name() + "[itFLATTABLE]");
return false;
}
setFeatureCount(fcoverage);
setSpatialMetadata(fcoverage);
fcoverage->attributesFromTable(featureTable);
IDomain semantics;
QList<MetaGeometryColumn> metaGeometries;
PostgresqlDatabaseUtil pgUtil(_resource,_options);
pgUtil.getMetaForGeometryColumns(metaGeometries);
pgUtil.prepareSubFeatureSemantics(semantics, metaGeometries);
setSubfeatureSemantics(fcoverage, semantics);
return true;
}