本文整理汇总了C++中Error_Set函数的典型用法代码示例。如果您正苦于以下问题:C++ Error_Set函数的具体用法?C++ Error_Set怎么用?C++ Error_Set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Error_Set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Error_Set
bool Cdodproperror::SaveGridsAsTIFF(CSG_Grid** grids, CSG_Strings paths)
{
TSG_Data_Type Type;
CSG_String FilePath;
CSG_Grid* Grid;
// SAVE TIFFS
for (int i = 0; i < paths.Get_Count(); i++)
{
FilePath = paths[i];
Grid = grids[i];
Type = Grid->Get_Type();
if( !GDALDataSet.Open_Write(FilePath, GDALDriver, GDALOptions, Type, 1, *Get_System(), Projection) )
{
Error_Set(CSG_String::Format(SG_T("%s: '%s' "), _TL("Failed to open file for writing: "), FilePath.c_str()));
return( false );
}
GDALDataSet.Write(0, Grid);
if( !GDALDataSet.Close() )
{
Error_Set(CSG_String::Format(SG_T("%s: '%s' "), _TL("Failed to close file after writing: "), FilePath.c_str()));
return( false );
}
}
return true;
}
示例2: Parameters
//---------------------------------------------------------
bool CPolygon_Geometrics::On_Execute(void)
{
//-------------------------------------------------
int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1;
int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1;
int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1;
int bArea = Parameters("BAREA") ->asBool() ? 0 : -1;
if( bParts && bPoints && bLength && bArea )
{
Error_Set(_TL("no properties selected"));
return( false );
}
//-------------------------------------------------
CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes();
if( !pPolygons->is_Valid() || pPolygons->Get_Count() <= 0 )
{
Error_Set(_TL("invalid lines layer"));
return( false );
}
if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pPolygons )
{
pPolygons = Parameters("OUTPUT")->asShapes();
pPolygons->Create(*Parameters("POLYGONS")->asShapes());
}
//-------------------------------------------------
if( !bParts ) { bParts = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); }
if( !bPoints ) { bPoints = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPOINTS") , SG_DATATYPE_Int ); }
if( !bLength ) { bLength = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("PERIMETER"), SG_DATATYPE_Double); }
if( !bArea ) { bArea = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("AREA") , SG_DATATYPE_Double); }
//-------------------------------------------------
for(int i=0; i<pPolygons->Get_Count() && Set_Progress(i, pPolygons->Get_Count()); i++)
{
CSG_Shape *pPolygon = pPolygons->Get_Shape(i);
if( bParts >= 0 ) pPolygon->Set_Value(bParts , pPolygon->Get_Part_Count());
if( bPoints >= 0 ) pPolygon->Set_Value(bPoints, pPolygon->Get_Point_Count());
if( bLength >= 0 ) pPolygon->Set_Value(bLength, ((CSG_Shape_Polygon *)pPolygon)->Get_Perimeter());
if( bArea >= 0 ) pPolygon->Set_Value(bArea , ((CSG_Shape_Polygon *)pPolygon)->Get_Area());
}
//-------------------------------------------------
if( pPolygons == Parameters("POLYGONS")->asShapes() )
{
DataObject_Update(pPolygons);
}
return( true );
}
示例3: Parameters
//---------------------------------------------------------
bool CLine_Properties::On_Execute(void)
{
//-------------------------------------------------
int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1;
int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1;
int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1;
if( bParts && bPoints && bLength )
{
Error_Set(_TL("no properties selected"));
return( false );
}
//-------------------------------------------------
CSG_Shapes *pLines = Parameters("LINES")->asShapes();
if( !pLines->is_Valid() || pLines->Get_Count() <= 0 )
{
Error_Set(_TL("invalid lines layer"));
return( false );
}
if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pLines )
{
pLines = Parameters("OUTPUT")->asShapes();
pLines->Create(*Parameters("LINES")->asShapes());
}
//-------------------------------------------------
if( !bParts ) { bParts = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); }
if( !bPoints ) { bPoints = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPOINTS"), SG_DATATYPE_Int ); }
if( !bLength ) { bLength = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("LENGTH") , SG_DATATYPE_Double); }
//-------------------------------------------------
for(int i=0; i<pLines->Get_Count() && Set_Progress(i, pLines->Get_Count()); i++)
{
CSG_Shape *pLine = pLines->Get_Shape(i);
if( bParts >= 0 ) pLine->Set_Value(bParts , pLine->Get_Part_Count());
if( bPoints >= 0 ) pLine->Set_Value(bPoints, pLine->Get_Point_Count());
if( bLength >= 0 ) pLine->Set_Value(bLength, ((CSG_Shape_Line *)pLine)->Get_Length());
}
//-------------------------------------------------
if( pLines == Parameters("LINES")->asShapes() )
{
DataObject_Update(pLines);
}
return( true );
}
示例4: Parameters
//---------------------------------------------------------
bool COGR_Export_KML::On_Execute(void)
{
CSG_Shapes Shapes, *pShapes = Parameters("SHAPES")->asShapes();
//-----------------------------------------------------
if( pShapes->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined )
{
Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates"));
}
else if( pShapes->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic )
{
Message_Fmt("\n%s (%s: %s)\n", _TL("re-projection to geographic coordinates"), _TL("original"), pShapes->Get_Projection().Get_Name().c_str());
bool bResult;
SG_RUN_TOOL(bResult, "pj_proj4", 2,
SG_TOOL_PARAMETER_SET("SOURCE" , pShapes)
&& SG_TOOL_PARAMETER_SET("TARGET" , &Shapes)
&& SG_TOOL_PARAMETER_SET("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84"))
);
if( bResult )
{
pShapes = &Shapes;
Message_Fmt("\n%s: %s\n", _TL("re-projection"), _TL("success"));
}
else
{
Message_Fmt("\n%s: %s\n", _TL("re-projection"), _TL("failed" ));
}
}
//-----------------------------------------------------
CSG_OGR_DataSet DataSource;
if( !DataSource.Create(Parameters("FILE")->asString(), "KML") )
{
Error_Set(_TL("KML file creation failed"));
return( false );
}
if( !DataSource.Write(pShapes) )
{
Error_Set(_TL("failed to store data"));
return( false );
}
return( true );
}
示例5: Parameters
//---------------------------------------------------------
bool CFilter_Resample::On_Execute(void)
{
double Cellsize;
CSG_Grid *pGrid, *pLoPass, *pHiPass;
//-----------------------------------------------------
pGrid = Parameters("GRID" )->asGrid();
pLoPass = Parameters("LOPASS")->asGrid();
pHiPass = Parameters("HIPASS")->asGrid();
Cellsize = Parameters("SCALE" )->asDouble() * Get_Cellsize();
//-----------------------------------------------------
if( Cellsize > 0.5 * SG_Get_Length(Get_System()->Get_XRange(), Get_System()->Get_YRange()) )
{
Error_Set(_TL("resampling cell size is too large"));
return( false );
}
//-----------------------------------------------------
CSG_Grid Grid(CSG_Grid_System(Cellsize, Get_XMin(), Get_YMin(), Get_XMax(), Get_YMax()), SG_DATATYPE_Float);
Grid.Assign(pGrid, GRID_RESAMPLING_Mean_Cells);
//-----------------------------------------------------
pLoPass->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Low Pass")));
pHiPass->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("High Pass")));
CSG_Colors Colors;
DataObject_Get_Colors(pGrid , Colors);
DataObject_Set_Colors(pLoPass, Colors);
DataObject_Set_Colors(pHiPass, 11, SG_COLORS_RED_GREY_BLUE);
//-----------------------------------------------------
for(int y=0; y<Get_NY() && Set_Progress(y); y++)
{
double py = Get_YMin() + y * Get_Cellsize();
#pragma omp parallel for
for(int x=0; x<Get_NX(); x++)
{
double z, px = Get_XMin() + x * Get_Cellsize();
if( !pGrid->is_NoData(x, y) && Grid.Get_Value(px, py, z) )
{
pLoPass->Set_Value(x, y, z);
pHiPass->Set_Value(x, y, pGrid->asDouble(x, y) - z);
}
else
{
pLoPass->Set_NoData(x, y);
pHiPass->Set_NoData(x, y);
}
}
}
//-----------------------------------------------------
return( true );
}
示例6: Parameters
//---------------------------------------------------------
bool CGeoref_Grid::On_Execute(void)
{
CSG_Shapes *pShapes_A = Parameters("REF_SOURCE")->asShapes();
CSG_Shapes *pShapes_B = Parameters("REF_TARGET")->asShapes();
int xField = Parameters("XFIELD")->asInt();
int yField = Parameters("YFIELD")->asInt();
//-----------------------------------------------------
if( ( pShapes_B && m_Engine.Set_Reference(pShapes_A, pShapes_B))
|| (!pShapes_B && m_Engine.Set_Reference(pShapes_A, xField, yField)) )
{
int Method = Parameters("METHOD")->asInt();
int Order = Parameters("ORDER" )->asInt();
if( m_Engine.Evaluate(Method, Order) && Get_Conversion() )
{
m_Engine.Destroy();
return( true );
}
}
//-----------------------------------------------------
if( !m_Engine.Get_Error().is_Empty() )
{
Error_Set(m_Engine.Get_Error());
}
m_Engine.Destroy();
return( false );
}
示例7: Parameters
//---------------------------------------------------------
bool CCost_Accumulated::On_Execute(void)
{
//-----------------------------------------------------
m_pCost = Parameters("COST" )->asGrid();
m_pAccumulated = Parameters("ACCUMULATED")->asGrid();
m_pAllocation = Parameters("ALLOCATION" )->asGrid();
m_pDirection = Parameters("DIR_MAXCOST")->asGrid();
m_bDegree = Parameters("DIR_UNIT" )->asInt() == 1;
m_dK = Parameters("DIR_K" )->asDouble();
//-----------------------------------------------------
CPoints Points;
if( !Get_Destinations(Points) )
{
Error_Set(_TL("no destination points in grid area."));
return( false );
}
//-----------------------------------------------------
Get_Cost(Points);
Get_Allocation();
//-----------------------------------------------------
return( true );
}
示例8: On_Execute
//---------------------------------------------------------
bool CShapes_SRID_Update::On_Execute(void)
{
if( !Get_Connection()->has_PostGIS() ) { Error_Set(_TL("no PostGIS layer")); return( false ); }
//-----------------------------------------------------
CSG_String Select;
CSG_Table Table;
Select.Printf(SG_T("f_table_name='%s'"), Parameters("TABLES")->asString());
if( !Get_Connection()->Table_Load(Table, "geometry_columns", "*", Select) || Table.Get_Count() != 1 )
{
return( false );
}
Select.Printf(SG_T("SELECT UpdateGeometrySRID('%s', '%s', %d)"),
Parameters("TABLES")->asString(),
Table[0].asString("f_geometry_column"),
Get_SRID()
);
//-----------------------------------------------------
if( !Get_Connection()->Execute(Select) )
{
return( false );
}
return( true );
}
示例9: Error_Set
//---------------------------------------------------------
bool CXYZ_Import::On_Execute(void)
{
CSG_File Stream;
if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R) )
{
Error_Set(_TL("file could not be opened"));
return( false );
}
//-----------------------------------------------------
CSG_Shapes *pPoints = Parameters("POINTS")->asShapes();
pPoints->Create(SHAPE_TYPE_Point, SG_File_Get_Name(Parameters("FILENAME")->asString(), false));
pPoints->Add_Field("Z", SG_DATATYPE_Double);
//-----------------------------------------------------
if( Parameters("HEADLINE")->asBool() )
{
CSG_String sLine;
if( !Stream.Read_Line(sLine) )
{
Error_Set(_TL("could not read headline"));
return( false );
}
}
//-----------------------------------------------------
sLong Length = Stream.Length();
double x, y, z;
while( Stream.Scan(x) && Stream.Scan(y) && Stream.Scan(z) && Set_Progress((double)Stream.Tell(), (double)Length) )
{
CSG_Shape *pPoint = pPoints->Add_Shape();
pPoint->Add_Point(x, y);
pPoint->Set_Value(0, z);
}
return( pPoints->Get_Count() > 0 );
}
示例10: Parameters
//---------------------------------------------------------
bool CLines_From_Polygons::On_Execute(void)
{
CSG_Shapes *pLines, *pPolygons;
pPolygons = Parameters("POLYGONS") ->asShapes();
pLines = Parameters("LINES") ->asShapes();
//-----------------------------------------------------
if( pPolygons->Get_Count() <= 0 )
{
Error_Set(_TL("no polygons in input"));
return( false );
}
//-----------------------------------------------------
pLines->Create(SHAPE_TYPE_Line, pPolygons->Get_Name(), pPolygons, pPolygons->Get_Vertex_Type());
for(int iPolygon=0; iPolygon<pPolygons->Get_Count(); iPolygon++)
{
CSG_Shape *pPolygon = pPolygons ->Get_Shape(iPolygon);
CSG_Shape *pLine = pLines ->Add_Shape(pPolygon, SHAPE_COPY_ATTR);
for(int iPart=0; iPart<pPolygon->Get_Part_Count(); iPart++)
{
for(int iPoint=0; iPoint<pPolygon->Get_Point_Count(iPart); iPoint++)
{
pLine->Add_Point(pPolygon->Get_Point(iPoint, iPart), iPart);
if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY )
{
pLine->Set_Z(pPolygon->Get_Z(iPoint, iPart), iPoint, iPart);
if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM )
{
pLine->Set_M(pPolygon->Get_M(iPoint, iPart), iPoint, iPart);
}
}
}
if( !CSG_Point(pPolygon->Get_Point(0, iPart)).is_Equal(pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart)) )
{
pLine->Add_Point(pPolygon->Get_Point(0, iPart), iPart);
if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY )
{
pLine->Set_Z(pPolygon->Get_Z(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart);
if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM )
{
pLine->Set_M(pPolygon->Get_M(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart);
}
}
}
}
}
return( true );
}
示例11: Error_Set
static const char *Heap_testSuite()
{
Error_Set(S_OK);
mu_run_test(Heap_Construct_test);
mu_run_test(Heap_Alloc_test);
mu_run_test(Heap_Alloc_test_NoHeap);
return NULL;
}
示例12: Parameters
//---------------------------------------------------------
bool CTable_PCA::On_Execute(void)
{
CSG_Vector Eigen_Values;
CSG_Matrix Eigen_Vectors, Matrix;
//-----------------------------------------------------
m_pTable = Parameters("TABLE") ->asTable();
m_Method = Parameters("METHOD") ->asInt();
//-----------------------------------------------------
if( !Get_Fields() )
{
Error_Set(_TL("invalid field selection"));
SG_FREE_SAFE(m_Features);
return( false );
}
if( !Get_Matrix(Matrix) )
{
Error_Set(_TL("matrix initialisation failed"));
SG_FREE_SAFE(m_Features);
return( false );
}
if( !SG_Matrix_Eigen_Reduction(Matrix, Eigen_Vectors, Eigen_Values) )
{
Error_Set(_TL("Eigen reduction failed"));
SG_FREE_SAFE(m_Features);
return( false );
}
//-----------------------------------------------------
Get_Components(Eigen_Vectors, Eigen_Values);
//-----------------------------------------------------
SG_FREE_SAFE(m_Features);
return( true );
}
示例13: Parameters
//---------------------------------------------------------
bool CGrids_Product::On_Execute(void)
{
//-----------------------------------------------------
CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS" )->asGridList();
if( pGrids->Get_Count() < 1 )
{
Error_Set(_TL("no grid in list"));
return( false );
}
//-----------------------------------------------------
CSG_Grid *pResult = Parameters("RESULT")->asGrid();
bool bNoData = Parameters("NODATA")->asBool();
//-----------------------------------------------------
for(int y=0; y<Get_NY() && Set_Progress(y); y++)
{
#pragma omp parallel for
for(int x=0; x<Get_NX(); x++)
{
int n = 0;
double d = 0.0;
for(int i=0; i<pGrids->Get_Count(); i++)
{
if( pGrids->asGrid(i)->is_InGrid(x, y) )
{
if( n++ < 1 )
{
d = pGrids->asGrid(i)->asDouble(x, y);
}
else
{
d *= pGrids->asGrid(i)->asDouble(x, y);
}
}
}
if( bNoData ? n > 0 : n == pGrids->Get_Count() )
{
pResult->Set_Value(x, y, d);
}
else
{
pResult->Set_NoData(x, y);
}
}
}
//-----------------------------------------------------
return( true );
}
示例14: Error_Set
//---------------------------------------------------------
bool CGrid_Classify_Supervised::On_Execute(void)
{
//-----------------------------------------------------
if( !Get_Features() )
{
Error_Set(_TL("invalid features"));
return( false );
}
//-----------------------------------------------------
CSG_Classifier_Supervised Classifier;
if( !Set_Classifier(Classifier) )
{
return( false );
}
//-----------------------------------------------------
CSG_Grid *pClasses = Parameters("CLASSES")->asGrid();
CSG_Grid *pQuality = Parameters("QUALITY")->asGrid();
pClasses->Set_NoData_Value(0);
pClasses->Assign(0.0);
//-----------------------------------------------------
Process_Set_Text(_TL("prediction"));
int Method = Parameters("METHOD")->asInt();
for(int y=0; y<Get_NY() && Set_Progress(y); y++)
{
#pragma omp parallel for
for(int x=0; x<Get_NX(); x++)
{
int Class;
double Quality;
CSG_Vector Features(m_pFeatures->Get_Count());
if( Get_Features(x, y, Features) && Classifier.Get_Class(Features, Class, Quality, Method) )
{
SG_GRID_PTR_SAFE_SET_VALUE(pClasses, x, y, 1 + Class);
SG_GRID_PTR_SAFE_SET_VALUE(pQuality, x, y, Quality );
}
else
{
SG_GRID_PTR_SAFE_SET_NODATA(pClasses, x, y);
SG_GRID_PTR_SAFE_SET_NODATA(pQuality, x, y);
}
}
}
//-----------------------------------------------------
return( Set_Classification(Classifier) );
}
示例15: Parameters
//---------------------------------------------------------
bool CSelect_Points::On_Execute(void)
{
//-----------------------------------------------------
m_pPoints = Parameters("POINTS") ->asShapes();
m_pSelection = Parameters("SELECTION") ->asShapes();
m_Radius = Parameters("RADIUS") ->asDouble();
m_MaxPoints = Parameters("MAXNUM") ->asInt();
m_Quadrant = Parameters("QUADRANT") ->asInt() - 1;
m_bAddCenter = Parameters("ADDCENTER") ->asBool();
//-----------------------------------------------------
if( !m_pPoints->is_Valid() )
{
Error_Set(_TL("invalid points layer"));
return( false );
}
if( m_pPoints->Get_Count() <= 0 )
{
Error_Set(_TL("no points in layer"));
return( false );
}
if( !m_Search.Create(m_pPoints, -1) )
{
Error_Set(_TL("failed to initialise search engine"));
return( false );
}
//-----------------------------------------------------
m_pSelection->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_pPoints->Get_Name(), _TL("Selection")), m_pPoints);
m_pSelection->Add_Field(_TL("Order") , SG_DATATYPE_Int);
m_pSelection->Add_Field(_TL("Distance") , SG_DATATYPE_Double);
//-----------------------------------------------------
return( true );
}