iobjectscpp win10 x64
在使用点数据集生成线数据集时候程序异常退出,但是下次打开时候线存在。
UGDatasetVector * dataset = (UGDatasetVector *) m_pWorkspace ->GetDataSource(0)->GetDataset (_U("Tower_R"));
dataset->Open();
UGQueryDef query = UGQueryDef();
UGRecordset* recordset = dataset->Query(query);
recordset->MoveFirst();
UGDatasetVectorInfo* info = new UGDatasetVectorInfo();
info ->m_nType = UGC ::UGDataset ::DatasetType::Line;
QString str_name = "Design_L";
UGString result = Translator::QStr2UGStr(str_name);
UGString name = m_pWorkspace ->GetDataSource(0)->GetUnoccupiedDatasetName(result);
if(name != result)
m_pWorkspace ->GetDataSource(0)->DeleteDataset(result);
info ->m_strName = result ;
info ->m_strTableName = result ;
UGDatasetVector * newDataset = m_pWorkspace ->GetDataSource(0)->CreateDatasetVector(*info);
newDataset->Open();
if(info)
{
delete info;
info = nullptr;
}
UGQueryDef query1 = UGQueryDef();
UGRecordset *re = newDataset->Query(query1);
UGGeoLine *line_1 = new UGGeoLine();
UGGeoLine *line_2 = new UGGeoLine();
UGPoint2D *points_1 = new UGPoint2D[];
UGPoint2D *points_2 = new UGPoint2D[];
int j = 0;
for (int i = 0; i < recordset->GetRecordCount(); i++)
{
recordset->MoveTo(i);
UGGeometry * pTempGeomtry = nullptr;
recordset->GetGeometry(pTempGeomtry);
UGGeoRegion * pPoint = dynamic_cast<UGGeoRegion*>(pTempGeomtry);
if(j == 0)
{
points_1[0] = pPoint->GetInnerPoint();
if(i > 0)
points_2[1] = pPoint->GetInnerPoint();
}
if(j == 1)
{
points_1[1] = pPoint->GetInnerPoint();
points_2[0] = pPoint->GetInnerPoint();
}
j++;
if(j == 2)
{
j = 0;
line_1->AddSub(points_1,2);
re->AddNew(line_1);
re->Update();
}
if(i > 1 && j == 1)
{
line_2->AddSub(points_2,2);
re->AddNew(line_2);
re->Update();
}
}
if(line_1 != nullptr)
{
delete line_1;
line_1 = nullptr;
}
if(line_2 != nullptr)
{
delete line_2;
line_2 = nullptr;
}
points_1 = nullptr;
points_2 = nullptr;
UGLayer *lay = m_pMap->m_Layers.AddDataset(newDataset);
m_pMap->m_Layers.MoveTo(0, 5);
UGStyle sty_L = UGStyle();
sty_L.SetLineColor(85735);
sty_L.SetLineWidth(0.3);
lay->SetStyle(sty_L);
qMapControl->Refresh();
依然不行