bool ImportWorker::runImport(int StartStep) { int i=0; bool OKToContinue = true; while (i<m_SourcesInfos.size() && OKToContinue) { OKToContinue = importLayer(StartStep+i,i); i++; } if (OKToContinue) OKToContinue = buildConnections(StartStep+m_SourcesInfos.size()+1); if (OKToContinue) OKToContinue = processFilesAndDatastore(StartStep+m_SourcesInfos.size()+2); return OKToContinue; }
void OgrFileImport::import(bool load_symbols_only) { auto file = qobject_cast<QFile*>(stream); if (!file) { throw FileFormatException("Internal error"); /// \todo Review design and/or message } auto filename = file->fileName(); // GDAL 2.0: ... = GDALOpenEx(template_path.toLatin1(), GDAL_OF_VECTOR, nullptr, nullptr, nullptr); auto data_source = ogr::unique_datasource(OGROpen(filename.toLatin1(), 0, nullptr)); if (data_source == nullptr) { throw FileFormatException(Importer::tr("Could not read '%1'") .arg(filename)); } empty_geometries = 0; no_transformation = 0; failed_transformation = 0; unsupported_geometry_type = 0; too_few_coordinates = 0; importStyles(data_source.get()); if (!load_symbols_only) { auto num_layers = OGR_DS_GetLayerCount(data_source.get()); for (int i = 0; i < num_layers; ++i) { auto layer = OGR_DS_GetLayer(data_source.get(), i); if (!layer) { addWarning(tr("Unable to load layer %1.").arg(i)); continue; } auto part = map->getCurrentPart(); if (option(QLatin1String("Separate layers")).toBool()) { if (num_layers > 0) { if (part->getNumObjects() == 0) { part->setName(OGR_L_GetName(layer)); } else { part = new MapPart(OGR_L_GetName(layer), map); auto index = map->getNumParts(); map->addPart(part, index); map->setCurrentPartIndex(index); } } } importLayer(part, layer); } } if (empty_geometries) { addWarning(tr("Unable to load %n objects, reason: %1", nullptr, empty_geometries) .arg(tr("Empty geometry."))); } if (no_transformation) { addWarning(tr("Unable to load %n objects, reason: %1", nullptr, no_transformation) .arg(tr("Can't determine the coordinate transformation: %1").arg(CPLGetLastErrorMsg()))); } if (failed_transformation) { addWarning(tr("Unable to load %n objects, reason: %1", nullptr, failed_transformation) .arg(tr("Failed to transform the coordinates."))); } if (unsupported_geometry_type) { addWarning(tr("Unable to load %n objects, reason: %1", nullptr, unsupported_geometry_type) .arg(tr("Unknown or unsupported geometry type."))); } if (too_few_coordinates) { addWarning(tr("Unable to load %n objects, reason: %1", nullptr, too_few_coordinates) .arg(tr("Not enough coordinates."))); } }