123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <IniFiles.hpp>
- #include "ITSDbF.h"
- #pragma hdrstop
- #include "FrmUtilMainF.h"
- #include <stdio.h>
- #include <locale.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCheckBox"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxGroupBox"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxProgressBar"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxmdaset"
- #pragma resource "*.dfm"
- TFrmUtilMain *FrmUtilMain;
- //---------------------------------------------------------------------------
- #define XML_DIR "\\MAPDATA\\layers\\"
- APP_CONFIG g_AppCfg;
- //Provider=tbprov.Tbprov.5;Cache Authentication=False;Encrypt Password=False;Integrated Security="";Mask Password=False;Persist Encrypted=False;Persist Security Info=False;User ID="";Bind Flags=0;Initial Catalog="";Data Source=GMUTIS;Impersonation Level=Anonymous;Location="";Lock Owner="";Mode=ReadWrite;Protection Level=None;Extended Properties="";Updatable Cursor=False;Enlist=None
- //Provider=tbprov.Tbprov.5;Cache Authentication=False;Encrypt Password=False;Integrated Security="";Mask Password=False;Persist Encrypted=False;Persist Security Info=False;User ID=itsdev;Bind Flags=0;Initial Catalog="";Data Source=GMUTIS;Impersonation Level=Anonymous;Location="";Lock Owner="";Mode=ReadWrite;Protection Level=None;Updatable Cursor=False;Enlist=None;
- bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
- {
- String sCfgFile;
- TIniFile *pIniFile = NULL;
- g_AppCfg.bAppClose = false;
- String sAppDir = ExtractFilePath(Application->ExeName);
- String sCfgDir = sAppDir + "Cfg\\";
- String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
- if (!ACfgFile.IsEmpty())
- sIniFile = ACfgFile + ".ini";
- sCfgFile = sCfgDir + sIniFile;
- String sMapDir = sAppDir + XML_DIR;
- ForceDirectories(sMapDir.c_str());
- try
- {
- String sTmp;
- pIniFile = new TIniFile(sCfgFile);
- String sSqlLog;
- g_AppCfg.itsdb.bSqlLog = false;
- g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
- g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
- g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
- g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
- g_AppCfg.link.bSqlLog = false;
- g_AppCfg.link.sProvider = pIniFile->ReadString("ITSDB_LINK", "PROVIDER", "OraOLEDB.Oracle.1");
- g_AppCfg.link.sServerName = pIniFile->ReadString("ITSDB_LINK", "SERVERNAME", "HANTE");
- g_AppCfg.link.sUserName = pIniFile->ReadString("ITSDB_LINK", "USERNAME", "hnits");
- g_AppCfg.link.sPassword = pIniFile->ReadString("ITSDB_LINK", "PASSWORD", "hnits");
- g_AppCfg.ifsc.bSqlLog = false;
- g_AppCfg.ifsc.sProvider = pIniFile->ReadString("ITSDB_IFSC", "PROVIDER", "OraOLEDB.Oracle.1");
- g_AppCfg.ifsc.sServerName = pIniFile->ReadString("ITSDB_IFSC", "SERVERNAME", "HANTE");
- g_AppCfg.ifsc.sUserName = pIniFile->ReadString("ITSDB_IFSC", "USERNAME", "hnits");
- g_AppCfg.ifsc.sPassword = pIniFile->ReadString("ITSDB_IFSC", "PASSWORD", "hnits");
- g_AppCfg.road.bSqlLog = false;
- g_AppCfg.road.sProvider = pIniFile->ReadString("ITSDB_ROAD", "PROVIDER", "OraOLEDB.Oracle.1");
- g_AppCfg.road.sServerName = pIniFile->ReadString("ITSDB_ROAD", "SERVERNAME", "HANTE");
- g_AppCfg.road.sUserName = pIniFile->ReadString("ITSDB_ROAD", "USERNAME", "hnits");
- g_AppCfg.road.sPassword = pIniFile->ReadString("ITSDB_ROAD", "PASSWORD", "hnits");
- String sTemp = g_AppCfg.itsdb.sProvider.UpperCase();
- if (sTemp.Pos("TIBERO"))
- {
- //g_AppCfg.itsdb.sProvider = "bprov.MSDTB.5";
- }
- g_AppCfg.flashmap.sMainMap = pIniFile->ReadString("FLASHMAP", "MAINMAP", "");
- g_AppCfg.flashmap.sLinkMap = pIniFile->ReadString("FLASHMAP", "LINKMAP", "");
- #if 0
- if (g_AppCfg.flashmap.sMainMap == "" ||
- g_AppCfg.flashmap.sLinkMap == "")
- {
- Application->MessageBox(L"지도 설정 정보를 읽어오는데 실패하였습니다.!!!!!!!!!!",
- L"환경설정 정보 로딩 오류!!!",
- MB_OK|MB_ICONERROR);
- }
- #endif
- g_AppCfg.flashmap.sMainMap = sAppDir + g_AppCfg.flashmap.sMainMap;
- g_AppCfg.flashmap.sLinkMap = sAppDir + g_AppCfg.flashmap.sLinkMap;
- }
- __finally
- {
- if (pIniFile) delete pIniFile;
- pIniFile = NULL;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void DB_CLOSE()
- {
- ITSDb_Close();
- }
- //---------------------------------------------------------------------------
- bool DB_OPEN(DB_INFO *ADbInfo)
- {
- DB_CLOSE();
- ITSDb_SetInfo(ADbInfo->sProvider, ADbInfo->sServerName, ADbInfo->sUserName, ADbInfo->sPassword);
- if (!ITSDb_Open())
- {
- Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n환경파일에서 데이터베이스 연결 정보를 확인하세요.",
- L"데이터베이스 접속 오류!!!",
- MB_OK|MB_ICONERROR);
- return false;
- }
- return true;
- }
- __fastcall TFrmUtilMain::TFrmUtilMain(TComponent* Owner)
- : TForm(Owner)
- {
- Application->OnException = OnAppException;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::OnAppException(TObject *Sender, Exception *exception)
- {
- String sClassName = (NULL != Sender) ? Sender->ClassName() : String("Unknown_Class");
- String sErrMsg = (NULL != exception) ? exception->Message : String("Unknown_Error");
- String sError = sClassName + " : " + sErrMsg;
- //Application->ShowException(&exception);
- //WriteLog(logError, "OnAppException: [%s]", AnsiString(sError).c_str());
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::CommClose()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- //Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::FormCreate(TObject *Sender)
- {
- FOnMessage = Application->OnMessage;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::FormDestroy(TObject *Sender)
- {
- try
- {
- //::OleUninitialize();
- //::CoUninitialize();
- }
- catch(Exception &exception)
- {
- //WriteLog(logError, "FormDestroy: [%s]", AnsiString(exception.ClassName()+exception.Message).c_str());
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::FormShow(TObject *Sender)
- {
- Application->ProcessMessages();
- edPath->Text = ExtractFilePath(Application->ExeName) + XML_DIR;
- Refresh();
- Application->ProcessMessages();
- TmrOnShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::FormCloseQuery(TObject *Sender, bool &CanClose)
- {
- // 폼이 닫히기 전에 수행해야 할 모뮬 기술
- // 프로그램 종료를 사용자가 확인할 수 있도록...
- if (!g_AppCfg.bAppClose)
- {
- String strMsg;
- strMsg = "";
- strMsg = "[ " + Caption + " ]\r\n\n";
- strMsg+= "프로그램을 종료 하시겠습니까?";
- //if(Application->MessageBox(strMsg.c_str(), String("프로그램 종료 확인").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES)
- {
- /*
- * 화면관련 작업을 못하도록 여기에 코드를 적자...
- */
- ITSDb_ApplicationTerm();
- g_AppCfg.bAppClose = true;
- }
- CanClose = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::BtnCloseClick(TObject *Sender)
- {
- g_AppCfg.bAppClose = true;
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::TmrOnShowTimer(TObject *Sender)
- {
- TmrOnShow->Enabled = false;
- #if 0
- if (!ITSDb_Open())
- {
- Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n환경파일에서 데이터베이스 연결 정보를 확인하세요.\r\n\r\n프로그램을 종료합니다.",
- L"데이터베이스 접속 오류!!!",
- MB_OK|MB_ICONERROR);
- g_AppCfg.bAppClose = true;
- Close();
- return;
- }
- #endif
- TmrAppState->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::TmrAppStateTimer(TObject *Sender)
- {
- TmrAppState->Enabled = false;
- if (g_AppCfg.bAppClose)
- {
- ITSDb_Close();
- Close();
- try {
- Application->Terminate();
- } catch(Exception &exception) {}
- }
- else
- {
- TmrAppState->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::UpdateProgress(int AProg, String AMsg/*=""*/)
- {
- try {
- cxProgressBar1->Position = AProg;
- if (AMsg != "") LblStatus->Caption = AMsg;
- Application->ProcessMessages();
- } catch(Exception &exception) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::cxButton1Click(TObject *Sender)
- {
- #if 0
- // 데이터베이스 버텍스 정보 설정
- int nStep;
- String sQry;
- TADOQuery *pADO = NULL;
- if (Application->MessageBox(L"데이터베이스 Vertex 정보를 생성하시겠습니까?\r\n기존의 정보가 삭제되고 새로운 정보가 입력됩니다.",
- L"데이터베이스 Vertex 정보생성", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES)
- {
- return;
- }
- cxProgressBar1->Properties->Max = 9;
- PnlProg->Left = 16;
- PnlProg->Top = 304;
- PnlProg->Visible = true;
- cxButton1->Enabled = false;
- cxButton2->Enabled = false;
- try
- {
- pADO = new TADOQuery(NULL);
- ITSDb_GetConnection()->BeginTrans();
- pADO->Connection = ITSDb_GetConnection();
- try {
- nStep = 1;
- UpdateProgress(nStep, cxLabel3->Caption);
- sQry = "DELETE TB_ROAD_VRTX_ARR";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->ExecSQL();
- LblDb01->Caption = "성공";
- sQry = "INSERT INTO TB_ROAD_VRTX_ARR \r\n"
- "SELECT X.ROAD_ID, X.LEVL, Y.CRDN_CNT, X.X_CRDN_ARR, X.Y_CRDN_ARR, \r\n"
- " Y.X_CRDN_MIN, Y.X_CRDN_MAX, Y.Y_CRDN_MIN, Y.Y_CRDN_MAX \r\n"
- " FROM (SELECT ROAD_ID, :p01 AS LEVL, \r\n"
- " SUBSTR(MAX(SYS_CONNECT_BY_PATH (X_CRDN, ',')), 2) X_CRDN_ARR, \r\n"
- " SUBSTR(MAX(SYS_CONNECT_BY_PATH (Y_CRDN, ',')), 2) Y_CRDN_ARR \r\n"
- " FROM (SELECT ROAD_ID, X_CRDN, Y_CRDN, \r\n"
- " ROW_NUMBER () OVER (PARTITION BY ROAD_ID ORDER BY ORD) RNUM \r\n"
- " FROM (SELECT ROAD_ID, ORD, X_CRDN, Y_CRDN \r\n"
- " FROM TB_ROAD_VRTX \r\n"
- " WHERE LEVL = :p02 \r\n"
- " ) \r\n"
- " ) \r\n"
- " START WITH RNUM = 1 \r\n"
- " CONNECT BY PRIOR RNUM = RNUM - 1 AND PRIOR ROAD_ID = ROAD_ID \r\n"
- " GROUP BY ROAD_ID) X, \r\n"
- " (SELECT ROAD_ID, LEVL, COUNT(1) AS CRDN_CNT, \r\n"
- " MIN(X_CRDN) AS X_CRDN_MIN, MAX(X_CRDN) AS X_CRDN_MAX, \r\n"
- " MIN(Y_CRDN) AS Y_CRDN_MIN, MAX(Y_CRDN) AS Y_CRDN_MAX \r\n"
- " FROM TB_ROAD_VRTX \r\n"
- " GROUP BY ROAD_ID, LEVL) Y \r\n"
- " WHERE X.ROAD_ID = Y.ROAD_ID \r\n"
- " AND X.LEVL = Y.LEVL \r\n"
- " AND X.ROAD_ID IN (SELECT ROAD_ID FROM TB_ROAD WHERE DEL_YN = 'N') \r\n";
- nStep = 2;
- UpdateProgress(nStep, cxLabel4->Caption);
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "1000";
- pADO->Parameters->ParamByName("p02")->Value = "1000";
- pADO->ExecSQL();
- LblDb02->Caption = "성공";
- nStep = 3;
- UpdateProgress(nStep, cxLabel5->Caption);
- //pADO->Close();
- //pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "2000";
- pADO->Parameters->ParamByName("p02")->Value = "2000";
- pADO->ExecSQL();
- LblDb03->Caption = "성공";
- nStep = 4;
- UpdateProgress(nStep, cxLabel6->Caption);
- //pADO->Close();
- //pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "4000";
- pADO->Parameters->ParamByName("p02")->Value = "4000";
- pADO->ExecSQL();
- LblDb04->Caption = "성공";
- nStep = 5;
- UpdateProgress(nStep, cxLabel7->Caption);
- sQry = "DELETE TB_IFSC_VRTX_ARR";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->ExecSQL();
- LblDb05->Caption = "성공";
- sQry = "INSERT INTO TB_IFSC_VRTX_ARR \r\n"
- "SELECT X.IFSC_ID, X.LEVL, Y.CRDN_CNT, X.X_CRDN_ARR, X.Y_CRDN_ARR, \r\n"
- " Y.X_CRDN_MIN, Y.X_CRDN_MAX, Y.Y_CRDN_MIN, Y.Y_CRDN_MAX \r\n"
- " FROM (SELECT IFSC_ID, :p01 AS LEVL, \r\n"
- " SUBSTR(MAX(SYS_CONNECT_BY_PATH (X_CRDN, ',')), 2) X_CRDN_ARR, \r\n"
- " SUBSTR(MAX(SYS_CONNECT_BY_PATH (Y_CRDN, ',')), 2) Y_CRDN_ARR \r\n"
- " FROM (SELECT IFSC_ID, X_CRDN, Y_CRDN, \r\n"
- " ROW_NUMBER () OVER (PARTITION BY IFSC_ID ORDER BY ORD) RNUM \r\n"
- " FROM (SELECT IFSC_ID, ORD, X_CRDN, Y_CRDN \r\n"
- " FROM TB_IFSC_VRTX \r\n"
- " WHERE LEVL = :p02 \r\n"
- " ) \r\n"
- " ) \r\n"
- " START WITH RNUM = 1 \r\n"
- " CONNECT BY PRIOR RNUM = RNUM - 1 AND PRIOR IFSC_ID = IFSC_ID \r\n"
- " GROUP BY IFSC_ID) X, \r\n"
- " (SELECT IFSC_ID, LEVL, COUNT(1) AS CRDN_CNT, \r\n"
- " MIN(X_CRDN) AS X_CRDN_MIN, MAX(X_CRDN) AS X_CRDN_MAX, \r\n"
- " MIN(Y_CRDN) AS Y_CRDN_MIN, MAX(Y_CRDN) AS Y_CRDN_MAX \r\n"
- " FROM TB_IFSC_VRTX \r\n"
- " GROUP BY IFSC_ID, LEVL) Y \r\n"
- " WHERE X.IFSC_ID = Y.IFSC_ID \r\n"
- " AND X.LEVL = Y.LEVL \r\n"
- " AND X.IFSC_ID IN (SELECT IFSC_ID FROM TB_IFSC WHERE DEL_YN = 'N') \r\n";
- nStep = 6;
- UpdateProgress(nStep, cxLabel8->Caption);
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "50";
- pADO->Parameters->ParamByName("p02")->Value = "50";
- pADO->ExecSQL();
- LblDb06->Caption = "성공";
- nStep = 7;
- UpdateProgress(nStep, cxLabel9->Caption);
- //pADO->Close();
- //pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "100";
- pADO->Parameters->ParamByName("p02")->Value = "100";
- pADO->ExecSQL();
- LblDb07->Caption = "성공";
- nStep = 8;
- UpdateProgress(nStep, cxLabel10->Caption);
- //pADO->Close();
- //pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "250";
- pADO->Parameters->ParamByName("p02")->Value = "250";
- pADO->ExecSQL();
- LblDb08->Caption = "성공";
- nStep = 9;
- UpdateProgress(nStep, cxLabel11->Caption);
- //pADO->Close();
- //pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = "500";
- pADO->Parameters->ParamByName("p02")->Value = "500";
- pADO->ExecSQL();
- LblDb09->Caption = "성공";
- ITSDb_GetConnection()->CommitTrans();
- Application->MessageBox(L"데이터베이스 Vertex 정보를 생성하였습니다.", L"데이터베이스 Vertex 정보생성", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- } catch(Exception &exception) {
- ITSDb_GetConnection()->RollbackTrans();
- switch(nStep)
- {
- case 1: LblDb01->Caption = "실패"; break;
- case 2: LblDb02->Caption = "실패"; break;
- case 3: LblDb03->Caption = "실패"; break;
- case 4: LblDb04->Caption = "실패"; break;
- case 5: LblDb05->Caption = "실패"; break;
- case 6: LblDb06->Caption = "실패"; break;
- case 7: LblDb07->Caption = "실패"; break;
- case 8: LblDb08->Caption = "실패"; break;
- case 9: LblDb09->Caption = "실패"; break;
- }
- String sErrMsg;
- sErrMsg = "데이터베이스 작업중에 오류가 발생 하였습니다.\r\n";
- sErrMsg+= String(exception.ClassName()) + exception.Message;
- Application->MessageBox(sErrMsg.c_str(), L"데이터베이스 Vertex 정보 생성 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- }
- __finally
- {
- PnlProg->Visible = false;
- cxButton1->Enabled = true;
- cxButton2->Enabled = true;
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmUtilMain::cxButton2Click(TObject *Sender)
- {
- int nStep;
- String sQry;
- TADOQuery *pADO = NULL;
- if ((!ChkLinkVertex->Checked) &&
- (!ChkIfscVertex->Checked) &&
- (!ChkRoadVertex->Checked)
- )
- {
- Application->MessageBox(L"작업 대상 정보를 선택하십시요.", L"XML 파일 생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- if (Application->MessageBox(L"선택한 정보의 좌표파일을 신규로 생성하시겠습니까?\r\n기존의 파일은 삭제되고 새로운 파일이 생성됩니다.",
- L"지도 좌표 파일 생성", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES)
- {
- return;
- }
- try
- {
- //_wsetlocale(LC_ALL, L"kor");
- cxProgressBar1->Properties->Max = 2;
- PnlProg->Left = 16;
- PnlProg->Top = 124;
- PnlProg->Visible = true;
- pADO = new TADOQuery(NULL);
- pADO->Connection = ITSDb_GetConnection();
- pADO->CursorLocation = clUseClient;
- pADO->CursorType = ctStatic;//ctOpenForwardOnly;
- pADO->LockType = ltReadOnly;//ltBatchOptimistic;
- pADO->DisableControls();
- if (ChkLinkVertex->Checked) MakeLinkVertexXml(pADO);
- if (ChkIfscVertex->Checked) MakeIfscVertexXml(pADO);
- if (ChkRoadVertex->Checked) MakeRoadVertexXml(pADO);
- Application->MessageBox(L"선택한 정보의 좌표파일 생성을 완료하였습니다.", L"지도 좌표 파일 생성", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- __finally
- {
- PnlProg->Visible = false;
- cxButton2->Enabled = true;
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeLinkVertexXml(TADOQuery *pADO)
- {
- if (DB_OPEN(&g_AppCfg.link) == false)
- {
- return false;
- }
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "LINK.dat";
- AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "LINK_"+Now().FormatString("yyyymmddhhnnss")+".dat";
- try
- {
- CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
- }
- catch(Exception &e)
- {
- }
- FILE *fd = NULL;
- UpdateProgress(1, "링크 구간좌표 정보 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"링크 구간좌표 정보 파일 파일을 생성하지 못하였습니다.",
- L"링크 구간좌표 정보 파일 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- //sQry = "SELECT A.LINK_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
- sQry = "SELECT A.LINK_ID AS ID, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
- " FROM TB_LINK_VRTX_ARR A, \r\n"
- " TB_LINK B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.LINK_ID = A.LINK_ID \r\n"
- " AND A.LEVL = 1 \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- String ID;
- String XAddr;
- String YAddr;
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- ID = pADO->FieldByName("ID")->AsString;
- //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
- //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
- XAddr = "";
- YAddr = "";
- String sColNm;
- for (int ii = 1; ii < 24; ii++)
- {
- sColNm.printf(L"XMSG%02d", ii);
- XAddr += pADO->FieldByName(sColNm)->AsWideString;
- sColNm.printf(L"YMSG%02d", ii);
- YAddr += pADO->FieldByName(sColNm)->AsWideString;
- }
- fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- fclose(fd);
- }
- pADO->Close();
- DB_CLOSE();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeIfscVertexXml2(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC.dat";
- AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC_"+Now().FormatString("yyyymmddhhnnss")+".dat";
- try
- {
- CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
- }
- catch(Exception &e)
- {
- }
- FILE *fd = NULL;
- UpdateProgress(1, "정보제공구간 구간좌표 정보 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"정보제공구간 구간좌표 정보 파일을 생성하지 못하였습니다.",
- L"정보제공구간 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- int nTotal = 0;
- #if 0
- sQry = "SELECT A.IFSC_ID AS ID, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1, 400) AS XMSG01, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 401, 400) AS XMSG02, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 801, 400) AS XMSG03, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1201, 400) AS XMSG04, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1601, 400) AS XMSG05, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2001, 400) AS XMSG06, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2401, 400) AS XMSG07, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2801, 400) AS XMSG08, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3201, 400) AS XMSG09, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3601, 400) AS XMSG10, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4001, 400) AS XMSG11, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4401, 400) AS XMSG12, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1, 400) AS YMSG01, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 401, 400) AS YMSG02, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 801, 400) AS YMSG03, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1201, 400) AS YMSG04, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1601, 400) AS YMSG05, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2001, 400) AS YMSG06, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2401, 400) AS YMSG07, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2801, 400) AS YMSG08, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3201, 400) AS YMSG09, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3601, 400) AS YMSG10, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4001, 400) AS YMSG11, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4401, 400) AS YMSG12 \r\n"
- " FROM TB_IFSC_VRTX_ARR A, \r\n"
- " TB_IFSC B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.IFSC_ID = A.IFSC_ID \r\n"
- " AND A.LEVL = 5 \r\n";
- #if 1
- sQry = "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
- " FROM TB_IFSC_VRTX_ARR A, \r\n"
- " TB_IFSC B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.IFSC_ID = A.IFSC_ID \r\n"
- " AND A.LEVL = 5 \r\n";
- #endif
- #endif
- try
- {
- try
- {
- sQry = "SELECT COUNT(1) AS TOTAL_CNT \r\n"
- " FROM TB_IFSC_VRTX_ARR A, \r\n"
- " TB_IFSC B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.IFSC_ID = A.IFSC_ID \r\n"
- " AND A.LEVL = 5 \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- nTotal = pADO->FieldByName("TOTAL_CNT")->AsInteger;
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- pADO->Close();
- }
- int nFetchRows = 500;
- int nFetchCnts = nTotal / nFetchRows;
- nFetchCnts = nFetchCnts + ((nTotal % nFetchRows) ? 1 : 0);
- for (int seq = 0; seq < nFetchCnts; seq++)
- {
- try
- {
- try
- {
- sQry = "SELECT ID, X_CRDN_ARR, Y_CRDN_ARR \r\n"
- " FROM ( \r\n"
- "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR, ROWNUM AS DATA_SEQ \r\n"
- " FROM TB_IFSC_VRTX_ARR A, \r\n"
- " TB_IFSC B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.IFSC_ID = A.IFSC_ID \r\n"
- " AND A.LEVL = 5 \r\n"
- " ORDER BY A.IFSC_ID \r\n"
- " ) \r\n"
- " WHERE DATA_SEQ >= :p01 AND DATA_SEQ < :p02 \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Parameters->ParamByName("p01")->Value = seq*nFetchRows;
- pADO->Parameters->ParamByName("p02")->Value = (seq+1)*nFetchRows;
- pADO->Open();
- //nRows = pADO->RecordCount;
- //cxProgressBar1->Properties->Max = nRows;
- String ID;
- String XAddr;
- String YAddr;
- nCnt = 0;
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- ID = pADO->FieldByName("ID")->AsString;
- XAddr = pADO->FieldByName("X_CRDN_ARR")->AsString;
- YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsString;
- fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
- //if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- Application->ProcessMessages();
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- //UpdateProgress(nRows);
- if (fd)
- {
- fclose(fd);
- }
- pADO->Close();
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeIfscVertexXml(TADOQuery *pADO)
- {
- if (DB_OPEN(&g_AppCfg.ifsc) == false)
- {
- return false;
- }
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC.dat";
- AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "IFSC_"+Now().FormatString("yyyymmddhhnnss")+".dat";
- try
- {
- CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
- }
- catch(Exception &e)
- {
- }
- FILE *fd = NULL;
- UpdateProgress(1, "정보제공구간 구간좌표 정보 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"정보제공구간 구간좌표 정보 파일을 생성하지 못하였습니다.",
- L"정보제공구간 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- //sQry = "SELECT A.IFSC_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
- sQry = "SELECT A.IFSC_ID AS ID, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
- " FROM TB_IFSC_VRTX_ARR A, \r\n"
- " TB_IFSC B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.IFSC_ID = A.IFSC_ID \r\n"
- " AND A.LEVL = 5 \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- String ID;
- String XAddr;
- String YAddr;
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- ID = pADO->FieldByName("ID")->AsString;
- //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
- //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
- XAddr = "";
- YAddr = "";
- String sColNm;
- for (int ii = 1; ii < 24; ii++)
- {
- sColNm.printf(L"XMSG%02d", ii);
- XAddr += pADO->FieldByName(sColNm)->AsWideString;
- sColNm.printf(L"YMSG%02d", ii);
- YAddr += pADO->FieldByName(sColNm)->AsWideString;
- }
- fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- fclose(fd);
- }
- pADO->Close();
- DB_CLOSE();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeRoadVertexXml(TADOQuery *pADO)
- {
- if (DB_OPEN(&g_AppCfg.road) == false)
- {
- return false;
- }
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "ROAD.dat";
- AnsiString sFileBackup = ExtractFilePath(Application->ExeName) + XML_DIR+ "ROAD_"+Now().FormatString("yyyymmddhhnnss")+".dat";
- try
- {
- CopyFile(String(sFile).c_str(), String(sFileBackup).c_str(), true); //존재하면 업어쓴다
- }
- catch(Exception &e)
- {
- }
- FILE *fd = NULL;
- UpdateProgress(1, "도로 구간좌표 정보 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"도로 구간좌표 정보 파일을 생성하지 못하였습니다.",
- L"도로 구간좌표 정보 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- //sQry = "SELECT A.ROAD_ID AS ID, A.X_CRDN_ARR, A.Y_CRDN_ARR \r\n"
- sQry = "SELECT A.ROAD_ID AS ID, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1, 200) AS XMSG01, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 201, 200) AS XMSG02, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 401, 200) AS XMSG03, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 601, 200) AS XMSG04, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 801, 200) AS XMSG05, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1001, 200) AS XMSG06, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1201, 200) AS XMSG07, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1401, 200) AS XMSG08, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1601, 200) AS XMSG09, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 1801, 200) AS XMSG10, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2001, 200) AS XMSG11, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2201, 200) AS XMSG12, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2401, 200) AS XMSG13, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2601, 200) AS XMSG14, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 2801, 200) AS XMSG15, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3001, 200) AS XMSG16, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3201, 200) AS XMSG17, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3401, 200) AS XMSG18, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3601, 200) AS XMSG19, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 3801, 200) AS XMSG20, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4001, 200) AS XMSG21, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4201, 200) AS XMSG22, \r\n"
- " SUBSTR(A.X_CRDN_ARR, 4401, 200) AS XMSG23, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1, 200) AS YMSG01, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 201, 200) AS YMSG02, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 401, 200) AS YMSG03, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 601, 200) AS YMSG04, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 801, 200) AS YMSG05, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1001, 200) AS YMSG06, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1201, 200) AS YMSG07, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1401, 200) AS YMSG08, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1601, 200) AS YMSG09, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 1801, 200) AS YMSG10, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2001, 200) AS YMSG11, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2201, 200) AS YMSG12, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2401, 200) AS YMSG13, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2601, 200) AS YMSG14, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 2801, 200) AS YMSG15, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3001, 200) AS YMSG16, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3201, 200) AS YMSG17, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3401, 200) AS YMSG18, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3601, 200) AS YMSG19, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 3801, 200) AS YMSG20, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4001, 200) AS YMSG21, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4201, 200) AS YMSG22, \r\n"
- " SUBSTR(A.Y_CRDN_ARR, 4401, 200) AS YMSG23 \r\n"
- " FROM TB_ROAD_VRTX_ARR A, \r\n"
- " TB_ROAD B \r\n"
- " WHERE B.DEL_YN = 'N' \r\n"
- " AND B.ROAD_ID = A.ROAD_ID \r\n"
- " AND A.LEVL = 7 \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- String ID;
- String XAddr;
- String YAddr;
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- ID = pADO->FieldByName("ID")->AsString;
- //XAddr = pADO->FieldByName("X_CRDN_ARR")->AsWideString;
- //YAddr = pADO->FieldByName("Y_CRDN_ARR")->AsWideString;
- XAddr = "";
- YAddr = "";
- String sColNm;
- for (int ii = 1; ii < 24; ii++)
- {
- sColNm.printf(L"XMSG%02d", ii);
- XAddr += pADO->FieldByName(sColNm)->AsWideString;
- sColNm.printf(L"YMSG%02d", ii);
- YAddr += pADO->FieldByName(sColNm)->AsWideString;
- }
- fwprintf(fd, L"%s;%s;%s\n", ID.c_str(), XAddr.c_str(), YAddr.c_str());
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- fclose(fd);
- }
- pADO->Close();
- DB_CLOSE();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::WriteXmlHead(FILE *AFd, bool AHead/*=true*/)
- {
- try
- {
- if (AFd == NULL) return false;
- if (AHead)
- {
- fprintf(AFd, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
- fprintf(AFd, "<DataList>\n");
- }
- else
- {
- fprintf(AFd, "</DataList>\n");
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::WriteXmlObject(FILE *AFd, String AObject)
- {
- try
- {
- if (AFd == NULL) return false;
- fwprintf(AFd, L"<object>%s</object>\n", AObject.c_str());
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::WriteXmlRecordCount(FILE *AFd, int ARows)
- {
- try
- {
- if (AFd == NULL) return false;
- fprintf(AFd, "<count>%d</count>\n", ARows);
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeNodeXml(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Node.xml";
- FILE *fd = NULL;
- UpdateProgress(1, "노드정보 XML 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"노드정보 XML 파일을 생성하지 못하였습니다.",
- L"노드정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- WriteXmlHead(fd, true);
- WriteXmlObject(fd, "node");
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- sQry = "SELECT A.NODE_ID, A.NODE_TYPE, A.NODE_NAME, \r\n"
- " A.TURN_P, A.RMRK, A.X_CRDN, A.Y_CRDN \r\n"
- " FROM TB_NODE A \r\n"
- " ORDER BY A.NODE_ID \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- WriteXmlRecordCount(fd, nRows);
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- String NODE_ID = pADO->FieldByName("NODE_ID")->AsString; //노드ID
- //String NODE_TYPE = pADO->FieldByName("NODE_TYPE")->AsString; //노드유형
- String NODE_NAME = pADO->FieldByName("NODE_NAME")->AsString.Trim(); //교차로명칭
- //String TURN_P = pADO->FieldByName("TURN_P")->AsString; //회전제한유무
- //String RMRK = pADO->FieldByName("RMRK")->AsString.Trim(); //비고
- String X_CRDN = pADO->FieldByName("X_CRDN")->AsString; //X 좌표
- String Y_CRDN = pADO->FieldByName("Y_CRDN")->AsString; //Y 좌표
- fwprintf(fd, L" <node>");
- fwprintf(fd, L"<id>%s</id><x>%s</x><y>%s</y>", NODE_ID.c_str(), X_CRDN.c_str(), Y_CRDN.c_str());
- fprintf(fd, "<name>%s</name>", UTF8Encode(NODE_NAME).c_str());
- fwprintf(fd, L"</node>\n");
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- WriteXmlHead(fd, false);
- fclose(fd);
- }
- pADO->Close();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeLinkXml(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Link.xml";
- FILE *fd = NULL;
- UpdateProgress(1, "링크정보 XML 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"링크정보 XML 파일을 생성하지 못하였습니다.",
- L"링크정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- WriteXmlHead(fd);
- WriteXmlObject(fd, "link");
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- sQry = "SELECT A.LINK_ID, A.F_NODE, A.T_NODE, TRIM(A.ROAD_NAME) ROAD_NAME, \r\n"
- " NVL(B.NODE_NAME, '') F_NAME, NVL(C.NODE_NAME, '') T_NAME, \r\n"
- " A.ROAD_USE, A.LANES, A.ROAD_RANK, TRIM(A.ROAD_TYPE) AS ROAD_TYPE, A.ROAD_NO, \r\n"
- " A.MAX_SPD, A.LINK_LENG, A.DEL_YN, DECODE(A.AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
- " FROM TB_LINK A, TB_NODE B, TB_NODE C \r\n"
- " WHERE A.F_NODE = B.NODE_ID(+) \r\n"
- " AND A.T_NODE = C.NODE_ID(+) \r\n"
- " ORDER BY LINK_ID \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- WriteXmlRecordCount(fd, nRows);
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- String LINK_ID = pADO->FieldByName("LINK_ID")->AsString; //'링크ID';;
- String F_NODEID = pADO->FieldByName("F_NODE")->AsString; //'시작노드ID';;
- String T_NODEID = pADO->FieldByName("T_NODE")->AsString; //'종료노드ID';;
- String ROAD_NAME = pADO->FieldByName("ROAD_NAME")->AsString.Trim(); //'도로명';;
- String F_NAME = pADO->FieldByName("F_NAME")->AsString; //'시작노드';;
- String T_NAME = pADO->FieldByName("T_NAME")->AsString; //'종료노드';;
- String ROAD_USE = pADO->FieldByName("ROAD_USE")->AsString; //'도로사용여부';;
- String LANES = pADO->FieldByName("LANES")->AsString; //'차로수';;
- String ROAD_RANK = pADO->FieldByName("ROAD_RANK")->AsString; //'도로등급';;
- String ROAD_TYPE = pADO->FieldByName("ROAD_TYPE")->AsString; //'도로유형';;
- String ROAD_NO = pADO->FieldByName("ROAD_NO")->AsString; //'도로번호';;
- String MAX_SPD = pADO->FieldByName("MAX_SPD")->AsString; //'최고제한속도';;
- String LINK_LENG = pADO->FieldByName("LINK_LENG")->AsString; //'연장';;
- String DEL_YN = pADO->FieldByName("DEL_YN")->AsString; //'삭제 여부';;
- String REGN_YN = pADO->FieldByName("REGN_YN")->AsString; //'로컬지역여부';
- fwprintf(fd, L" <link>");
- fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
- LINK_ID.c_str(), F_NODEID.c_str(), T_NODEID.c_str(), ROAD_RANK.c_str(), LINK_LENG.c_str());
- fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
- UTF8Encode(ROAD_NAME).c_str(), UTF8Encode(F_NAME).c_str(), UTF8Encode(T_NAME).c_str());
- fwprintf(fd, L"</link>\n");
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- WriteXmlHead(fd, false);
- fclose(fd);
- }
- pADO->Close();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeIfscXml(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Ifsc.xml";
- FILE *fd = NULL;
- UpdateProgress(1, "정보제공구간 XML 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"정보제공구간 XML 파일을 생성하지 못하였습니다.",
- L"정보제공구간 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- WriteXmlHead(fd);
- WriteXmlObject(fd, "ifsc");
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- sQry = "SELECT IFSC_ID, IFSC_NM, DRCT_CD, STRT_NM, END_NM, SECT_LNGT, \r\n"
- " EXTR_CNCT_SECT_YN, DEL_YN, RMRK, F_NODE_ID, T_NODE_ID, \r\n"
- " SECT_GRAD_CD, AREA_CD, DECODE(AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
- " FROM TB_IFSC \r\n"
- " ORDER BY IFSC_ID \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- WriteXmlRecordCount(fd, nRows);
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- String IFSC_ID = pADO->FieldByName("IFSC_ID")->AsString;
- String IFSC_NM = pADO->FieldByName("IFSC_NM")->AsString.Trim();
- String DRCT_CD = pADO->FieldByName("DRCT_CD")->AsString;
- //String RMRK = pADO->FieldByName("RMRK")->AsString.Trim();
- //String EXTR_CNCT_SECT_YN = pADO->FieldByName("EXTR_CNCT_SECT_YN")->AsString;
- //String DEL_YN = pADO->FieldByName("DEL_YN")->AsString;
- String SECT_LNGT = pADO->FieldByName("SECT_LNGT")->AsString;
- //String SECT_GRAD_CD = pADO->FieldByName("SECT_GRAD_CD")->AsString;
- String F_NODE_ID = pADO->FieldByName("F_NODE_ID")->AsString;
- String T_NODE_ID = pADO->FieldByName("T_NODE_ID")->AsString;
- String STRT_NM = pADO->FieldByName("STRT_NM")->AsString.Trim();
- String END_NM = pADO->FieldByName("END_NM")->AsString.Trim();
- //String REGN_YN = pADO->FieldByName("REGN_YN")->AsString;
- //String AREA_CD = pADO->FieldByName("AREA_CD")->AsString;
- fwprintf(fd, L" <link>");
- fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
- IFSC_ID.c_str(), F_NODE_ID.c_str(), T_NODE_ID.c_str(), DRCT_CD.c_str(), SECT_LNGT.c_str());
- fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
- UTF8Encode(IFSC_NM).c_str(), UTF8Encode(STRT_NM).c_str(), UTF8Encode(END_NM).c_str());
- fwprintf(fd, L"</link>\n");
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- WriteXmlHead(fd, false);
- fclose(fd);
- }
- pADO->Close();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeRoadXml(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "Road.xml";
- FILE *fd = NULL;
- UpdateProgress(1, "도로정보 XML 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"도로정보 XML 파일을 생성하지 못하였습니다.",
- L"도로정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- WriteXmlHead(fd);
- WriteXmlObject(fd, "road");
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- sQry = "SELECT ROAD_ID, ROAD_NAME, DRCT_CD, STRT_NM, END_NM, \r\n"
- " DEL_YN, SECT_LNGT, F_NODE_ID, T_NODE_ID, \r\n"
- " SECT_GRAD_CD, AREA_CD, \r\n"
- " DECODE(AREA_CD, 'LAT001', 'Y', 'N') REGN_YN \r\n"
- " FROM TB_ROAD \r\n"
- //" WHERE DEL_YN = 'N' \r\n"
- " ORDER BY ROAD_ID \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- WriteXmlRecordCount(fd, nRows);
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- String ROAD_ID = pADO->FieldByName("ROAD_ID")->AsString;
- String ROAD_NAME = pADO->FieldByName("ROAD_NAME")->AsString.Trim();
- String DRCT_CD = pADO->FieldByName("DRCT_CD")->AsString;
- String STRT_NM = pADO->FieldByName("STRT_NM")->AsString.Trim();
- String END_NM = pADO->FieldByName("END_NM")->AsString.Trim();
- //String DEL_YN = pADO->FieldByName("DEL_YN")->AsString;
- String SECT_LNGT = pADO->FieldByName("SECT_LNGT")->AsString;
- String F_NODE_ID = pADO->FieldByName("F_NODE_ID")->AsString;
- String T_NODE_ID = pADO->FieldByName("T_NODE_ID")->AsString;
- //String SECT_GRAD_CD = pADO->FieldByName("SECT_GRAD_CD")->AsString;
- //String AREA_CD = pADO->FieldByName("AREA_CD")->AsString;
- //String REGN_YN = pADO->FieldByName("REGN_YN")->AsString;
- fwprintf(fd, L" <link>");
- fwprintf(fd, L"<id>%s</id><f_node>%s</f_node><t_node>%s</t_node><info>%s</info><dist>%s</dist>\n",
- ROAD_ID.c_str(), F_NODE_ID.c_str(), T_NODE_ID.c_str(), DRCT_CD.c_str(), SECT_LNGT.c_str());
- fprintf(fd, " <name>%s</name><f_name>%s</f_name><t_name>%s</t_name>",
- UTF8Encode(ROAD_NAME).c_str(), UTF8Encode(STRT_NM).c_str(), UTF8Encode(END_NM).c_str());
- fwprintf(fd, L"</link>\n");
- if ((nCnt % 50) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- WriteXmlHead(fd, false);
- fclose(fd);
- }
- pADO->Close();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmUtilMain::MakeRegionVertexXml(TADOQuery *pADO)
- {
- AnsiString sFile = ExtractFilePath(Application->ExeName) + XML_DIR+ "RegionVertex.xml";
- FILE *fd = NULL;
- UpdateProgress(1, "행정구역 Vertex XML 파일생성");
- if ((fd = fopen(sFile.c_str(), "w")) == NULL)
- {
- Application->MessageBox(L"행정구역 Vertex 정보 파일을 생성하지 못하였습니다.",
- L"행정구역 Vertex 정보 XML 파일생성", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- WriteXmlHead(fd);
- WriteXmlObject(fd, "region_vertex");
- int nRows= 0;
- int nCnt = 0;
- String sQry;
- try
- {
- try
- {
- sQry = "SELECT CONFIGSEQ AS ORD, COORDX AS X_CRDN, COORDY AS Y_CRDN \r\n"
- " FROM LINK_SUBSECTION \r\n"
- " WHERE SUBSECTIONKIND = 'B' \r\n"
- " AND DISPLAYLEVEL = 1 \r\n"
- " ORDER BY CONFIGSEQ \r\n";
- pADO->Close();
- pADO->SQL->Text = sQry;
- pADO->Open();
- nRows = pADO->RecordCount;
- cxProgressBar1->Properties->Max = nRows;
- WriteXmlRecordCount(fd, nRows);
- String sPosX = "";
- String sPosY = "";
- String sMinXY = "";
- String sMaxXY = "";
- int nOrd, nOrdCnt;
- nOrd = 1;
- for( ; !pADO->Eof; pADO->Next(), nCnt++)
- {
- sPosX += pADO->FieldByName("X_CRDN")->AsString;
- sPosY += pADO->FieldByName("Y_CRDN")->AsString;
- sPosX = sPosX.SubString(1, sPosX.Length()-1);
- sPosY = sPosY.SubString(1, sPosY.Length()-1);
- fwprintf(fd, L" <pos><order>%d</order><x>%s</x><y>%s</y></pos>\n", nOrd++, sPosX.c_str(), sPosY.c_str());
- sPosX = "";
- sPosY = "";
- if ((nCnt % 20) == 0) UpdateProgress(nCnt);
- }
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- return false;
- }
- }
- __finally
- {
- UpdateProgress(nRows);
- if (fd)
- {
- WriteXmlHead(fd, false);
- fclose(fd);
- }
- pADO->Close();
- }
- return true;
- }
- //---------------------------------------------------------------------------
|