MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / ExportDataSource

Method ExportDataSource

ShapeOperations/OGRDataAdapter.cpp:282–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282OGRLayerProxy*
283OGRDataAdapter::ExportDataSource(const wxString& o_ds_format,
284 const wxString& o_ds_name,
285 const wxString& o_layer_name,
286 OGRwkbGeometryType geom_type,
287 std::vector<OGRGeometry*> ogr_geometries,
288 TableInterface* table,
289 std::vector<int>& selected_rows,
290 OGRSpatialReference* spatial_ref,
291 bool is_update,
292 wxString cpg_encode)
293{
294 wxLogMessage("In OGRDataAdapter::ExportDataSource()");
295 GdaConst::DataSourceType ds_type = IDataSource::FindDataSourceType(o_ds_format);
296
297 // field identifier: a pair value <column pos, time step> to indicate how to
298 // retreive real field name and cell value for time-enabled table
299 typedef std::pair<int, int> field_idn;
300 std::vector<field_idn> field_idn_s;
301 std::vector<wxString> field_name_s;
302 // check field names first
303 if ( table != NULL ) {
304 // get all field names for FieldNameCorrectionDlg
305 std::vector<wxString> all_fnames;
306 int time_steps = table->GetTimeSteps();
307 for ( int id=0; id < table->GetNumberCols(); id++ ) {
308 if (table->IsColTimeVariant(id)) {
309 for ( int t=0; t < time_steps; t++ ) {
310 wxString fname = table->GetColName(id, t);
311 if (fname.IsEmpty()) {
312 wxString msg;
313 msg << "Field name is empty at position: " << id << " and time " << t;
314 throw GdaException(msg.mb_str(),
315 GdaException::FIELD_NAME_EMPTY);
316 }
317 all_fnames.push_back(fname);
318 field_idn_s.push_back(std::make_pair(id, t));
319 field_name_s.push_back(fname);
320 }
321 } else {
322 wxString fname = table->GetColName(id);
323 if (fname.IsEmpty()) {
324 wxString msg;
325 msg << "Field name is empty at position: " << id ;
326 throw GdaException(msg.mb_str(),
327 GdaException::FIELD_NAME_EMPTY);
328 }
329 all_fnames.push_back(fname);
330 field_idn_s.push_back(std::make_pair(id, 0));
331 field_name_s.push_back(fname);
332 }
333 }
334
335 // try to correct
336 FieldNameCorrectionDlg fname_correct_dlg(ds_type, all_fnames);
337 if ( fname_correct_dlg.NeedCorrection()) {
338 if (fname_correct_dlg.ShowModal() != wxID_OK) {
339 // cancel at Field Name Correction

Callers 2

SaveDataSourceAsMethod · 0.80
CreateOGRLayerMethod · 0.80

Calls 11

GdaExceptionClass · 0.85
NeedCorrectionMethod · 0.80
RenameSimpleColMethod · 0.80
GetTimeStepsMethod · 0.45
GetNumberColsMethod · 0.45
IsColTimeVariantMethod · 0.45
GetColNameMethod · 0.45
IsEmptyMethod · 0.45
GetNewFieldNamesMethod · 0.45
sizeMethod · 0.45
CreateLayerMethod · 0.45

Tested by

no test coverage detected