Changeset 18


Ignore:
Timestamp:
02/22/13 13:30:00 (12 years ago)
Author:
lucsch
Message:
  • Preliminary code for processing user_content.txt. Processing thematic_layers is now working
  • Corrected base_structure and user_structure.sql
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/models/base/base_structure.sql

    r8 r18  
    55  `CATALOG_ID` int(11) NOT NULL, 
    66  PRIMARY KEY (`ATTRIBUT_ID`,`CATALOG_ID`) 
    7 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     7) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    88 
    99-- dmn_catalog -- 
     
    1717  `DESCRIPTION_4` varchar(255) DEFAULT NULL, 
    1818  PRIMARY KEY (`CATALOG_ID`) 
    19 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     19) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    2020 
    2121-- dmn_layer_attribut -- 
     
    2525  `ATTRIBUT_NAME` varchar(100) DEFAULT NULL, 
    2626  PRIMARY KEY (`ATTRIBUT_ID`,`LAYER_INDEX`) 
    27 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     27) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    2828 
    2929-- dmn_layer_object -- 
     
    4444  PRIMARY KEY (`OBJECT_ID`), 
    4545  KEY `DMN_LAYER_OBJECT_FKIndex2` (`THEMATIC_LAYERS_LAYER_INDEX`,`OBJECT_ID`) 
    46 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     46) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    4747 
    4848-- dmn_layer_type -- 
     
    5151  `TYPE_DESCRIPTION` varchar(20) NOT NULL COMMENT 'Layer type description', 
    5252  PRIMARY KEY (`TYPE_CD`) 
    53 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     53) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    5454 
    5555 
     
    6565  `SHORTCUT_DESC` varchar(255) DEFAULT NULL, 
    6666  PRIMARY KEY (`SHORTCUT_CD`) 
    67 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     67) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    6868 
    6969INSERT INTO dmn_shortcut_key VALUES(1,"F1",""); 
     
    8888  `PERCENT_SKIPPED` double DEFAULT NULL, 
    8989  PRIMARY KEY (`LAYER_INDEX`) 
    90 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     90) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    9191 
    9292-- generic_aat -- 
     
    9797  KEY `GENERIC_LINES_has_DMN_LAYER_OBJECT_FKIndex1` (`OBJECT_VAL_ID`), 
    9898  KEY `GENERIC_LINES_has_DMN_LAYER_OBJECT_FKIndex2` (`OBJECT_GEOM_ID`) 
    99 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     99) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    100100 
    101101-- generic_dmn -- 
     
    104104  `DESCRIPTION` varchar(255) DEFAULT NULL COMMENT 'Code description', 
    105105  PRIMARY KEY (`CODE`) 
    106 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     106) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    107107 
    108108-- generic_frame -- 
     
    111111  `OBJECT_GEOMETRY` linestring NOT NULL COMMENT 'Feature geometry', 
    112112  PRIMARY KEY (`OBJECT_ID`) 
    113 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     113) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    114114 
    115115-- generic_labels -- 
     
    118118  `OBJECT_GEOMETRY` multipoint NOT NULL, 
    119119  PRIMARY KEY (`OBJECT_ID`) 
    120 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     120) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    121121 
    122122-- generic_lat -- 
     
    127127  KEY `GENERIC_LABELS_has_DMN_LAYER_OBJECT_FKIndex1` (`OBJECT_VAL_ID`), 
    128128  KEY `GENERIC_LABELS_has_DMN_LAYER_OBJECT_FKIndex2` (`OBJECT_GEOM_ID`) 
    129 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     129) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    130130 
    131131-- generic_lines -- 
     
    134134  `OBJECT_GEOMETRY` linestring NOT NULL, 
    135135  PRIMARY KEY (`OBJECT_ID`) 
    136 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     136) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    137137 
    138138-- generic_notes -- 
     
    147147  `ISFIXED` tinyint(1) DEFAULT '0', 
    148148  PRIMARY KEY (`OBJECT_ID`) 
    149 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     149) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    150150 
    151151-- generic_pat -- 
     
    156156  KEY `GENERIC_POINTS_has_DMN_LAYER_OBJECT_FKIndex1` (`OBJECT_VAL_ID`), 
    157157  KEY `GENERIC_POINTS_has_DMN_LAYER_OBJECT_FKIndex2` (`OBJECT_GEOM_ID`) 
    158 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     158) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    159159 
    160160-- generic_points -- 
     
    163163  `OBJECT_GEOMETRY` multipoint NOT NULL COMMENT 'Feature geometry', 
    164164  PRIMARY KEY (`OBJECT_ID`) 
    165 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     165) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    166166 
    167167-- lang_def -- 
     
    170170  `LANG_NAME` varchar(50) DEFAULT NULL, 
    171171  PRIMARY KEY (`LANG_ID`) 
    172 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     172) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    173173 
    174174 
     
    187187  `QUERIES_CODE` varchar(1000) DEFAULT NULL, 
    188188  PRIMARY KEY (`QUERIES_ID`) 
    189 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     189) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    190190 
    191191INSERT INTO prj_queries VALUES(1,0,"Lines without attribution","SELECT o.OBJECT_ID FROM generic_lines AS o WHERE o.OBJECT_ID NOT IN (SELECT a.OBJECT_GEOM_ID FROM generic_aat AS a)"); 
     
    208208  `PRJ_SNAP_TOLERENCE` int(11) NOT NULL DEFAULT '10', 
    209209  PRIMARY KEY (`SETTING_DBK`) 
    210 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
    211  
    212  
    213 INSERT INTO prj_settings VALUES(1,"Meters","No projection","Combioula_complet",224,"/Users/lucien/DATA/PRJ/TOOLMAP2/projects/test_prjaout/export",0,"/Users/lucien/DATA/PRJ/TOOLMAP2/projects/test_prjaout/backups","CREALP",0); 
     210) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
     211 
     212 
     213INSERT INTO prj_settings VALUES(1,"Meters","No projection","Master",224,"",0,"","SWISSTOPO - CREALP", "", 0); 
    214214 
    215215-- prj_snapping -- 
     
    218218  `SNAPPING_TYPE` int(11) NOT NULL, 
    219219  PRIMARY KEY (`TOC_ID`) 
    220 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     220) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    221221 
    222222-- prj_stats -- 
     
    229229  `DATE_END` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 
    230230  PRIMARY KEY (`STAT_ID`) 
    231 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     231) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    232232 
    233233-- prj_toc -- 
     
    244244  PRIMARY KEY (`CONTENT_ID`), 
    245245  KEY `PRJ_TOC_FKIndex1` (`TYPE_CD`) 
    246 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
    247  
    248  
    249 INSERT INTO prj_toc VALUES(1,0,"","Lines",1,0,1,0); 
    250 INSERT INTO prj_toc VALUES(2,1,"","Points",1,1,2,0); 
    251 INSERT INTO prj_toc VALUES(3,1,"","Labels",1,2,3,0); 
    252 INSERT INTO prj_toc VALUES(4,1,"","Notes",0,3,4,0); 
    253 INSERT INTO prj_toc VALUES(5,0,"","Frame",1,4,5,0); 
     246) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
     247 
     248 
     249INSERT INTO prj_toc VALUES(1,0,"","Lines",1,0,1,"",0); 
     250INSERT INTO prj_toc VALUES(2,1,"","Points",1,1,2,"",0); 
     251INSERT INTO prj_toc VALUES(3,1,"","Labels",1,2,3,"",0); 
     252INSERT INTO prj_toc VALUES(4,1,"","Notes",0,3,4,"",0); 
     253INSERT INTO prj_toc VALUES(5,0,"","Frame",1,4,5,"",0); 
    254254 
    255255 
     
    261261  KEY `SHORTCUT_KEYS_has_DMN_LAYER_OBJECT_FKIndex2` (`OBJECT_ID`), 
    262262  KEY `SHORTCUT_LIST_FKIndex2` (`SHORTCUT_CD`) 
    263 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     263) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    264264 
    265265-- thematic_layers -- 
     
    272272  PRIMARY KEY (`LAYER_INDEX`), 
    273273  KEY `THEMATIC_LAYERS_FKIndex1` (`TYPE_CD`) 
    274 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     274) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    275275 
    276276-- zoom_level -- 
     
    280280  `RANK` int(11) DEFAULT NULL, 
    281281  PRIMARY KEY (`ZOOM_ID`) 
    282 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 
     282) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
    283283 
    284284INSERT INTO zoom_level VALUES(1,5000,2); 
  • trunk/models/combioula/user_structure.sql

    r7 r18  
    99  PRIMARY KEY (`OBJECT_ID`), 
    1010  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    11 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     11) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    1212 
    1313-- layer_at2 -- 
     
    1919  PRIMARY KEY (`OBJECT_ID`), 
    2020  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    21 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     21) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    2222 
    2323-- layer_at3 -- 
     
    2929  PRIMARY KEY (`OBJECT_ID`), 
    3030  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    31 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     31) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    3232 
    3333-- layer_at4 -- 
     
    3939  PRIMARY KEY (`OBJECT_ID`), 
    4040  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    41 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     41) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    4242 
    4343-- layer_at7 -- 
     
    4949  PRIMARY KEY (`OBJECT_ID`), 
    5050  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    51 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     51) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    5252 
    5353-- layer_at9 -- 
     
    5757  PRIMARY KEY (`OBJECT_ID`), 
    5858  KEY `LAYER_ATX_FKIndex1` (`OBJECT_ID`) 
    59 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 
     59) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    6060 
  • trunk/tmdmcreator/src/main.cpp

    r16 r18  
    8383    bool bVerbose = parser.Found("verbose"); 
    8484    bool bToolMap = parser.Found("toolmap"); 
    85     if (parser.Found("overwrite")) { 
     85    if (parser.Found("overwrite") && wxFileExists(parser.GetParam(3))) { 
    8686        wxRemoveFile(parser.GetParam(3)); 
    8787    } 
  • trunk/tmdmcreator/src/tmdmcopier.cpp

    r16 r18  
    2626 
    2727TmDmCopier::~TmDmCopier() { 
     28    m_File->Flush(); 
    2829    wxDELETE(m_File); 
    2930} 
     
    4950 
    5051bool TmDmCopier::CopyFrom(const wxString & text) { 
     52    m_File->SeekEnd(); 
    5153    if (m_File->Write(text) == false) { 
    5254        m_Errors.Add(wxString::Format(_("Writing to: %s failed!"), m_File->GetName())); 
  • trunk/tmdmcreator/src/tmdmcreator.cpp

    r17 r18  
    9494    errorsmsg.Clear(); 
    9595    // Copy structure 
    96     TmDmCopier myCopier(m_FileNameOutSQL); 
    97     if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 
    98         errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameBaseSQL.GetFullPath())); 
    99         return false; 
     96    { // needed to destroy the copier before processing layers 
     97        TmDmCopier myCopier(m_FileNameOutSQL); 
     98        if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 
     99            errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameBaseSQL.GetFullPath())); 
     100            return false; 
     101        } 
     102         
     103        if (myCopier.CopyFrom(m_FileNameUserSQL) == false) { 
     104            errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameUserSQL.GetFullPath())); 
     105            return false; 
     106        } 
    100107    } 
    101      
    102     if (myCopier.CopyFrom(m_FileNameUserSQL) == false) { 
    103         errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameUserSQL.GetFullPath())); 
    104         return false; 
    105     } 
    106      
     108 
    107109    // Process layers 
    108110    TmDmProcessorSimple myLayerProc(m_FileNameUserContent, m_FileNameOutSQL); 
     
    112114        return false; 
    113115    } 
    114     if (myLayerProc.ProcessBlock(myThematicLayersStart)==false) { 
     116    if (myLayerProc.ProcessBlock(myThematicLayersStart, _T("thematic_layers"))==false) { 
    115117        errorsmsg.Add(wxString::Format(_("Processing 'thematic_layers' failed in %s"), m_FileNameUserContent.GetFullPath())); 
    116118        return false; 
  • trunk/tmdmcreator/src/tmdmprocessor.cpp

    r17 r18  
    6161 
    6262 
    63 bool TmDmProcessorSimple::ProcessBlock(int blockstart) { 
    64     wxString mySQLCols = wxEmptyString; 
    65     wxString mySQLTxt = wxEmptyString; 
     63bool TmDmProcessorSimple::ProcessBlock(int blockstart, const wxString & tablename) { 
     64    wxArrayString mySQLCols; 
     65    TmDmCopier myCopier(m_FileDst); 
    6666     
    6767    wxFileInputStream input(m_FileSrc.GetFullPath()); 
     
    6969    long myLineIndex = 0; 
    7070    while(input.IsOk() && !input.Eof() ){ 
     71        wxString myRow = text.ReadLine(); 
    7172        if (myLineIndex <= blockstart) { 
    7273            myLineIndex++; 
     
    7475        } 
    7576         
    76         wxString myRow = text.ReadLine(); 
     77        if (myLineIndex == blockstart+1) { 
     78            mySQLCols = wxStringTokenize(myRow, _T("\t"), wxTOKEN_RET_EMPTY); 
     79            myLineIndex++; 
     80            continue; 
     81        } 
    7782         
    78         // HERE !!!  
     83        wxArrayString myValues = wxStringTokenize(myRow, _T("\t"), wxTOKEN_RET_EMPTY_ALL); 
     84        bool bEmpty = true; 
     85        for (unsigned int i = 0; i< myValues.GetCount(); i++) { 
     86            if (myValues[i] != wxEmptyString) { 
     87                bEmpty = false; 
     88                break; 
     89            } 
     90        } 
     91        if (bEmpty == true) { 
     92            // ok empty line found 
     93            return true; 
     94        } 
    7995         
    80          
    81          
     96        // write insert sentence 
     97        wxString myInsert = wxString::Format(_T("INSERT INTO `%s` ("), tablename); 
     98        for (unsigned int i = 0; i< mySQLCols.GetCount(); i++) { 
     99            myInsert.Append(wxString::Format(_T("%s,"), mySQLCols.Item(i))); 
     100        } 
     101        myInsert.RemoveLast(); 
     102        myInsert.Append(_T(") VALUES (")); 
     103        for (unsigned int i = 0; i< mySQLCols.GetCount(); i++) { 
     104            myInsert.Append(wxString::Format(_T("\"%s\","), myValues.Item(i))); 
     105        } 
     106        myInsert.RemoveLast(); 
     107        myInsert.Append(_T(");\n")); 
     108        myCopier.CopyFrom(myInsert); 
    82109        myLineIndex++; 
    83110    } 
    84     return wxNOT_FOUND; 
    85  
    86      
    87      
    88      
    89111    return false; 
    90112} 
     
    104126} 
    105127 
    106 bool TmDmProcessorAttributs::ProcessBlock(int blockstart) { 
     128bool TmDmProcessorAttributs::ProcessBlock(int blockstart, const wxString & tablename) { 
    107129    return false; 
    108130} 
  • trunk/tmdmcreator/src/tmdmprocessor.h

    r17 r18  
    2424#include <wx/wfstream.h> 
    2525#include <wx/txtstrm.h> 
     26#include <wx/tokenzr.h> 
    2627 
    2728 
     
    3738     
    3839    int FindBlock(const wxString & blockname); 
    39     virtual bool ProcessBlock(int blockstart) = 0; 
     40    virtual bool ProcessBlock(int blockstart, const wxString & tablename) = 0; 
    4041}; 
    4142 
     
    5152    virtual ~TmDmProcessorSimple(); 
    5253     
    53     virtual bool ProcessBlock(int blockstart); 
     54    virtual bool ProcessBlock(int blockstart, const wxString & tablename); 
    5455}; 
    5556 
     
    6566    virtual ~TmDmProcessorAttributs(); 
    6667     
    67     virtual bool ProcessBlock(int blockstart); 
     68    virtual bool ProcessBlock(int blockstart, const wxString & tablename); 
    6869}; 
    6970#endif 
Note: See TracChangeset for help on using the changeset viewer.