//--------------------------------------------------------- bool CWKSP_Project::_Compatibility_Data(TSG_Data_Type Type, CSG_Parameters *pParameters, const CSG_String &Version) { if( !pParameters ) { return( false ); } if( !Version.Cmp(SAGA_VERSION) ) { return( true ); } //----------------------------------------------------- if( Version.is_Empty() ) { CSG_Parameter *pParameter; if( Type == SG_DATAOBJECT_TYPE_Grid ) { if( (pParameter = pParameters->Get_Parameter("COLORS_TYPE")) != NULL ) { if( pParameter->asInt() == 3 ) { // 0:Single >> 1:LUT >> 2:Discrete >> 3:Graduated >> 4:RGB Overlay >> 5:RGB Composite >> 6:Shade pParameter->Set_Value(5); // RGB moved to position 5 } } } } return( true ); }
//--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Exists(const CSG_String &Table_Name) const { if( is_Connected() ) { try { otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database. while( !Stream.eof() ) { std_string Catalog, Schema, Table, Type, Remarks; Stream >> Catalog >> Schema >> Table >> Type >> Remarks; if( !Table_Name.Cmp(CSG_String(Table.c_str())) ) { return( true ); } } } catch( otl_exception &e ) { _Error_Message(e); } } return( false ); }
//--------------------------------------------------------- bool CSG_mRMR::Set_Data(CSG_Table &Data, int ClassField, double Threshold) { if( !Get_Memory(Data.Get_Field_Count(), Data.Get_Count()) ) { return( false ); } //----------------------------------------------------- if( ClassField < 0 || ClassField >= m_nVars ) { ClassField = 0; } Data.Set_Index(ClassField, TABLE_INDEX_Ascending); CSG_String s; for(int iSample=0, Class=0; iSample<m_nSamples; iSample++) { double *pData = m_Samples[iSample] = m_Samples[0] + iSample * m_nVars; if( s.Cmp(Data[iSample].asString(ClassField)) ) { s = Data[iSample].asString(ClassField); Class++; } *pData++ = Class; for(int iVar=0; iVar<m_nVars; iVar++) { if( iVar != ClassField ) { *pData++ = Data[iSample].asDouble(iVar); } } } Data.Del_Index(); m_VarNames += Data.Get_Field_Name(ClassField); for(int iVar=0; iVar<m_nVars; iVar++) { if( iVar != ClassField ) { m_VarNames += Data.Get_Field_Name(iVar); } } //----------------------------------------------------- if( Threshold >= 0.0 ) // discretization { Discretize(Threshold); } return( true ); }
//--------------------------------------------------------- bool CWKSP_Project::_Compatibility_Load_Data(const wxString &FileName) { CSG_String sLine; CSG_File Stream; if( !Stream.Open(&FileName, SG_FILE_R, true) ) { return( false ); } //------------------------------------------------- while( Stream.Read_Line(sLine) && sLine.Cmp(DATA_ENTRIES_BEGIN) ); if( sLine.Cmp(DATA_ENTRIES_BEGIN) ) { return( false ); } g_pSAGA_Frame->Freeze(); g_pData->Get_Menu_Files()->Set_Update(false); while( _Compatibility_Load_Data(Stream, SG_File_Get_Path(&FileName).w_str()) ); g_pData->Get_Menu_Files()->Set_Update(true); //------------------------------------------------- while( Stream.Read_Line(sLine) && sLine.Cmp(MAP_ENTRIES_BEGIN) ); if( !sLine.Cmp(MAP_ENTRIES_BEGIN) ) { while( _Compatibility_Load_Map(Stream, SG_File_Get_Path(&FileName).w_str()) ); } switch( g_pData->Get_Parameter("PROJECT_MAP_ARRANGE")->asInt() ) { case 1: g_pSAGA_Frame->Tile(wxHORIZONTAL); break; case 2: g_pSAGA_Frame->Tile(wxVERTICAL ); break; } g_pSAGA_Frame->Thaw(); return( true ); }
//--------------------------------------------------------- bool CTable_Enumerate::On_Execute(void) { int iField, iField_ID, iID, iRecord, old_Field; TSG_Table_Index_Order old_Order; CSG_String Value; CSG_Table *pTable, *pOutput; CSG_Table_Record *pRecord; //----------------------------------------------------- pTable = Parameters("INPUT") ->asTable(); pOutput = Parameters("OUTPUT") ->asTable(); iField = Parameters("FIELD") ->asInt(); //----------------------------------------------------- if( iField >= 0 && iField < pTable->Get_Field_Count() && pTable->Get_Record_Count() > 0 ) { if( pOutput != NULL && pOutput != pTable ) { pOutput->Create (*pTable); pOutput->Set_Name ( pTable->Get_Name()); pTable = pOutput; } //------------------------------------------------- pTable->Add_Field(_TL("ENUM_ID"), SG_DATATYPE_Int); iField_ID = pTable->Get_Field_Count() - 1; old_Order = pTable->Get_Index_Order(0); old_Field = pTable->Get_Index_Field(0); pTable->Set_Index(iField, TABLE_INDEX_Descending); Value = pTable->Get_Record_byIndex(0)->asString(iField); for(iRecord=0, iID=1; iRecord<pTable->Get_Record_Count(); iRecord++) { pRecord = pTable->Get_Record_byIndex(iRecord); if( Value.Cmp(pRecord->asString(iField)) ) { Value = pRecord->asString(iField); iID++; } pRecord->Set_Value(iField_ID, iID); } pTable->Set_Index(old_Field, old_Order); return( true ); } return( false ); }
//--------------------------------------------------------- inline bool CDXF_Import::Check_Layer(const CSG_String &Name) { Check_Process(); switch( m_Filter ) { case 1: return( Name.Cmp(SG_T("0")) != 0 ); case 2: return( Name.Cmp(SG_T("0")) == 0 ); } return( true ); }
//--------------------------------------------------------- bool PGSQL_is_Connected (const CSG_String &Server) { CSG_Table Connections; RUN_MODULE(DB_PGSQL_Get_Connections, false, SET_PARAMETER("CONNECTIONS", &Connections)); // CGet_Connections for(int i=0; bResult && i<Connections.Get_Count(); i++) { if( !Server.Cmp(Connections[i].asString(0)) ) { return( true ); } } return( false ); }
//--------------------------------------------------------- bool CShapes_Split_by_Attribute::On_Execute(void) { int iField; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); iField = Parameters("FIELD") ->asInt(); Parameters("CUTS")->asTableList()->Del_Items(); //----------------------------------------------------- if( pTable->is_Valid() && pTable->Set_Index(iField, TABLE_INDEX_Ascending) ) { CSG_String sValue; CSG_Table *pCut = NULL; for(int iRecord=0; iRecord<pTable->Get_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(iRecord); if( !pCut || sValue.Cmp(pRecord->asString(iField)) ) { pCut = pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ? SG_Create_Shapes(((CSG_Shapes *)pTable)->Get_Type(), SG_T(""), pTable) : SG_Create_Table(pTable); pCut->Set_Name(CSG_String::Format(SG_T("%s [%s = %s]"), pTable->Get_Name(), pTable->Get_Field_Name(iField), pRecord->asString(iField) )); Parameters("CUTS")->asTableList()->Add_Item(pCut); sValue = pRecord->asString(iField); } pCut->Add_Record(pRecord); } return( pCut != NULL ); } return( false ); }
//--------------------------------------------------------- bool CChange_Detection::Get_Changes(CSG_Table &Initial, CSG_Table &Final, CSG_Table *pChanges, CSG_Matrix &Identity) { int iInitial, iFinal; //----------------------------------------------------- Identity.Create(Final.Get_Count() + 1, Initial.Get_Count() + 1); for(iInitial=0; iInitial<Initial.Get_Count(); iInitial++) { CSG_String s = Initial[iInitial].asString(CLASS_NAM); for(iFinal=0; iFinal<Final.Get_Count(); iFinal++) { Identity[iInitial][iFinal] = s.Cmp(Final[iFinal].asString(CLASS_NAM)) ? 0 : 1; } } Identity[Initial.Get_Count()][Final.Get_Count()] = 1; // unclassified //----------------------------------------------------- pChanges->Destroy(); pChanges->Add_Field(_TL("Name"), SG_DATATYPE_String); for(iFinal=0; iFinal<Final.Get_Count(); iFinal++) { pChanges->Add_Field(Final[iFinal].asString(CLASS_NAM), SG_DATATYPE_Double); } pChanges->Add_Field(_TL("Unclassified"), SG_DATATYPE_Double); //----------------------------------------------------- for(iInitial=0; iInitial<Initial.Get_Count(); iInitial++) { pChanges->Add_Record()->Set_Value(0, Initial[iInitial].asString(CLASS_NAM)); } pChanges->Add_Record()->Set_Value(0, _TL("Unclassified")); return( true ); }
//--------------------------------------------------------- int CDecision_Tree::Get_Class(CSG_Parameters *pDecision, const TSG_Point &Point) { double Value; CSG_Grid *pGrid = pDecision->Get_Parameter("GRID")->asGrid(); if( pGrid && pGrid->Get_Value(Point, Value) ) { CSG_String ID = pDecision->Get_Identifier(); if( !ID.Cmp(SG_T("ROOT")) ) ID.Clear(); ID += Value < pDecision->Get_Parameter("THRESHOLD")->asDouble() ? SG_T("A") : SG_T("B"); if( pDecision->Get_Parameter(ID + SG_T("|NODE"))->asBool() ) { return( Get_Class(pDecision->Get_Parameter(ID)->asParameters(), Point) ); } else { return( Get_Class(ID) ); } } return( -1 ); }
//--------------------------------------------------------- bool CPolygon_Dissolve::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() || pPolygons->Get_Count() < 2 ) { Error_Set(_TL("invalid or empty polygons layer")); return( false ); } //----------------------------------------------------- CSG_Shapes *pUnions = Parameters("DISSOLVED")->asShapes(); pUnions->Create(SHAPE_TYPE_Polygon); int Field_1 = Parameters("FIELD_1")->asInt(); int Field_2 = Parameters("FIELD_2")->asInt(); if( Field_1 < 0 ) Field_2 = -1; int Field_3 = Parameters("FIELD_3")->asInt(); if( Field_2 < 0 ) Field_3 = -1; if( Field_1 >= 0 ) { CSG_String s = pPolygons->Get_Field_Name(Field_1); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_1), pPolygons->Get_Field_Type(Field_1)); if( Field_2 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_2); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_2), pPolygons->Get_Field_Type(Field_2)); if( Field_3 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_3); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_3), pPolygons->Get_Field_Type(Field_3)); } } pPolygons->Set_Index(Field_1, TABLE_INDEX_Ascending, Field_2, TABLE_INDEX_Ascending, Field_3, TABLE_INDEX_Ascending); pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), s.c_str())); } else // if( Field_1 < 0 ) { pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), _TL("All"))); } Init_Statistics(pUnions, pPolygons); //----------------------------------------------------- CSG_String Value; CSG_Shape *pUnion = NULL; bool bDissolve = Parameters("BND_KEEP")->asBool() == false; //----------------------------------------------------- for(int iPolygon=0; iPolygon<pPolygons->Get_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(pPolygons->Get_Record_byIndex(iPolygon)->Get_Index()); CSG_String s; if( Field_1 >= 0 ) s = pPolygon->asString(Field_1); if( Field_2 >= 0 ) s += pPolygon->asString(Field_2); if( Field_3 >= 0 ) s += pPolygon->asString(Field_3); if( pUnion == NULL || (Field_1 >= 0 && Value.Cmp(s)) ) { Set_Union(pUnion, bDissolve); Value = s; pUnion = pUnions->Add_Shape(pPolygon, SHAPE_COPY_GEOM); if( Field_1 >= 0 ) pUnion->Set_Value(0, pPolygon->asString(Field_1)); if( Field_2 >= 0 ) pUnion->Set_Value(1, pPolygon->asString(Field_2)); if( Field_3 >= 0 ) pUnion->Set_Value(2, pPolygon->asString(Field_3)); Add_Statistics(pUnion, pPolygon, true); } else { for(int iPart=0; iPart<pPolygon->Get_Part_Count(); iPart++) { for(int iPoint=0, nParts=pUnion->Get_Part_Count(); iPoint<pPolygon->Get_Point_Count(iPart); iPoint++) { pUnion->Add_Point(pPolygon->Get_Point(iPoint, iPart), nParts); } } Add_Statistics(pUnion, pPolygon, false); } } Set_Union(pUnion, bDissolve); //----------------------------------------------------- if( m_Statistics ) { delete[](m_Statistics); } m_List.Clear(); return( pUnions->is_Valid() ); }
//--------------------------------------------------------- bool CSG_Shapes::Create(const CSG_String &File_Name) { Destroy(); SG_UI_Msg_Add(CSG_String::Format("%s: %s...", _TL("Load shapes"), File_Name.c_str()), true); //----------------------------------------------------- bool bResult = File_Name.BeforeFirst(':').Cmp("PGSQL") && SG_File_Exists(File_Name) && _Load_ESRI(File_Name); if( bResult ) { Set_File_Name(File_Name, true); } //----------------------------------------------------- else if( File_Name.BeforeFirst(':').Cmp("PGSQL") == 0 ) // database source { CSG_String s(File_Name); s = s.AfterFirst(':'); CSG_String Host (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Port (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String DBName(s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Table (s.BeforeFirst(':')); CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 0); // CGet_Connections if( pTool != NULL ) { SG_UI_ProgressAndMsg_Lock(true); //--------------------------------------------- CSG_Table Connections; CSG_String Connection = DBName + " [" + Host + ":" + Port + "]"; pTool->Settings_Push(); if( pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTIONS", &Connections) && pTool->Execute() ) // CGet_Connections { for(int i=0; !bResult && i<Connections.Get_Count(); i++) { if( !Connection.Cmp(Connections[i].asString(0)) ) { bResult = true; } } } pTool->Settings_Pop(); //--------------------------------------------- if( bResult && (bResult = (pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 20)) != NULL) == true ) // CPGIS_Shapes_Load { pTool->Settings_Push(); bResult = pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTION", Connection) && SG_TOOL_PARAMETER_SET("TABLES" , Table) && SG_TOOL_PARAMETER_SET("SHAPES" , this) && pTool->Execute(); pTool->Settings_Pop(); } SG_UI_ProgressAndMsg_Lock(false); } } //----------------------------------------------------- if( bResult ) { Set_Modified(false); Set_Update_Flag(); SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); return( true ); } for(int iShape=Get_Count()-1; iShape>=0; iShape--) // be kind, keep at least those shapes that have been loaded successfully { if( !Get_Shape(iShape)->is_Valid() ) { Del_Shape(iShape); } } if( Get_Count() <= 0 ) { Destroy(); } SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); return( false ); }
//--------------------------------------------------------- bool CGrid_Value_Replace::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pGrid = Parameters("OUTPUT")->asGrid(); if( !pGrid || pGrid == Parameters("INPUT")->asGrid() ) { pGrid = Parameters("INPUT")->asGrid(); } else { pGrid->Assign(Parameters("INPUT")->asGrid()); DataObject_Set_Parameters(pGrid, Parameters("INPUT")->asGrid()); pGrid->Fmt_Name("%s [%s]", Parameters("INPUT")->asGrid()->Get_Name(), _TL("Changed")); } //----------------------------------------------------- int Method = Parameters("METHOD")->asInt(); CSG_Table LUT; switch( Method ) { default: LUT.Create(*Parameters("IDENTITY")->asTable()); break; case 1: LUT.Create(*Parameters("RANGE" )->asTable()); break; case 2: LUT.Create( Parameters("RANGE" )->asTable()); if( SG_UI_Get_Window_Main() // gui only && DataObject_Get_Parameter(Parameters("GRID" )->asGrid(), "LUT") && DataObject_Get_Parameter(Parameters("INPUT")->asGrid(), "LUT") ) { CSG_Table LUTs[2]; LUTs[0].Create(*DataObject_Get_Parameter(Parameters("GRID" )->asGrid(), "LUT")->asTable()); LUTs[1].Create(*DataObject_Get_Parameter(Parameters("INPUT")->asGrid(), "LUT")->asTable()); for(int i=0; i<LUTs[0].Get_Count(); i++) { CSG_String Name = LUTs[0][i].asString(1); for(int j=LUTs[1].Get_Count()-1; j>=0; j--) { if( !Name.Cmp(LUTs[1][j].asString(1)) ) { CSG_Table_Record *pReplace = LUT.Add_Record(); pReplace->Set_Value(0, LUTs[0][i].asDouble(3)); pReplace->Set_Value(1, LUTs[1][j].asDouble(3)); pReplace->Set_Value(2, LUTs[1][j].asDouble(4)); LUTs[1].Del_Record(j); break; } } } for(int j=0; j<LUTs[1].Get_Count(); j++) { LUTs[0].Add_Record(LUTs[1].Get_Record(j)); } DataObject_Add(pGrid); CSG_Parameter *pLUT = DataObject_Get_Parameter(pGrid, "LUT"); pLUT->asTable()->Assign_Values(&LUTs[0]); DataObject_Set_Parameter(pGrid, pLUT); } break; } //----------------------------------------------------- if( LUT.Get_Count() == 0 ) { Error_Set(_TL("empty look-up table, nothing to replace")); return( false ); } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #ifndef _DEBUG #pragma omp parallel for #endif for(int x=0; x<Get_NX(); x++) { double Value = pGrid->asDouble(x, y); for(int i=0; i<LUT.Get_Count(); i++) { if( Method == 0 ) { if( LUT[i].asDouble(1) == Value ) { pGrid->Set_Value(x, y, LUT[i].asDouble(0)); break; } } else { if( LUT[i].asDouble(1) <= Value && Value <= LUT[i].asDouble(2) ) { pGrid->Set_Value(x, y, LUT[i].asDouble(0)); break; } } } } } //----------------------------------------------------- if( pGrid == Parameters("INPUT")->asGrid() ) { DataObject_Update(pGrid); } return( true ); }
//--------------------------------------------------------- bool CLine_Dissolve::On_Execute(void) { CSG_Shapes *pLines = Parameters("LINES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() < 2 ) { Error_Set(_TL("invalid or empty lines layer")); return( false ); } //----------------------------------------------------- CSG_Shapes *pDissolved = Parameters("DISSOLVED")->asShapes(); pDissolved->Create(SHAPE_TYPE_Line); CSG_Parameter_Table_Fields &Fields = *Parameters("FIELDS")->asTableFields(); CSG_Table Dissolve; //----------------------------------------------------- if( Fields.Get_Count() == 0 ) { pDissolved->Fmt_Name("%s [%s]", pLines->Get_Name(), _TL("Dissolved")); } else { Dissolve.Add_Field("INDEX", SG_DATATYPE_Int ); Dissolve.Add_Field("VALUE", SG_DATATYPE_String); Dissolve.Set_Record_Count(pLines->Get_Count()); for(int i=0; i<pLines->Get_Count() && Set_Progress(i, pLines->Get_Count()); i++) { CSG_Shape *pLine = pLines->Get_Shape(i); CSG_String Value; for(int iField=0; iField<Fields.Get_Count(); iField++) { Value += pLine->asString(Fields.Get_Index(iField)); } Dissolve[i].Set_Value(0, i); Dissolve[i].Set_Value(1, Value); } Dissolve.Set_Index(1, TABLE_INDEX_Ascending); //------------------------------------------------- CSG_String Name; for(int iField=0; iField<Fields.Get_Count(); iField++) { if( iField > 0 ) { Name += "; "; } Name += pLines->Get_Field_Name(Fields.Get_Index(iField)); pDissolved->Add_Field( pLines->Get_Field_Name(Fields.Get_Index(iField)), pLines->Get_Field_Type(Fields.Get_Index(iField)) ); } pDissolved->Fmt_Name("%s [%s: %s]", pLines->Get_Name(), _TL("Dissolved"), Name.c_str()); } //----------------------------------------------------- Statistics_Initialize(pDissolved, pLines); //----------------------------------------------------- CSG_String Value; CSG_Shape *pDissolve = NULL; for(int i=0; i<pLines->Get_Count() && Set_Progress(i, pLines->Get_Count()); i++) { CSG_Shape *pLine = pLines->Get_Shape(!Dissolve.Get_Count() ? i : Dissolve[i].asInt(0)); if( !pDissolve || (Dissolve.Get_Count() && Value.Cmp(Dissolve[i].asString(1))) ) { if( Dissolve.Get_Count() ) { Value = Dissolve[i].asString(1); } pDissolve = pDissolved->Add_Shape(pLine, SHAPE_COPY_GEOM); for(int iField=0; iField<Fields.Get_Count(); iField++) { *pDissolve->Get_Value(iField) = *pLine->Get_Value(Fields.Get_Index(iField)); } Statistics_Add(pDissolve, pLine, true); } else { Add_Line(pDissolve, pLine); Statistics_Add(pDissolve, pLine, false); } } //----------------------------------------------------- return( pDissolved->is_Valid() ); }
//--------------------------------------------------------- bool CTL_Extract::On_Execute(void) { //----------------------------------------------------- CSG_Table Elements; Elements.Add_Field(SG_T("TEXT"), SG_DATATYPE_String); Elements.Add_Field(SG_T("FILE"), SG_DATATYPE_String); int nFiles = Read_Directory(Parameters("DIRECTORY")->asString(), Elements); if( nFiles <= 0 ) { Error_Set(SG_T("no source code files found")); return( false ); } Message_Add(CSG_String::Format("\n%s: %d", SG_T("number of scanned files"), nFiles), false); if( Elements.Get_Count() <= 0 ) { Error_Set(SG_T("no translatable text elements found")); return( false ); } Message_Add(CSG_String::Format("\n%s: %d", SG_T("number of translatable elements"), Elements.Get_Count()), false); //----------------------------------------------------- Process_Set_Text(SG_T("collecting elements")); CSG_String Text; bool bLocation = Parameters("LOCATION" )->asBool(); CSG_Table *pTarget = Parameters("TARGET")->asTable(); pTarget->Destroy(); pTarget->Set_Name(SG_T("Translatable Elements")); pTarget->Add_Field("TEXT" , SG_DATATYPE_String); pTarget->Add_Field("TRANSLATION", SG_DATATYPE_String); if( bLocation ) { pTarget->Add_Field("FILE" , SG_DATATYPE_String); } Elements.Set_Index(0, TABLE_INDEX_Ascending); for(int i=0; i<Elements.Get_Count() && Set_Progress(i, Elements.Get_Count()); i++) { if( i == 0 || Text.Cmp(Elements.Get_Record_byIndex(i)->asString(0)) ) { Text = Elements.Get_Record_byIndex(i)->asString(0); CSG_Table_Record *pRecord = pTarget->Add_Record(); pRecord->Set_Value(0, Text); if( bLocation ) { pRecord->Set_Value(2, Elements.Get_Record_byIndex(i)->asString(1)); } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CSG_MetaData::Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase) const { CSG_String s; return( Get_Property(Name, s) && (bNoCase ? !s.CmpNoCase(String) : !s.Cmp(String)) ); }
//--------------------------------------------------------- bool CLines_From_Points::On_Execute(void) { int Order, Separate, Elevation; CSG_String s; CSG_Shape *pLine , *pPoint; CSG_Shapes *pLines, *pPoints; pPoints = Parameters("POINTS" )->asShapes(); pLines = Parameters("LINES" )->asShapes(); Order = Parameters("ORDER" )->asInt(); Separate = Parameters("SEPARATE" )->asInt(); Elevation = Parameters("ELEVATION")->asInt(); //------------------------------------------------- if( pPoints->Get_Count() < 1 ) { return( false ); } //------------------------------------------------- pLines->Create(SHAPE_TYPE_Line, pPoints->Get_Name(), NULL, Elevation >= 0 ? SG_VERTEX_TYPE_XYZ : SG_VERTEX_TYPE_XY); pLines->Add_Field(SG_T("ID"), SG_DATATYPE_Int); if( Separate >= 0 ) { pLines->Add_Field(pPoints->Get_Field_Name(Separate), pPoints->Get_Field_Type(Separate)); pPoints->Set_Index(Separate, TABLE_INDEX_Ascending, Order, TABLE_INDEX_Ascending); } else { pPoints->Set_Index(Order, TABLE_INDEX_Ascending); } //------------------------------------------------- for(int iPoint=0; iPoint<pPoints->Get_Count(); iPoint++) { pPoint = pPoints->Get_Shape_byIndex(iPoint); if( pLines->Get_Count() == 0 || (Separate >= 0 && s.Cmp(pPoint->asString(Separate))) ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, pLines->Get_Count()); if( Separate >= 0 ) { pLine->Set_Value(1, s = pPoint->asString(Separate)); } } pLine->Add_Point(pPoint->Get_Point(0)); if( Elevation >= 0 ) { pLine->Set_Z(pPoint->asDouble(Elevation), iPoint); } } return( true ); }