일반적으로 GIS에서 데이터베이스를 구축하기 위해서 캐드에서 xdata형식으로 도형 키값을 만들고
오라클에서 도형 키와 연결되는 속성키를 생성하게 된다.
이때 shape 파일과 일반 테이블의 키 값이 잘 매칭되는지 확인해볼 필요가 있다.
이를 위해 도형과 일반테이블의 키값을 확인하는 스크립트가 필요하다.
theProject = av.GetProject
theDocList = theProject.GetDocs
theTblList = {}
DocCnt = theDocList.count
theNum = DocCnt-1
for each docName in 0..theNum
theDoc = theDocList.Get(docName)
DocStr = theDoc.AsString
if(DocStr.Contains(".dbf"))then
theTblList.add(theDoc)
end
end
theView = theProject.FindDoc("View1")
theTheme = theView.GetThemes.Get(0)
theFTab = theTheme.GetFTab
theFieldList = theFTab.GetFields
theKeyFieldSel = Msgbox.ListAsString(theFieldList, "KEY가 되는 필드를 선택하십시오.", "KEY필드 선택")
if(theKeyFieldSel=nil)then
exit
else
theKeyStr = theKeyFieldSel.AsString
theKeyField = theFTab.FindField(theKeyStr)
if(theKeyStr<>"Shape") then
theTblSel = Msgbox.ListAsString(theTblList, "매칭되는 속성테이블을 선택하십시오.", "테이블 선택")
if(theTblSel=nil)then
exit
else
theTblSelStr = theTblSel.AsString
theTbl = theProject.FindDoc(theTblSelStr)
theVTab = theTbl.GetVTab
theTblFieldList = theVTab.GetFields
theTblKeyFieldSel = Msgbox.ListAsString(theTblFieldList, "속성테이블의 KEY가 되는 필드를 선택하십시오.", "속성테이블 KEY필드 선택")
if(theTblKeyFieldSel=nil)then
exit
else
theTblKeyStr = theTblKeyFieldSel.AsString
theTblKeyField = theVTab.FindField(theTblKeyStr)
theShpList = {}
theAttList = {}
for each rec in theFTab
theStr = theFTab.ReturnValueString(theKeyField, rec)
theShpList.Add(theStr)
end
for each rec in theVTab
theTblStr = theVTab.ReturnValueString(theTblKeyField, rec)
theAttList.Add(theTblStr)
end
theShpErrorList={}
theAttErrorList={}
theShpListCnt = theShpList.Count
theShpListNum = theShpListCnt-1
theAttListCnt = theAttList.Count
theAttListNum = theAttListCnt-1
for each sel in 0..theShpListNum
theShpKey = theShpList.Get(sel)
theShpNum = theAttList.FindByValue (theShpKey)
if(theShpNum = -1)then
theShpErrorList.add(theShpKey)
end
end
for each sel in 0..theAttListNum
theAttKey = theAttList.Get(sel)
theAttNum = theShpList.FindByValue (theAttKey)
if(theAttNum = -1)then
theAttErrorList.add(theAttKey)
end
end
theShpErrorListCnt = theShpErrorList.count
theAttErrorListCnt = theAttErrorList.count
if(theShpErrorListCnt <> 0) then
edit_state = theFTab.IsEditable
theFTab.SetEditable(true)
ErrorField = Field.Make ("Err_shp",#FIELD_CHAR,40,0)
theFTab.AddFields({ErrorField})
theShpErrorListNum = theShpErrorListCnt-1
for each theShpVal in 0..theShpErrorListNum
theShpRlt = theShpErrorList.Get(theShpVal)
theShpRltStr = theShpRlt.AsString
theFTab.Query("(["+theKeyStr+"]="+theShpRltStr.quote+")",theFTab.GetSelection,#VTAB_SELTYPE_NEW)
ErrStr="도형에만 존재하는 값입니다."
for each rec1 in theFTab.GetSelection
theFTab.SetValueString(ErrorField, rec1, ErrStr)
end
end
theFTab.SetEditable(edit_state)
end
if(theAttErrorListCnt <> 0) then
edit_state = theVTab.IsEditable
theVTab.SetEditable(true)
ErrorField = Field.Make ("Err_tbl",#FIELD_CHAR,40,0)
theVTab.AddFields({ErrorField})
theAttErrorListNum = theAttErrorListCnt-1
for each theAttVal in 0..theAttErrorListNum
theAttRlt = theAttErrorList.Get(theAttVal)
theAttRltStr = theAttRlt.AsString
theVTab.Query("(["+theTblKeyStr+"]="+theAttRltStr.quote+")",theVTab.GetSelection,#VTAB_SELTYPE_NEW)
ErrStr="속성에만 존재하는 값입니다."
for each rec2 in theVTab.GetSelection
theVTab.SetValueString(ErrorField, rec2, ErrStr)
end
end
theVTab.SetEditable(edit_state)
end
end
end
else
Msgbox.Error("선택하신 "+theKeyStr+"필드는 KEY필드로 부적절 합니다.","KEY필드 선택 오류")
end
end


댓글을 달아 주세요