Changeset 21 for trunk/tmdmcreator/src


Ignore:
Timestamp:
02/25/13 11:47:25 (12 years ago)
Author:
lucsch
Message:
  • TmDmCreator is now working (supports language selection)
  • Adding swisstopo data model definition
Location:
trunk/tmdmcreator/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tmdmcreator/src/main.cpp

    r18 r21  
    3535        wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, 
    3636    { wxCMD_LINE_SWITCH, "v", "verbose", "Be more verbose" }, 
    37     { wxCMD_LINE_SWITCH, "t", "toolmap", "toolmap output" }, 
    38     { wxCMD_LINE_SWITCH, "o", "overwrite", "overwrite output" },     
     37    { wxCMD_LINE_SWITCH, "t", "toolmap", "toolmap output (default is SQL)" }, 
     38    { wxCMD_LINE_SWITCH, "o", "overwrite", "overwrite output" }, 
     39    { wxCMD_LINE_OPTION, "l", "language", "language column (default is 0)", wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL}, 
    3940    { wxCMD_LINE_PARAM, NULL, NULL, "[base structure sql file]"}, 
    4041    { wxCMD_LINE_PARAM, NULL, NULL, "[user structure sql file]"}, 
     
    8384    bool bVerbose = parser.Found("verbose"); 
    8485    bool bToolMap = parser.Found("toolmap"); 
     86    long myLanguage = 0; 
     87    if(parser.Found("language", &myLanguage) == true) { 
     88        wxPrintf(_("Using language column: %ld\n"), myLanguage); 
     89    } 
    8590    if (parser.Found("overwrite") && wxFileExists(parser.GetParam(3))) { 
    8691        wxRemoveFile(parser.GetParam(3)); 
     
    108113    } 
    109114     
    110     if (myCreator.ProcessFiles(myErrors) == false) { 
     115    if (myCreator.ProcessFiles(myErrors, myLanguage) == false) { 
    111116        if (bVerbose == true) { 
    112117            PrintArray(myErrors); 
  • trunk/tmdmcreator/src/tmdmcreator.cpp

    r19 r21  
    9191 
    9292 
    93 bool TmDmCreator::ProcessFiles(wxArrayString & errorsmsg) { 
     93bool TmDmCreator::ProcessFiles(wxArrayString & errorsmsg, int languagecolumn) { 
    9494    errorsmsg.Clear(); 
    9595    // Copy structure 
     
    109109    // Process layers 
    110110    TmDmProcessorSimple myProc(m_FileNameUserContent, m_FileNameOutSQL); 
     111    myProc.SetLanguageColumn(languagecolumn); 
    111112    int myThematicLayersStart = myProc.FindBlock(_T("thematic_layers")); 
    112113    if (myThematicLayersStart == wxNOT_FOUND) { 
     
    132133    // Process attributs 
    133134    TmDmProcessorAttributs myProcAttributs (m_FileNameUserContent, m_FileNameOutSQL); 
     135    myProcAttributs.SetLanguageColumn(languagecolumn); 
    134136    int myAttributStart = myProcAttributs.FindBlock(_T("attributs")); 
    135137    if (myAttributStart == wxNOT_FOUND) { 
  • trunk/tmdmcreator/src/tmdmcreator.h

    r16 r21  
    4242     
    4343    bool CheckFiles(wxArrayString & errormsg); 
    44     bool ProcessFiles(wxArrayString & errorsmsg);     
     44    bool ProcessFiles(wxArrayString & errorsmsg, int languagecolumn); 
    4545}; 
    4646#endif 
  • trunk/tmdmcreator/src/tmdmprocessor.cpp

    r19 r21  
    2121    m_FileSrc = src; 
    2222    m_FileDst = dest; 
     23    m_LanguageCol = 0; 
    2324} 
    2425 
     
    4243    } 
    4344    return wxNOT_FOUND; 
     45} 
     46 
     47 
     48 
     49wxString TmDmProcessor::SwitchCols(wxArrayString * cols, wxArrayString * values, int item) { 
     50    if (m_LanguageCol == 0) { 
     51        return values->Item(item); 
     52    } 
     53     
     54 
     55    if(cols->Item(item).Contains(_T("_0")) == true) { 
     56        return values->Item(item + m_LanguageCol); 
     57    } 
     58     
     59    wxString myColName = wxString::Format(_T("_%d"), m_LanguageCol); 
     60    if (cols->Item(item).Contains(myColName) == true) { 
     61        return values->Item(item - m_LanguageCol); 
     62    } 
     63    return values->Item(item); 
     64} 
     65 
     66 
     67 
     68void TmDmProcessor::SetLanguageColumn(int value) { 
     69    m_LanguageCol = value; 
    4470} 
    4571 
     
    104130        myInsert.Append(_T(") VALUES (")); 
    105131        for (unsigned int i = 0; i< mySQLCols.GetCount(); i++) { 
    106             myInsert.Append(wxString::Format(_T("\"%s\","), myValues.Item(i))); 
     132            myInsert.Append(wxString::Format(_T("\"%s\","), SwitchCols(&mySQLCols, &myValues, i))); 
    107133        } 
    108134        myInsert.RemoveLast(); 
     
    232258        wxString myInsert = _T("INSERT INTO `dmn_catalog` VALUES ("); 
    233259        for (unsigned int i = START_COL; i< mySQLCols.GetCount(); i++) { 
    234             myInsert.Append(wxString::Format(_T("\"%s\","), myValues.Item(i))); 
     260            myInsert.Append(wxString::Format(_T("\"%s\","), SwitchCols(&mySQLCols, &myValues, i))); 
    235261        } 
    236262        myInsert.RemoveLast(); 
  • trunk/tmdmcreator/src/tmdmprocessor.h

    r19 r21  
    3333    wxFileName m_FileDst; 
    3434     
     35    int m_LanguageCol; 
     36    wxString SwitchCols(wxArrayString * cols, wxArrayString * values, int item); 
     37     
    3538public: 
    3639    TmDmProcessor(const wxFileName & src, const wxFileName & dest); 
     
    3942    int FindBlock(const wxString & blockname); 
    4043    virtual bool ProcessBlock(int blockstart, const wxString & tablename) = 0; 
     44 
     45    void SetLanguageColumn(int value); 
    4146}; 
    4247 
Note: See TracChangeset for help on using the changeset viewer.