MapGis67读取点线区
#pragma pack(push, 1) #include "Win_area.h" #pragma pack(pop) //读取点文件 long CTerrionLableApp::ReadLableInfoFromFile() { CString cstrfilter, strPathName; char cszTextTemp[LEN_LONG_CODE] = ""; /* String strLabel;*/ char *szLabel = NULL; cstrfilter =_T("MapGis点文件(*.WT)|*.WT"); CFileDialog cFDlg(TRUE,_T(".xls"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,cstrfilter); if (cFDlg.DoModal() == IDOK) { strPathName.Format(_T("%s"),cFDlg.GetPathName()); } else return 0; AREA_HINST ahInst = NULL; short sPntAi = 0; long i = 0, lLGNum= 0, lPhyNum = 0; short lsize = 0; CATT_STRU *RAttStru = NULL; char *czAtt = NULL; CMineLabelStr mineLabel; D_DOT ddPos; m_vMineLabel.clear(); ahInst = _InitWorkArea(NULL); sPntAi = _OpenFileArea(ahInst, strPathName.GetBuffer(0)); _GetPntNum(sPntAi, &lLGNum, &lPhyNum); //得到 点的个数 PNT_INFO pntInfo; for (i = 0; i < lPhyNum; i++) { if (_GetPntExistFlag(sPntAi,i) !=1) continue; _GetPnt(sPntAi,i,&ddPos,&szLabel,&lsize,&pntInfo); mineLabel.m_lNO = i; mineLabel.m_strLabel= szLabel; mineLabel.m_lColorNo = pntInfo.iclr; // mineLabel.m_strType = pntInfo.info.text.ifnt; mineLabel.m_lSize = pntInfo.info.ch.height; _GetPntAtt(sPntAi,i,&RAttStru,&czAtt); _CvtFldToString1(RAttStru, czAtt, "坐标X", cszTextTemp, LEN_LONG_CODE, NULL, NULL); mineLabel.m_dPos.x = atof(cszTextTemp); _CvtFldToString1(RAttStru, czAtt, "坐标Y", cszTextTemp, LEN_LONG_CODE, NULL, NULL); mineLabel.m_dPos.y = atof(cszTextTemp); _CvtFldToString1(RAttStru, czAtt, "坐标Z", cszTextTemp, LEN_LONG_CODE, NULL, NULL); mineLabel.m_dPos.z = atof(cszTextTemp); m_vMineLabel.push_back(mineLabel); } _CloseArea(sPntAi); _FreeWorkArea(ahInst); return 1; } //读取线文件 long CCKQModelCls::GetRcdsFromLineWL(char *szLineFileName,CMineProfile *pMineProfile) { CATT_STRU *stru = NULL; char *att = NULL; long num = 0, lLgcNum = 0, lPhyNum = 0; char szFldValue[LEN_LONG_CODE]; int i = 0, j = 0,lRes = 0;; short ai = 0; char CrdID[LEN_LONG_CODE]; AREA_HINST ahist = _InitWorkArea(NULL); ai = _OpenFileArea(ahist, szLineFileName); if (ai == 0) { lRes = 0; goto EndPro; } if (_GetLinNum(ai, &lLgcNum, &lPhyNum) == 1) { for (i = 0; i < lPhyNum; i++) { if (_GetLinExistFlag(ai, i) != 1) { continue; } _GetLinAtt(ai, i, &stru, &att); if(_CvtFldToString1(stru,att,"储量边界类型",szFldValue,LEN_LONG_CODE,NULL,NULL) <= 0) continue; if (0 == strcmp(szFldValue,m_strType.GetBuffer(0)))//储量边界类型为1 { D_DOT *pDots = NULL; D_3DOT d3Dots; long lDotNum = 0, lType = 0, lFlag = 0; _GetLin(ai, i, &pDots, &lDotNum, NULL, NULL); m_pMineDataMng->ReadCoalPmType(pMineProfile->m_szKTXCode, &lType); if (lDotNum < 3) continue; v3Dots.clear(); for (j = 0; j < lDotNum; j++) { _GetOriPoint1(pMineProfile->m_d3StartPos,pMineProfile->m_d3EndPos,pDots[j],d3Dots,lType); v3Dots.push_back(d3Dots); } //判断是否封闭 if (fabs(v3Dots[0].x - v3Dots[lDotNum-1].x) > 0.0001 || fabs(v3Dots[0].y - v3Dots[lDotNum-1].y) > 0.0001 || fabs(v3Dots[0].z - v3Dots[lDotNum-1].z) > 0.0001) {//不封闭,添加最后一点为最初点 v3Dots.push_back(d3Dots); } if(_CvtFldToString1(stru,att,"ID",szFldValue,LEN_LONG_CODE,NULL,NULL) <= 0) continue; strcpy(CrdID, pMineProfile->m_szKTXCode); strcat(CrdID, "--"); strcat(CrdID, szFldValue); SaveRcdsToCkqCoord(CrdID,pMineProfile->m_szKTXCode); // m_v3DotList.push_back(v3Dots);//存储所有点到内存 if(-1 == DrawCkqLineArea(String(CrdID),pMineProfile->m_szKTXCode))//这里最好是一个不重复的字符,wl文件中获取 { lRes = 0; goto EndPro; } } } } lRes = 1; EndPro: _CloseArea(ai); _FreeWorkArea(ahist); return lRes; } ////////////////移动点////////////////////// long CPrjViewTool::MoveOreReservesTablePnt(short sPntAi, char * cszBlockCode,double dMoveHeight, double dMoveWeight) { D_DOT dDotPos; CATT_STRU *RAttStru = NULL; char *czAtt = NULL; long lLGNum = 0, lPhyNum = 0, i = 0; char cszTextTemp[LEN_LONG_CODE] = ""; _GetPntNum(sPntAi, &lLGNum, &lPhyNum); //得到 区的个数 for (i = 0; i <lPhyNum; i++) { if (_GetPntExistFlag(sPntAi,i) !=1) continue; _GetPntAtt(sPntAi,i,&RAttStru,&czAtt); _CvtFldToString1(RAttStru, czAtt, "块段编号", cszTextTemp, LEN_LONG_CODE, NULL, NULL); if (strcmp(cszBlockCode, cszTextTemp) == 0) { _GetPntPos(sPntAi,i,&dDotPos); dDotPos.x += dMoveWeight; dDotPos.y += dMoveHeight; _UpdatePntPos(sPntAi,i,&dDotPos); } } return 1; } ////////////////移动线///////////////////////////// long CPrjViewTool::MoveOreReservesTableLine(short sLineAi, char * cszBlockCode,double dMoveHeight, double dMoveWeight) { CATT_STRU *RAttStru = NULL; char *czAtt = NULL; long lLGNum = 0, lPhyNum = 0, i = 0, k = 0; char cszTextTemp[LEN_LONG_CODE] = ""; D_DOT *pLineDot; long lLineNum; _GetLinNum(sLineAi, &lLGNum, &lPhyNum); //得到 线的个数 for (i = 0; i <lPhyNum; i++) { if (_GetLinExistFlag(sLineAi,i) !=1) continue; _GetLinAtt(sLineAi,i,&RAttStru,&czAtt); _CvtFldToString1(RAttStru, czAtt, "块段编号", cszTextTemp, LEN_LONG_CODE, NULL, NULL); if (strcmp(cszBlockCode, cszTextTemp) == 0) { _GetLin(sLineAi,i,&pLineDot, &lLineNum, NULL); for (k = 0; k < lLineNum; k++) { pLineDot[k].x += dMoveWeight; pLineDot[k].y += dMoveHeight; } _UpdateLin(sLineAi,i,pLineDot, lLineNum, NULL); } } return 1; } //////////////////移动区//////////////////// long CPrjViewTool::MoveOreReservesTableReg(short sRegAi, char * cszBlockCode,double dMoveHeight, double dMoveWeight) { CATT_STRU *RAttStru = NULL; char *czAtt = NULL; long lLGNum = 0, lPhyNum = 0, i = 0, k = 0; char cszTextTemp[LEN_LONG_CODE] = ""; long * rdat = NULL; long len = 0; D_DOT * pRegDot = NULL; long lRegDotNum = 0; _GetRegNum(sRegAi, &lLGNum, &lPhyNum); //得到 区的个数 for (i = 0; i < lPhyNum; i ++) { if (_GetRegExistFlag(sRegAi,i) !=1) continue; _GetRegAtt(sRegAi,i,&RAttStru,&czAtt); _CvtFldToString1(RAttStru, czAtt, "块段编号", cszTextTemp, LEN_LONG_CODE, NULL, NULL); if (strcmp(cszBlockCode, cszTextTemp) == 0) { _GetReg(sRegAi, i, &rdat, &len, NULL); _GetLin(sRegAi,rdat[1], &pRegDot,&lRegDotNum, NULL); for (k = 0; k<lRegDotNum; k++) { pRegDot[k].x += dMoveWeight; pRegDot[k].y += dMoveHeight; } _UpdateLin(sRegAi,rdat[1],pRegDot, lRegDotNum, NULL); _UpdateReg(sRegAi, i, rdat, len, NULL); } } return 1; } long CPrjViewTool::DelPntLineReg() { //删除已经存在的旧的点线区 short sPntAi = 0; short sLineAi = 0; short sRegAi = 0; long lpti = 0, lLni = 0, lRegi; long lLgNum = 0,lPyNum = 0; CATT_STRU* CatStru; char* szAtt; long *rdat = NULL; long len = 0; sPntAi = GetPrjAi(m_PrjInfo.m_OrePrj, BLOCK_TABLE_WT, CUREDT); sLineAi = GetPrjAi(m_PrjInfo.m_OrePrj, BLOCK_TABLE_WL, CUREDT); sRegAi = GetPrjAi(m_PrjInfo.m_OrePrj, BLOCK_TABLE_WP, CUREDT); //删点 _GetPntNum(sPntAi,&lLgNum,&lPyNum); for (lpti = 0; lpti < lPyNum; lpti++) { if (_GetPntExistFlag(sPntAi,lpti) == 1) { _GetPntAtt(sPntAi,lpti,&CatStru,&szAtt); _DelPnt(sPntAi,lpti); } } //删线 lLgNum = 0,lPyNum = 0; _GetLinNum(sLineAi,&lLgNum,&lPyNum); for (lLni = 0; lLni < lPyNum; lLni++) { if (_GetLinExistFlag(sLineAi,lLni) == 1) { _GetLinAtt(sLineAi,lLni,&CatStru,&szAtt); _DelLin(sLineAi,lLni); } } //删区 lLgNum = 0,lPyNum = 0; _GetRegNum(sRegAi, &lLgNum, &lPyNum); for (lRegi = 0; lRegi < lPyNum; lRegi ++) { if (_GetRegExistFlag(sRegAi, lRegi) == 1) { _GetReg(sRegAi, lRegi, &rdat, &len, NULL); _DelLin(sRegAi, rdat[1]); _DelReg(sRegAi, lRegi); } } return 1; } //////////////////////////////写点属性/////////////////////////// long CPrjViewTool::WritePntAtt(short sPntAi, long * spti, char * cBlockCode, char * cNoteType) { CATT_STRU *RAttStru = NULL; char *czAtt = NULL; long i = 0; // ExtendPntAtt(sPntAi); _GetPntAtt(sPntAi,* spti,&RAttStru,&czAtt); _SetFldFromStr(czAtt,RAttStru,"块段编号",cBlockCode); _SetFldFromStr(czAtt,RAttStru,"注记类型",cNoteType); _WritePntAtt(sPntAi,* spti,RAttStru,czAtt); // _SaveFile(sPntAi); return 1; } long CPrjViewTool::ExtendPntAtt(short sPntAi) { long lNum = 0, i = 0; CATT_STRU *RAttStru = NULL; short sFlg = FALSE; CFIELD_HEAD FldEntry;//坐标 _GetPntAttStru(sPntAi, &RAttStru); lNum = RAttStru->hd.numbfield; if(lNum > 2) return TRUE; FldEntry.fieldtype = STR_TYPE; FldEntry.fieldlength = LEN_LONG_CODE; FldEntry.msk_leng = MAX_PATH; FldEntry.edit_enable = FLDEDT_YES; strcpy(FldEntry.fieldname,"块段编号"); _AppendPntStruFld(sPntAi, 1, &FldEntry); strcpy(FldEntry.fieldname,"注记类型"); _AppendPntStruFld(sPntAi, 1, &FldEntry); return 1; } /////////////////////////写线属性///////////////////////////////// long CPrjViewTool::WriteLineAtt(short sLineAi, long sLni, char * cBlockCode, char * cNoteType) { CATT_STRU *RAttStru = NULL; char *czAtt = NULL; // ExtendLineAtt(sLineAi); _GetLinAtt(sLineAi,sLni,&RAttStru,&czAtt); _SetFldFromStr(czAtt,RAttStru,"块段编号",cBlockCode); _SetFldFromStr(czAtt,RAttStru,"注记类型",cNoteType); _WriteLinAtt(sLineAi,sLni,RAttStru,czAtt); // _SaveFile(sLineAi); return 1; } long CPrjViewTool::ExtendLineAtt(short sLineAi) { long lNum = 0, i = 0; CATT_STRU *RAttStru = NULL; short sFlg = FALSE; CFIELD_HEAD FldEntry;//坐标 _GetLinAttStru(sLineAi, &RAttStru); lNum = RAttStru->hd.numbfield; if(lNum > 2) return TRUE; FldEntry.fieldtype = STR_TYPE; FldEntry.fieldlength = LEN_LONG_CODE; FldEntry.msk_leng = MAX_PATH; FldEntry.edit_enable = FLDEDT_YES; strcpy(FldEntry.fieldname,"块段编号"); _AppendLinStruFld(sLineAi, 1, &FldEntry); strcpy(FldEntry.fieldname,"注记类型"); _AppendLinStruFld(sLineAi, 1, &FldEntry); return 1; } //////////////////写区属性//////////////////////////////// long CPrjViewTool::WriteRegAtt(short sRegAi, long sRgi, char * cBlockCode, char * cNoteType) { CATT_STRU *RAttStru = NULL; char *czAtt = NULL; // ExtendRegAtt(sRegAi); _GetRegAtt(sRegAi,sRgi,&RAttStru,&czAtt); _SetFldFromStr(czAtt,RAttStru,"块段编号",cBlockCode); _SetFldFromStr(czAtt,RAttStru,"注记类型",cNoteType); _WriteRegAtt(sRegAi,sRgi,RAttStru,czAtt); // _SaveFile(sRegAi); return 1; } long CPrjViewTool::ExtendRegAtt(short sRegAi) { long lNum = 0, i = 0; CATT_STRU *RAttStru = NULL; short sFlg = FALSE; CFIELD_HEAD FldEntry;//坐标 _GetRegAttStru(sRegAi, &RAttStru); lNum = RAttStru->hd.numbfield; if(lNum > 2) return TRUE; FldEntry.fieldtype = STR_TYPE; FldEntry.fieldlength = LEN_LONG_CODE; FldEntry.msk_leng = MAX_PATH; FldEntry.edit_enable = FLDEDT_YES; strcpy(FldEntry.fieldname,"块段编号"); _AppendRegStruFld(sRegAi, 1, &FldEntry); strcpy(FldEntry.fieldname,"注记类型"); _AppendRegStruFld(sRegAi, 1, &FldEntry); return 1; }