Sie sind auf Seite 1von 36

FindBasin

theView=av.GetActiveDoc
theDir=av.GetProject.GetWorkDir
'
thm=nil
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="Basins.shp") then
thm=t
end
end
if (thm=nil) then
MsgBox.Error(" Basins.shp!","")
exit
end
'
theFtab=thm.GetFtab
theNameFld=theFtab.FindField("River")
theLonFld=theFtab.FindField("Lon")
theLatFld=theFtab.FindField("Lat")
theAreaFld=theFtab.FindField("Area")
thePerimeterFld=theFtab.FindField("Perimeter")
theBitMap=theFtab.GetSelection
theBitMap.ClearAll '
theFTab.SetSelection(theBitMap)
'
MethodSearch=MsgBox.YesNo(" (Yes)
(No)?","",True)
if (MethodSearch=True) then
'
ListName=List.Make
for each rec in theFtab
ListName.Add(theFtab.ReturnValue(theNameFld,rec))
end
Listname_=Listname.Clone
Listname_.RemoveDuplicates
Listname_.Sort(true)
ChoiceName=MsgBox.ChoiceAsString(Listname_," ","")
if (ChoiceName=nil) then
exit
end
' c
theBitMap=theFTab.GetSelection
QQ="( [River] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
theBitMap=theFTab.GetSelection
if (theBitMap.Count>1) then ' ,

theListCoord=List.Make
theListStr=List.Make
for each rec in theBitMap
Lat=theFtab.ReturnValue(theLatFld,rec)

Lon=theFtab.ReturnValue(theLonFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString++" "+LatMin.AsString+"'"++LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString++" "+LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=ChoiceName++""++LatStr++""++LonStr
theListCoord.Add({LatLonStr,Lon,Lat})
theListStr.Add(LatLonStr)
end
theListStr.Sort(true) '
ChoiceChar=MsgBox.ChoiceAsString(theListStr,"
","")
if (ChoiceChar=nil) then
exit
end
for each i in 0..(theListCoord.Count-1)
theEl=theListCoord.Get(i)
if (theEl.Get(0)=ChoiceChar) then
Lon1=theEl.Get(1)
Lat1=theEl.Get(2)
end
end
Lon1.SetFormat("dd.ddddd")
Lat1.SetFormat("dd.ddddd")
theBitMap=theFTab.GetSelection
QQ="( ( [Lat] ="++Lat1.AsString++") and ( [Lon] ="++Lon1.AsString++") )"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end
end
'----------------else
'
theListCoord=List.Make
theListStr=List.Make
for each rec in theFtab
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString++" "+LatMin.AsString+"'"++LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString++" "+LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr

theListCoord.Add({LatLonStr,Lon,Lat})
theListStr.Add(LatLonStr)
end
theListStr.Sort(true) '
ChoiceChar=MsgBox.ChoiceAsString(theListStr,"
","")
if (ChoiceChar=nil) then
exit
end
for each i in 0..(theListCoord.Count-1)
theEl=theListCoord.Get(i)
if (theEl.Get(0)=ChoiceChar) then
Lon1=theEl.Get(1)
Lat1=theEl.Get(2)
end
end
Lon1.SetFormat("dd.ddddd")
Lat1.SetFormat("dd.ddddd")
theBitMap=theFTab.GetSelection
QQ="( ( [Lat] ="++Lat1.AsString++") and ( [Lon] ="++Lon1.AsString++") )"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
'----------------end
theBitMap=theFTab.GetSelection
for each rec in theBitMap
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
Area=(theFtab.ReturnValue(theAreaFld,rec))/1000000 Area.SetFormat("d.d")
Perimeter=theFtab.ReturnValue(thePerimeterFld,rec)/1000
Perimeter.SetFormat("d.d")
River=theFtab.ReturnValue(theNameFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString+176.AsChar++LatMin.AsString+"'"+
+LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString+176.AsChar++LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr
end
TheStr=""++River+NL+
"..:"++LatLonStr+NL+
" = "+Area.AsString++"."+NL+
" = "+Perimeter.AsString++""
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)

else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
MsgBox.Report(theStr,"")
Clipboard.The.Empty
Clipboard.The.Add(TheStr)
Clipboard.The.Update
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochem.shp"))
then
t.SetVisible(true)
end
end
theView.Invalidate
'StrOut="c:\Program Files\Microsoft Office\Office10\msaccess.exe ""c:\reestraltay\reestr.mdb""/cmd basin,"
'StrOut="d:\Program Files\Microsoft Office\Office10\msaccess.exe ""c:\reestraltay\reestr.mdb""/cmd river,,,"
'StrOut=StrOut++ChoiceName
'System.Execute(StrOut)
StrOut="c:\reestr-altay\reestr.bat"
StrOut=StrOut+" river!"+" !"+" ! "+ChoiceName
System.Execute(StrOut)
'StrOut="c:\reestr-altay\reestr.bat"
'
'StrOut=StrOut+" lake!"+" !"+" ! "+ChoiceName
'System.Execute(StrOut)

Find GidrochemPunkt
theView=av.GetActiveDoc
theDir=av.GetProject.GetWorkDir
'
theBase=av.GetProject.FindDoc("base.dbf")
BaseVtab=theBase.GetVtab
'bIdFld=BaseVtab.FindField("Id")
bInfoFld=BaseVtab.FindField("A1")
bWeshFld=BaseVtab.FindField("Wesh")
bDateFld=BaseVtab.FindField("A2")
bQFld=BaseVtab.FindField("A6")
bCFld=BaseVtab.FindField("C")
'
thm=nil
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="hydrochemy.shp") then
thm=t
end
end
if (thm=nil) then
MsgBox.Error(" hydrochemy.shp!","")
exit
end
'
theFtab=thm.GetFtab
theInfoFld=theFtab.FindField("S_c10")
theIdFld=theFtab.FindField("Id")
theBitMap=theFtab.GetSelection
theBitMap.ClearAll '
theFTab.SetSelection(theBitMap)
ListSpec=List.Make
ListName=List.Make
ListName_=List.Make
for each rec in theFtab
Name=theFtab.ReturnValue(theInfoFld,rec)
Name_=Name
ListName_.Add(Name_)
ListSpec.Add({Name_,Name})
end
ListName_.Sort(True)
for each i in 0..(ListName_.Count-1)
SearchName=ListName_.Get(i)
for each j in 0..(ListSpec.Count-1)
El=ListSpec.Get(j)
if (El.Get(0)=SearchName) then
ListName.Add(El.Get(1))
end
end
end
'
ChoiceName=MsgBox.ChoiceAsString(ListName," ","")
if (ChoiceName=nil) then

exit
end
' c
theBitMap=theFTab.GetSelection
QQ="( [S_c10] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
btheBM=theFtab.GetSelection
for each rec in theBitMap 'theBM
bId=theFtab.ReturnValue(theIdFld,rec)
end
if (btheBM.Count=0) then
MsgBox.Info("bbbbbbbbbbb","")
end
'
theBM=BaseVTab.GetSelection
QQ="( [A1] ="++34.AsChar+bId.AsString+34.AsChar++")"
if (BaseVTab.Query(QQ,theBM,#VTAB_SELTYPE_NEW)) then
BaseVtab.UpdateSelection
end
theBM=BaseVTab.GetSelection
if (theBM.Count=0) then
MsgBox.Info(" ","")
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
theView.GetDisplay.ZoomToScale (200000)
else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochemy.shp"))
then
t.SetVisible(true)
end
end
theView.Invalidate
exit

end
' ,
Str1=" "
Str2=" "
MethodSearch=MsgBox.YesNo(Str1+" (Yes) "+Str2+" (No)?","",True)
'
ListWesh=List.Make
for each rec in theBM
Wesh=BaseVtab.ReturnValue(bWeshFld,rec)
ListWesh.Add(Wesh)
end
ListWesh.RemoveDuplicates
ListWesh.Sort(true) '
if (MethodSearch=True) then
'
'
ChoiceWesh=MsgBox.ChoiceAsString(ListWesh,"
","")
if (ChoiceWesh=nil) then
exit
end
theBM=BaseVTab.GetSelection
QQ="( [Wesh] ="++34.AsChar+ChoiceWesh+34.AsChar++")"
if (BaseVTab.Query(QQ,theBM,#VTAB_SELTYPE_AND)) then
BaseVTab.UpdateSelection
end
theBM=BaseVTab.GetSelection
'
ListData=List.Make
ListDate=List.Make
for each rec in theBM
theDate=BaseVtab.ReturnValue(bDateFld,rec)
theDate.SetFormat("yyyy.MM.dd")
myDateString= theDate.AsString
theC=BaseVtab.ReturnValue(bCFld,rec)
theQ=BaseVtab.ReturnValue(bQFld,rec)
ListData.Add({myDateString,theC,theQ})
ListDate.Add(myDateString)
end
'
ListDate.Sort(True)
InfoStr=" "+NL+
ChoiceName+NL+
" : "+ChoiceWesh+NL
for each i in 0..(ListDate.Count-1)
myDateString=ListDate.Get(i)
for each j in 0..(ListData.Count-1)
El=ListData.Get(j)
if (El.Get(0)=myDateString) then
myC=El.Get(1)
myQ=El.Get(2)
end
end
myQ.SetFormat("d.dd")

myC.SetFormat("d.ddddd")
if ((myQ=0) or (myQ=99999.99)) then
myQString=""
else
myQString=myQ.AsString
end
InfoStr=InfoStr+myDateString++" C= "+myC.AsString++", Q= "+MyQString+NL
end
else
'
'
InfoStr=" "+NL+
ChoiceName+NL
'
for each k in 0..(ListWesh.Count-1)
ChoiceWesh=ListWesh.Get(k)
theBM=BaseVTab.GetSelection
QQ="(( [Wesh] ="++34.AsChar+ChoiceWesh+34.AsChar++")"++"and"++
"( [A1] ="++34.AsChar+bId.AsString+34.AsChar++"))"
if (BaseVTab.Query(QQ,theBM,#VTAB_SELTYPE_NEW)) then
BaseVTab.UpdateSelection
end
theBM=BaseVTab.GetSelection
kkk=theBM.Count'''''''''''''''''''''''''''''''''
'
ListData=List.Make
ListDate=List.Make
for each rec in theBM
theDate=BaseVtab.ReturnValue(bDateFld,rec)
theDate.SetFormat("yyyy.MM.dd")
myDateString= theDate.AsString
theC=BaseVtab.ReturnValue(bCFld,rec)
theQ=BaseVtab.ReturnValue(bQFld,rec)
ListData.Add({myDateString,theC,theQ})
ListDate.Add(myDateString)
end
'
ListDate.Sort(True)
lll=ListDate.Count ''''''''''''''''''''''''''''''''
InfoStr=InfoStr+" : "+ChoiceWesh+NL
for each i in 0..(ListDate.Count-1)
myDateString=ListDate.Get(i)
for each j in 0..(ListData.Count-1)
El=ListData.Get(j)
if (El.Get(0)=myDateString) then
myC=El.Get(1)
myQ=El.Get(2)
end
end
myQ.SetFormat("d.dd")
myC.SetFormat("d.ddddd")
if ((myQ=0) or (myQ=99999.99)) then
myQString=""
else
myQString=myQ.AsString
end
InfoStr=InfoStr+myDateString++" C= "+myC.AsString++", Q= "+MyQString+NL

end
end
end
MsgBox.Report(InfoStr,"")
Clipboard.The.Empty
Clipboard.The.Add(InfoStr)
Clipboard.The.Update
'
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
theView.GetDisplay.ZoomToScale (200000)
else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
theView.Invalidate
for each t in theView.GetThemes
if (t=thm) then
t.SetActive(true)
else
t.SetActive(false)
end
end
theView.CopyThemes
theView.DeleteTheme(thm)
theView.Paste
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochemy.shp"))
then
t.SetVisible(true)
end
end
theView.Invalidate

FindLake
theView=av.GetActiveDoc
theDir=av.GetProject.GetWorkDir
'
thm=nil
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp") then
thm=t
end
end
if (thm=nil) then
MsgBox.Error(" lake_polygon_update.shp!","")
exit
end
'
theFtab=thm.GetFtab
theNameFld=theFtab.FindField("Name")
theBasinFld=theFtab.FindField("Basin")
theRegionFld=theFtab.FindField("Region")
theLonFld=theFtab.FindField("Lon")
theLatFld=theFtab.FindField("Lat")
theAreaFld=theFtab.FindField("Area_")
thePerimeterFld=theFtab.FindField("Per_")
theWatFld=theFtab.FindField("Is_wat")
theIdFld=theFtab.FindField("Id1")
theBitMap=theFtab.GetSelection
theBitMap.ClearAll '
theFTab.SetSelection(theBitMap)
'
MethodSearch=MsgBox.YesNo(" (Yes)
(No)?","",True)
if (MethodSearch=True) then
'
ListName=List.Make
for each rec in theFtab
ListName.Add(theFtab.ReturnValue(theNameFld,rec))
end
Listname_=Listname.Clone
Listname_.RemoveDuplicates
Listname_.Sort(true)
ChoiceName=MsgBox.ChoiceAsString(Listname_," ","")
if (ChoiceName=nil) then
exit
end
' c
theBitMap=theFTab.GetSelection
QQ="( [Name] ="+ChoiceName.Quote+")"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
theBitMap=theFTab.GetSelection
ListId=List.Make

for each rec in theBitMap


theId=theFtab.ReturnValue(theIdFld,rec)
ListId.Add(theId)
end
ListId.RemoveDuplicates
if (theBitMap.Count>1) then ' ,

' ,
ListBasin=List.Make
for each rec in theBitMap
theBasin=theFtab.ReturnValue(theBasinFld,rec)
ListBasin.Add(theBasin)
end
ListBasin.RemoveDuplicates
' ,
if (ListBasin.Count>1) then
ListBasin.Sort(True)
ChoiceBasin=MsgBox.ChoiceAsString(ListBasin," "+ChoiceName+
" ","")
if (ChoiceBasin=nil) then
exit
end
theBitMap=theFTab.GetSelection
QQ1="([Basin] ="++34.AsChar+ChoiceBasin+34.AsChar++")"
if (theFTab.Query(QQ1,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end
else
ChoiceBasin=ListBasin.Get(0)
end
theBitMap=theFTab.GetSelection
theBitMap=theFTab.GetSelection
ListRegion=List.Make
for each rec in theBitMap
theRegion=theFtab.ReturnValue(theRegionFld,rec)
ListRegion.Add(theRegion)
end
ListRegion.RemoveDuplicates
' ,
if (ListRegion.Count>1) then
ListRegion.Sort(True)
ChoiceRegion=MsgBox.ChoiceAsString(ListRegion," "+ChoiceName+
" ","")
if (ChoiceRegion=nil) then
exit
end
theBitMap=theFTab.GetSelection
QQ1="([Region] ="++34.AsChar+ChoiceRegion+34.AsChar++")"
if (theFTab.Query(QQ1,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end

else
ChoiceRegion=ListRegion.Get(0)
end
theBitMap=theFTab.GetSelection

end
'----------------else
'
theListCoord=List.Make
theListStr=List.Make
for each rec in theFtab
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString++" "+LatMin.AsString+"'"++LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString++" "+LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr
theListCoord.Add({LatLonStr,Lon,Lat})
theListStr.Add(LatLonStr)
end
theListStr.Sort(true) '
ChoiceChar=MsgBox.ChoiceAsString(theListStr,"
","")
if (ChoiceChar=nil) then
exit
end
for each i in 0..(theListCoord.Count-1)
theEl=theListCoord.Get(i)
if (theEl.Get(0)=ChoiceChar) then
Lon1=theEl.Get(1)
Lat1=theEl.Get(2)
end
end
Lon1.SetFormat("dd.ddddd")
Lat1.SetFormat("dd.ddddd")
theBitMap=theFTab.GetSelection
QQ="( ( [Lat] ="++Lat1.AsString++") and ( [Lon] ="++Lon1.AsString++") )"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
for each rec in theBitMap
ChoiceName=theFtab.ReturnValue(theNameFld,rec)
end

'----------------end
CountWat=0
theBitMap=theFTab.GetSelection
for each rec in theBitMap
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
Area=(theFtab.ReturnValue(theAreaFld,rec))/1000000 Area.SetFormat("d.d")
Perimeter=theFtab.ReturnValue(thePerimeterFld,rec)/1000
Perimeter.SetFormat("d.d")
Name=theFtab.ReturnValue(theNameFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString+176.AsChar++LatMin.AsString+"'"+
+LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString+176.AsChar++LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr
theWat=theFtab.ReturnValue(theWatFld,rec)
if(theWat="w") then
CountWat=CountWat+1 ',

end
end
theStrAddBas=""
'
if(CountWat>0) then
theDocTabl=av.FindDoc(" .dbf")
theTabl=theDocTabl.GetVTab
theTablBasin=theTabl.FindField("Lake")
theTablRegion=theTabl.FindField("Region")
theTablScom=theTabl.FindField("S_com")
theTablS=theTabl.FindField("S_part")
theTablProc=theTabl.FindField("Procent")
theBitMapTab=theTabl.GetSelection
QQ="( [Lake] ="+ChoiceName.Quote+")"
if (theTabl.Query(QQ,theBitMapTab,#VTAB_SELTYPE_NEW)) then
theTabl.UpdateSelection
end
theBitMapTab=theTabl.GetSelection
theStrAddBas2=" "
for each rec in theBitMapTab
theSComBas=theTabl.ReturnValue(theTablScom,rec)
theReg=theTabl.ReturnValue(theTablRegion,rec)
theS=theTabl.ReturnValue(theTablS,rec)
thePr=theTabl.ReturnValue(theTablProc,rec)
theS=theS/1000000

theStrAddBas2=theStrAddBas2++" "+theReg++"-"+":"++theS.AsString+
+".:"++
"("+thePr.AsString+"%)"+NL
end
theSComBas=theSComBas/1000000
theStrAddBas=" . . - "+theSComBas.AsString++".:"+NL+
theStrAddBas2
end
TheStr=""++Name+NL+
"..:"++LatLonStr+NL+
" = "+Area.AsString++"."+NL+
" = "+Perimeter.AsString++""+NL+NL+
theStrAddBas
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
MsgBox.Report(theStr,"")
Clipboard.The.Empty
Clipboard.The.Add(TheStr)
Clipboard.The.Update
'StrOut="d:\Program Files\Microsoft Office\Office10\msaccess.exe ""c:\reestraltay\reestr.mdb""/cmd lake,"
'StrOut=StrOut++ChoiceName
StrOut="c:\reestr-altay\reestr.bat"
StrOut=StrOut+" lake!"+ChoiceName
System.Execute(StrOut)
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochem.shp"))
then
t.SetVisible(true)
end
end
theView.Invalidate

FindRegion
theView=av.GetActiveDoc
theDir=av.GetProject.GetWorkDir
'
thm=nil
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="Regions.shp") then
thm=t
end
end
if (thm=nil) then
MsgBox.Error(" Regions.shp!","")
exit
end
'
theFtab=thm.GetFtab
theNameFld=theFtab.FindField("region")
theLonFld=theFtab.FindField("Lon")
theLatFld=theFtab.FindField("Lat")
theAreaFld=theFtab.FindField("Area")
thePerimeterFld=theFtab.FindField("Perimeter")
theBitMap=theFtab.GetSelection
theBitMap.ClearAll '
theFTab.SetSelection(theBitMap)
'
MethodSearch=MsgBox.YesNo(" (Yes)
(No)?","",True)
if (MethodSearch=True) then
'
ListName=List.Make
for each rec in theFtab
ListName.Add(theFtab.ReturnValue(theNameFld,rec))
end
Listname_=Listname.Clone
Listname_.RemoveDuplicates
Listname_.Sort(true)
ChoiceName=MsgBox.ChoiceAsString(Listname_," ","")
if (ChoiceName=nil) then
exit
end
' c
theBitMap=theFTab.GetSelection
QQ="( [region] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
theBitMap=theFTab.GetSelection
if (theBitMap.Count>1) then ' ,

theListCoord=List.Make
theListStr=List.Make
for each rec in theBitMap
Lat=theFtab.ReturnValue(theLatFld,rec)

Lon=theFtab.ReturnValue(theLonFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString+176.AsChar+LatMin.AsString+"'"+
+LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString+176.AsChar+LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=ChoiceName++""++LatStr++""++LonStr
theListCoord.Add({LatLonStr,Lon,Lat})
theListStr.Add(LatLonStr)
end
theListStr.Sort(true) '
ChoiceChar=MsgBox.ChoiceAsString(theListStr,"
","")
if (ChoiceChar=nil) then
exit
end
for each i in 0..(theListCoord.Count-1)
theEl=theListCoord.Get(i)
if (theEl.Get(0)=ChoiceChar) then
Lon1=theEl.Get(1)
Lat1=theEl.Get(2)
end
end
Lon1.SetFormat("dd.ddddd")
Lat1.SetFormat("dd.ddddd")
theBitMap=theFTab.GetSelection
QQ="( ( [Lat] ="++Lat1.AsString++") and ( [Lon] ="++Lon1.AsString++") )"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end
end
'----------------else
'
theListCoord=List.Make
theListStr=List.Make
for each rec in theFtab
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString++" "+LatMin.AsString+"'"++LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString++" "+LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr

theListCoord.Add({LatLonStr,Lon,Lat})
theListStr.Add(LatLonStr)
end
theListStr.Sort(true) '
ChoiceChar=MsgBox.ChoiceAsString(theListStr,"
","")
if (ChoiceChar=nil) then
exit
end
for each i in 0..(theListCoord.Count-1)
theEl=theListCoord.Get(i)
if (theEl.Get(0)=ChoiceChar) then
Lon1=theEl.Get(1)
Lat1=theEl.Get(2)
end
end
Lon1.SetFormat("dd.ddddd")
Lat1.SetFormat("dd.ddddd")
theBitMap=theFTab.GetSelection
QQ="( ( [Lat] ="++Lat1.AsString++") and ( [Lon] ="++Lon1.AsString++") )"
if (theFTab.Query(QQ,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
'----------------end
theBitMap=theFTab.GetSelection
for each rec in theBitMap
Lat=theFtab.ReturnValue(theLatFld,rec)
Lon=theFtab.ReturnValue(theLonFld,rec)
Area=(theFtab.ReturnValue(theAreaFld,rec))/1000000 Area.SetFormat("d.d")
Perimeter=theFtab.ReturnValue(thePerimeterFld,rec)/1000
Perimeter.SetFormat("d.d")
region=theFtab.ReturnValue(theNameFld,rec)
LatDeg=Lat.Floor
LatMin=((Lat-LatDeg)*60).Floor
LatSec=((Lat-LatDeg-(LatMin/60))*3600).Floor
LatDeg.SetFormat("d")
LatMin.SetFormat("d") LatSec.SetFormat("d")
LatStr=LatDeg.AsString+176.AsChar++LatMin.AsString+"'"+
+LatSec.AsString+34.AsChar
LonDeg=Lon.Floor
LonMin=((Lon-LonDeg)*60).Floor
LonSec=((Lon-LonDeg-(LonMin/60))*3600).Floor
LonDeg.SetFormat("d")
LonMin.SetFormat("d") LonSec.SetFormat("d")
LonStr=LonDeg.AsString+176.AsChar++LonMin.AsString+"'"+
+LonSec.AsString+34.AsChar
LatLonStr=""++LatStr++""++LonStr
end
TheStr=""++region+NL+
"..:"++LatLonStr+NL+
" = "+Area.AsString++"."+NL+
" = "+Perimeter.AsString++""
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)

else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
MsgBox.Report(theStr,"")
Clipboard.The.Empty
Clipboard.The.Add(TheStr)
Clipboard.The.Update
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochem.shp"))
then
t.SetVisible(true)
end
end
thm.SetVisible(true)
theView.Invalidate
'StrOut="d:\Program Files\Microsoft Office\Office10\msaccess.exe ""c:\reestraltay\reestr.mdb""/cmd region,"
'StrOut=StrOut++ChoiceName
StrOut="c:\reestr-altay\reestr.bat"
StrOut=StrOut+" river!"+" !"
StrOut=StrOut+ChoiceName
System.Execute(StrOut)
StrOut="c:\reestr-altay\reestr.bat"
'StrOut=StrOut+" lake!"+" !"
'StrOut=StrOut+ChoiceName
'System.Execute(StrOut)

FindRiver
theView=av.GetActiveDoc
theDir=av.GetProject.GetWorkDir
'
thm=nil
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")
then
thm=t
end
end
if (thm=nil) then
MsgBox.Error(" river_1_polyline_update.shp","")
exit
end
for each t in theView.GetThemes
if (t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp") then
thm_poly=t
end
end
if (thm=nil) then
MsgBox.Error(" river_1_region_update.shp!","")
exit
end

'
theFtab=thm.GetFtab
theNameFld=theFtab.FindField("Name")
theLengthFld=theFtab.FindField("Length_")
theLengthFld1=theFtab.FindField("Length")
theBasinFld=theFtab.FindField("Basin")
theRegionFld=theFtab.FindField("Region")
theWatFld=theFtab.FindField("Is_wat")
theIdFld=theFtab.FindField("Id_r1")
theFtabP=thm_poly.GetFtab
theNameFldP=theFtabP.FindField("Name")
theLengthFldP=theFtabP.FindField("Length_")
theLenFldP=theFtabP.FindField("Length")
theBasinFldP=theFtabP.FindField("Basin")
theRegionFldP=theFtabP.FindField("Region")
theWatFldP=theFtabP.FindField("Is_wat")
theBitMap=theFtab.GetSelection
theBitMap.ClearAll '
theFTab.SetSelection(theBitMap)
theBitMapP=theFtabP.GetSelection
theBitMapP.ClearAll '
theFTabP.SetSelection(theBitMapP)
'
ListName=List.Make

for each rec in theFtab


ListName.Add(theFtab.ReturnValue(theNameFld,rec))
end
Listname_=Listname.Clone
Listname_.RemoveDuplicates
Listname_.Add("")
Listname_.Add("")
Listname_.Add("")
Listname_.Sort(true)
ChoiceName=MsgBox.ChoiceAsString(Listname_," ","")
if ((ChoiceName=nil) or (ChoiceName="")) then
exit
end
'StrOut="c:\Program Files\Microsoft Office\Office10\msaccess.exe c:\reestraltay\200\reestr.mde /cmd river,"
'StrOut="d:\Program Files\Microsoft Office\Office10\msaccess.exe ""c:\reestraltay\reestr.mdb""/cmd river,"
' StrOut="c:\reestr-altay\200\reestr.mde /cmd river"
'StrOut=StrOut+ChoiceName
StrOut="c:\reestr-altay\reestr.bat"
StrOut=StrOut+" river!"+ChoiceName
if (ChoiceName="") then
theBitMapP=theFTabP.GetSelection
QQ0=" ([Name] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTabP.Query(QQ0,theBitMapP,#VTAB_SELTYPE_NEW)) then
theFtabP.UpdateSelection
end
r = Rect.MakeEmpty
r = r.UnionWith(thm_poly.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
System.Execute(StrOut)
exit
elseif ((ChoiceName="") or (ChoiceName="")) then
theBitMapP=theFTabP.GetSelection
QQ0=" ([Name] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTabP.Query(QQ0,theBitMapP,#VTAB_SELTYPE_NEW)) then
theFtabP.UpdateSelection
end
theDocTabl=av.FindDoc(" .dbf")
theTabl=theDocTabl.GetVTab
theTablBasin=theTabl.FindField("Basin")
theTablRegion=theTabl.FindField("Region")
theTablScom=theTabl.FindField("S_com")
theTablS=theTabl.FindField("S_part")
theTablProc=theTabl.FindField("Procent")
theBitMapTab=theTabl.GetSelection

QQ="( [Basin] ="++34.AsChar+ChoiceName+34.AsChar++")"


if (theTabl.Query(QQ,theBitMapTab,#VTAB_SELTYPE_NEW)) then
theTabl.UpdateSelection
end
theBitMapTab=theTabl.GetSelection
theStrAddBas2=" "
for each rec in theBitMapTab
theSComBas=theTabl.ReturnValue(theTablScom,rec)
theReg=theTabl.ReturnValue(theTablRegion,rec)
theS=theTabl.ReturnValue(theTablS,rec)
thePr=theTabl.ReturnValue(theTablProc,rec)
theS=theS/1000000
theStrAddBas2=theStrAddBas2++" "+theReg+":"++theS.AsString++".:"++
"("+thePr.AsString+"%)"+NL
end
theSComBas=theSComBas/1000000
theStrAddBas=" . . - "+theSComBas.AsString++".:"+NL+
theStrAddBas2
TheStr=":"++ChoiceName+NL+theStrAddBas
r = Rect.MakeEmpty
r = r.UnionWith(thm_poly.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
else
theView.GetDisplay.SetExtent(r.Scale(1.1))
end
MsgBox.Report(theStr,"")
System.Execute(StrOut)
exit
end
' c
theBitMap=theFTab.GetSelection
QQ0="( [Name] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theFTab.Query(QQ0,theBitMap,#VTAB_SELTYPE_NEW)) then
theFtab.UpdateSelection
end
theBitMap=theFTab.GetSelection
' ,
ListBasin=List.Make
for each rec in theBitMap
theBasin=theFtab.ReturnValue(theBasinFld,rec)
ListBasin.Add(theBasin)
end
ListBasin.RemoveDuplicates
' ,
if (ListBasin.Count>1) then
ListBasin.Sort(True)
ChoiceBasin=MsgBox.ChoiceAsString(ListBasin," ."+ChoiceName+
" ","")

if (ChoiceBasin=nil) then
exit
end
theBitMap=theFTab.GetSelection
QQ1="([Basin] ="++34.AsChar+ChoiceBasin+34.AsChar++")"
if (theFTab.Query(QQ1,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end
'StrOut=StrOut+",,"+ChoiceBasin
StrOut=StrOut+"! ! "+ChoiceBasin
else
ChoiceBasin=ListBasin.Get(0)
end
theBitMap=theFTab.GetSelection
TheChoice=theBitMap.AsList.Find(True)
IdMach=theFtab.ReturnValue(theIdFld,TheChoice)
L_mach=0
CountId=0
for each rec in theBitMap
theId=theFtab.ReturnValue(theIdFld,rec)
LL=theFtab.ReturnValue(theLengthFld,rec)
If(L_mach<LL) then
L_mach=LL
IdMach=theId
CountId=CountId+1
end
end
if (CountId>0) then
QQ3="([Id_r1] ="+IdMach.AsString+")"
if (theFTab.Query(QQ3,theBitMap,#VTAB_SELTYPE_AND)) then
theFtab.UpdateSelection
end
end
theBitMap=theFTab.GetSelection
cc=theBitMap.Count
TheChoice=theBitMap.AsList.Find(True)
Length=theFtab.ReturnValue(theLengthFld,theChoice)
CountWat=0
ListRegion=List.Make
for each rec in theBitMap
theRegion=theFtab.ReturnValue(theRegionFld,rec)
ListRegion.Add(theRegion)
theWat=theFtab.ReturnValue(theWatFld,rec)
CountWat=CountWat+theWat.AsNumber ',

end
ListRegion.RemoveDuplicates
' ,
TheDictReg=Dictionary.Make(200)
for each reg in ListRegion
LengthReg=0
for each rec in theBitMap

tmpReg=theFtab.ReturnValue(theRegionFld,rec)
if (tmpReg=reg) then
LengthReg=LengthReg+(theFtab.ReturnValue(theLengthFld1,rec))
end
end
if (LengthReg>0) then
TheDictReg.Add(reg,LengthReg)
end
end
'
theBitMapP=theFTabP.GetSelection
QQ2="(([Basin] ="++34.AsChar+ChoiceBasin+34.AsChar++") and "+
" ([Name] ="++34.AsChar+ChoiceName+34.AsChar++"))"
if (theFTabP.Query(QQ2,theBitMapP,#VTAB_SELTYPE_NEW)) then
theFtabP.UpdateSelection
end
CountWatP=0
ListRegionP=List.Make
for each rec in theBitMapP
theRegion=theFtabP.ReturnValue(theRegionFldP,rec)
ListRegionP.Add(theRegion)
theWat=theFtabP.ReturnValue(theWatFldP,rec)
CountWatP=CountWatP+theWat.AsNumber ',

end
ListRegionP.RemoveDuplicates
for each regp in ListRegionP
LengthReg=0
for each rec in theBitMapP
tmpReg=theFtabP.ReturnValue(theRegionFldP,rec)
if (tmpReg=regp) then
LengthReg=LengthReg+(theFtabP.ReturnValue(theLenFldP,rec))
end
end
AddLen=0
for each reg in ListRegion
if(reg=regp)then
AddLen=AddLen+TheDictReg.Get(reg)
TheDictReg.Remove(reg)
end
end
If(AddLen=0) then ListRegion.Add(theRegion)
end
LengthReg=LengthReg+AddLen
TheDictReg.Add(regp,LengthReg)
end
TheStrAdd=""
for each reg in ListRegion' TheDictReg'.AsList
LengthReg=theDictReg.Get(reg)
Procent=LengthReg/Length
LengthReg=LengthReg/1000
LengthReg.SetFormat("d.ddd")
Procent=Procent*100

Procent.SetFormat("d.dd")
TheStrAdd=TheStrAdd+" "+reg.AsString++""++"-"++LengthReg.AsString+
+""++"("+Procent.AsString+"%)"+NL
end
theStrAddBas=""
'
'
if(CountWat>0) then
theDocTabl=av.FindDoc(" .dbf")
theTabl=theDocTabl.GetVTab
theTablBasin=theTabl.FindField("Basin")
theTablRegion=theTabl.FindField("Region")
theTablScom=theTabl.FindField("S_com")
theTablS=theTabl.FindField("S_part")
theTablProc=theTabl.FindField("Procent")
theBitMapTab=theTabl.GetSelection
QQ="( [Basin] ="++34.AsChar+ChoiceName+34.AsChar++")"
if (theTabl.Query(QQ,theBitMapTab,#VTAB_SELTYPE_NEW)) then
theTabl.UpdateSelection
end
theBitMapTab=theTabl.GetSelection
theStrAddBas2=" "
for each rec in theBitMapTab
theSComBas=theTabl.ReturnValue(theTablScom,rec)
theReg=theTabl.ReturnValue(theTablRegion,rec)
theS=theTabl.ReturnValue(theTablS,rec)
thePr=theTabl.ReturnValue(theTablProc,rec)
theS=theS/1000000
theStrAddBas2=theStrAddBas2++" "+theReg++"-"+":"++theS.AsString+
+".:"++
"("+thePr.AsString+"%)"+NL
end
theSComBas=theSComBas/1000000
theStrAddBas=" . . - "+theSComBas.AsString++".:"+NL+
theStrAddBas2
end
Length=Length/1000
Length.SetFormat("d.ddd")
TheStr=":"++ChoiceName+NL+
":"++ChoiceBasin+NL+
" = "+Length.AsString++""+NL+
"
:"+NL+
TheStrAdd+NL+theStrAddBas
r = Rect.MakeEmpty
r = r.UnionWith(thm.GetSelectedExtent)
r = r.UnionWith(thm_poly.GetSelectedExtent)
if (r.IsEmpty) then
return nil
elseif ( r.ReturnSize = (0@0) ) then
theView.GetDisplay.PanTo(r.ReturnOrigin)
else

theView.GetDisplay.SetExtent(r.Scale(1.1))
end
MsgBox.Report(theStr,"")
Clipboard.The.Empty
Clipboard.The.Add(TheStr)
Clipboard.The.Update
System.Execute(StrOut)
for each t in theView.GetThemes
if ((t.GetSrcName.GetFilename.GetBaseName="Basins.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_polyline_overlay_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="river_1_region_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="regions.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_polygon_update.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="lake_region_1km2_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region_big.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="towns_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="qwartals_region.shp")OR
(t.GetSrcName.GetFilename.GetBaseName="hydrochem.shp"))
then
t.SetVisible(true)
end
end
theView.Invalidate

From GK14 to DD
theView=av.GetActiveDoc
' Creates the projection object GK14N
aRect=Rect.MakeXY(72,52,90,64)
aPrj = TransverseMercator.Make(aRect)
aPrj.SetCentralMeridian(81.0)
aPrj.SetReferenceLatitude(0)
aPrj.SetScale(1.0)
' Enter the False Easting in meters
aPrj.SetFalseEasting(500000)
aPrj.SetFalseNorthing(0)
aPrj.SetSpheroid(#SPHEROID_KRASOVSKY)
theDrawPnt = theView.GetDisplay.ReturnUserPoint
PntUnPrj=theDrawPnt.ReturnUnProjected(aPrj)
XX=PntUnPrj.getX ' ).AsNumber
YY=PntUnPrj.getY ').AsNumber
Xf=XX.Floor
Yf=YY.Floor
Xrem=(XX-Xf)*60
Yrem=(YY-Yf)*60
Xmin=Xrem.Floor
Ymin=Yrem.Floor
Xsec=((Xrem-Xmin)*60).Floor
Ysec=((Yrem-Ymin)*60).Floor
if(Xmin<10) then Xm="0"+Xmin.asString else Xm=Xmin.asString
end
if(Ymin<10) then Ym="0"+Ymin.asString else Ym=Ymin.asString
end
if(Xsec<10) then Xs="0"+Xsec.asString else Xs=Xsec.asString
end
if(Ysec<10) then Ys="0"+Ysec.asString else Ys=Ysec.asString
end
myInf=" -"++Xf.asString+" "+Xm+"' "+Xs+"''"+NL+
" -"++Yf.asString+" "+Ym+"' "+Ys+"''"
MsgBox.Info (myInf," :")
Clipboard.The.Empty
Clipboard.The.Add(myInf)
Clipboard.The.Update

EndPoint
theView=av.GetActiveDoc
theGraphicList = theView.GetGraphics
theDisplay = theView.GetDisplay
for each graphicpoint in theGraphicList
if (graphicpoint.GetName = " ".asString) then
theGraphicList.RemoveGraphic(graphicpoint)
break
end
end
thePalette = av.GetSymbolWin.GetPalette
mlst = thePalette.GetList(#PALETTE_LIST_MARKER)
theGraphicSymboltoUse = mlst.Get(40)
theGraphicSymbol = BasicMarker.Make
theGraphicSymbol.Copy(theGraphicSymbolToUse)
theGraphicSymbol.SetColor(Color.GetRed)
theGraphicSymbol.SetSize(10)
thedrawpoint = theDisplay.ReturnUserPoint
theGraphicpoint = GraphicShape.Make(thedrawpoint)
theGraphicpoint.SetSymbol(theGraphicSymbol)
theLinkNum = GraphicText.Make(" "+" ",thedrawpoint)
theLinkNum.GetSymbol.SetSize(12)
theGroup = GraphicGroup.Make
theGroup.Add(theGraphicpoint)
theGroup.Add(theLinkNum)
theGroup.SetName((" ").asString)
theGraphicList.Add(theGroup)
theGraphicList.Invalidate
av.ProcessAllInvals

AddXY
theView = av.GetActiveDoc
'must be global to work in Calc exp below
_theProjection = theView.GetProjection
project_flag = _theProjection.IsNull.Not 'true if projected
theTheme = theView.GetActiveThemes.Get(0)
'Check if point or polygon theme
if (((theTheme.GetSrcName.GetSubName = "point") or
(theTheme.GetSrcName.GetSubName = "polygon")).Not) then
MsgBox.Info("Active theme must be polygon or point theme","")
exit
end
'get the theme table and current edit state
theFTab = theTheme.GetFTab
theFields = theFTab.GetFields
edit_state = theFTab.IsEditable
'make sure table is editable and that fields can be added
if (theFtab.CanEdit) then
theFTab.SetEditable(true)
if ((theFTab.CanAddFields).Not) then
MsgBox.Info("Can't add fields to the table."+NL+"Check write permission.",
"Can't add X,Y coordinates")
exit
end
else
MsgBox.Info("Can't modify the feature table."+NL+
"Check write permission.","Can't add X,Y coordinates")
exit
end
'Check if fields named "X-coord" and Y-coord" exist
x_exists = (theFTab.FindField("X-coord") = NIL).Not
y_exists = (theFtab.FindField("Y-coord") = NIL).Not
if (x_exists or y_exists) then
if (MsgBox.YesNo("Overwrite existing fields?",
"X-coord, Y-coord fields already exist", false)) then
'if ok to overwrite, delete the fields as they may not be defined
'as required by this script (eg., created from another script).
if (x_exists) then
theFTab.RemoveFields({theFTab.FindField("X-coord")})
end
if (y_exists) then
theFTab.RemoveFields({theFTab.FindField("Y-coord")})
end
else
exit
end 'if (MsgBox...)
end 'if
x = Field.Make ("X-coord",#FIELD_DECIMAL,18,5)
y = Field.Make ("Y-coord",#FIELD_DECIMAL,18,5)
theFTab.AddFields({x,y})

'Get point coordinates or polygon centroid coordinates


if (theTheme.GetSrcName.GetSubName = "point") then
if (project_flag) then
'Projection defined
theFTab.Calculate("[Shape].ReturnProjected(_theProjection).GetX", x)
theFTab.Calculate("[Shape].ReturnProjected(_theProjection).GetY", y)
else
'No projection defined
theFTab.Calculate("[Shape].GetX", x)
theFTab.Calculate("[Shape].GetY", y)
end 'if
else 'polygon case
if (project_flag) then
theFTab.Calculate("[Shape].ReturnCenter.ReturnProjected(_theProjection).GetX", x)
theFTab.Calculate("[Shape].ReturnCenter.ReturnProjected(_theProjection).GetY", y)
else
theFTab.Calculate("[Shape].ReturnCenter.GetX", x)
theFTab.Calculate("[Shape].ReturnCenter.GetY", y)
end ' if
end
'Return editing state to pre-script running state
theFTab.SetEditable(edit_state)

Frame
theView=av.GetActiveDoc
theGraphicList = theView.GetGraphics
theDisplay = theView.GetDisplay
for each graphicpoint in theGraphicList
if (graphicpoint.GetName = " ".asString) then
theGraphicList.RemoveGraphic(graphicpoint)
break
end
end
thePalette = av.GetSymbolWin.GetPalette
mlst = thePalette.GetList(#PALETTE_LIST_FILL)
theGraphicSymboltoUse = mlst.Get(40)
theGraphicSymbol = VectorFill.Make
theGraphicSymbol.Copy(theGraphicSymbolToUse)
theGraphicSymbol.SetStyle(#VECTORFILL_STYLE_RECTANGLE)
ColorBG=Color.Make
ColorBG.SetTransparent(True)
theGraphicSymbol.SetBGColor(ColorBG)
theGraphicSymbol.SetColor(ColorBG)
theGraphicSymbol.SetPenSize(2)
theGraphicSymbol.SetOlColor(Color.GetRed)
theGraphicSymbol.SetOlWidth(2)
theGraphicSymbol.SetOutlined(TRUE)

thedrawpoint = theDisplay.ReturnUserRect
theGraphicpoint = GraphicShape.Make(thedrawpoint)
theGraphicpoint.SetSymbol(theGraphicSymbol)
theLinkNum = GraphicText.Make(" "+"
",thedrawpoint.ReturnExtent.ReturnOrigin)
theLinkNum.GetSymbol.SetSize(12)
theGroup = GraphicGroup.Make
theGroup.Add(theGraphicpoint)
theGroup.Add(theLinkNum)
theGroup.SetName((" ").asString)
theGraphicList.Add(theGroup)
theGraphicList.Invalidate
av.ProcessAllInvals

Legend Remove
theView=av.GetActiveDoc
theGraphicList = theView.GetGraphics
'theDisplay = theView.GetDisplay
count=0
TheListG=List.Make
for each graphicpoint in theGraphicList
if (graphicpoint.GetName = " ".asString) then
TheListG.Add(graphicpoint)
count=count+1
elseif (graphicpoint.GetName = " ".asString) then
TheListG.Add(graphicpoint)
count=count+1
elseif (graphicpoint.GetName = " ".asString) then
TheListG.Add(graphicpoint)
count=count+1
end
if (count=3) then
break
end
end
if (TheListG.Count<>0) then
for each k in 0..(TheListG.Count-1)
TheGraphicList.RemoveGraphic(TheListG.Get(k))
end
end

Main
'
'
'--- ,
DirName = av.GetProject.GetWorkDir
TheView=av.GetActiveDoc
NameArc=" " '
TheArcFTab=theView.FindTheme(NameArc).GetFTab
theTNodeFld=TheArcFTab.FindField("To_node")
theFNodeFld=TheArcFTab.FindField("From_node")
theArcFld=TheArcFTab.FindField("R1_")
theLengthFld=TheArcFTab.FindField("Length")
theShpFld=TheArcFTab.FindField("Shape")
'-------------------
aTolerance=200 '
MaxNArc=3 '

'------------------'---
theGraphicList = theView.GetGraphics
for each graphicpoint in theGraphicList
if (graphicpoint.GetName = " ".asString) then
theSrcPoint=graphicpoint.GetGraphics.Get(0).GetShape
end
if (graphicpoint.GetName = " ".asString) then
theSinkPoint=graphicpoint.GetGraphics.Get(0).GetShape
end
if (graphicpoint.GetName = " ".asString) then
theFrame=graphicpoint.GetGraphics.Get(0).GetShape '
!
end
end
if ( not (theFrame.Intersects(TheSrcPoint)) ) then
MsgBox.Error(" !
!","ReestrCalc.Main")
exit
end
if ( not (theFrame.Intersects(TheSinkPoint)) )then
MsgBox.Error(" !
!","ReestrCalc.Main")
exit
end
'-------------------------------------------------------'
TheArcFtab.SelectByRect(theFrame,#VTAB_SELTYPE_NEW)
theSelection=TheArcFtab.GetSelection

N_=theSelection.Count
if (N_<1) then
MsgBox.Error(" !","ReestrCalc.Main")
exit
end
theDictArc=Dictionary.Make(N_) '
theDictNode=Dictionary.Make(N_) ' , ,
N_,
'-
for each rec in theSelection
TheId=TheArcFtab.ReturnValue(theArcFld,rec)
TheLength=TheArcFtab.ReturnValue(theLengthFld,rec)
TheFnode=TheArcFtab.ReturnValue(theFNodeFld,rec)
TheTnode=TheArcFtab.ReturnValue(theTNodeFld,rec)
TheDictArc.Add(TheId,{TheLength,TheFnode,TheTnode})
TheDictNode.Add(TheFNode,TheId) ' FNode
.
end
'-------------------------------------------------------theSelection=TheArcFtab.GetSelection
theSelection.ClearAll
TheArcFtab.SetSelection(theSelection)
TheArcFtab.UpdateSelection
'-------------------------------------------------------'-------------------------------------------------------' ,

' -
'
TheArcFtab.SelectByPoint (TheSrcPoint, aTolerance, #VTAB_SELTYPE_NEW)
if (TheArcFtab.GetSelection.Count>MaxNArc) then
MsgBox.Error(" : 10 !
!","ReestrCalc.Main")
exit
end
if (TheArcFtab.GetSelection.Count=0) then
MsgBox.Error(" :
! !","ReestrCalc.Main")
exit
end
' ,
TheSrcIdArc=nil
TheSrcR=aTolerance
TheSrcArc=nil
for each rec in TheArcFtab.GetSelection
MinSrcIdArc=TheArcFtab.ReturnValue(theArcFld,rec)
MinSrcArc=TheArcFtab.ReturnValue(theShpFld,rec)
MinSrcR=TheSrcPoint.Distance(MinSrcArc)
if (MinSrcR<=TheSrcR) then
TheSrcIdArc=MinSrcIdArc
TheSrcR=MinSrcR
TheSrcArc=MinSrcArc

end
end
'
TheSrcArcLength=TheSrcArc.ReturnLength
TheSrcPoint.Snap(TheSrcArc,TheSrcR+1)
TheLengthSrc=(100-(TheSrcArc.PointPosition(TheSrcPoint)))*TheSrcArcLength/100

' -
'
TheArcFtab.SelectByPoint (TheSinkPoint, aTolerance, #VTAB_SELTYPE_NEW)
if (TheArcFtab.GetSelection.Count>MaxNArc) then
MsgBox.Error(" : 10 !
!","ReestrCalc.Main")
exit
end
if (TheArcFtab.GetSelection.Count=0) then
MsgBox.Error(" :
! !","ReestrCalc.Main")
exit
end
' ,
TheSinkIdArc=nil
TheSinkR=aTolerance
TheSinkArc=nil
for each rec in TheArcFtab.GetSelection
MinSinkIdArc=TheArcFtab.ReturnValue(theArcFld,rec)
MinSinkArc=TheArcFtab.ReturnValue(theShpFld,rec)
MinSinkR=TheSinkPoint.Distance(MinSinkArc)
if (MinSinkR<=TheSinkR) then
TheSinkIdArc=MinSinkIdArc
TheSinkR=MinSinkR
TheSinkArc=MinSinkArc
end
end
'
TheSinkArcLength=TheSinkArc.ReturnLength
TheSinkPoint.Snap(TheSinkArc,TheSinkR+1)
TheLengthSink=(TheSinkArc.PointPosition(TheSinkPoint))*TheSinkArcLength/100

'
if (TheSrcIdArc=TheSinkIdArc) then
',
LengthFinal=TheLengthSink-(TheSinkArcLength-TheLengthSrc)
else
Flag=False
CurrArc=TheSrcIdArc
while (Flag=False)
CurrArc_Char=TheDictArc.Get(CurrArc)
if (CurrArc<>TheSinkIdArc) then
if (CurrArc=TheSrcIdArc) then

LengthFinal=TheLengthSrc
else
LengthFinal= LengthFinal+(CurrArc_Char.Get(0))
end
NextFNode=CurrArc_Char.Get(2)
CurrArc=TheDictNode.Get(NextFNode)
if (CurrArc=nil) then
MsgBox.Error(" ,
! !",
"ReestrCalc.Main")
exit
end
else
LengthFinal= LengthFinal+TheLengthSink
Flag=True
end
end
end
'-------------------------------------------------------theSelection=TheArcFtab.GetSelection
theSelection.ClearAll
TheArcFtab.SetSelection(theSelection)
TheArcFtab.UpdateSelection
'---
av.PurgeObjects
LengthFinal.SetFormat("d")
message= " "+NL+ " "+
LengthFinal.AsString++""
MsgBox.Info(message,"ReestrCalc.Main")
Clipboard.The.Empty
Clipboard.The.Add(message)
Clipboard.The.Update

StartPoint
theView=av.GetActiveDoc
theGraphicList = theView.GetGraphics
theDisplay = theView.GetDisplay
for each graphicpoint in theGraphicList
if (graphicpoint.GetName = " ".asString) then
theGraphicList.RemoveGraphic(graphicpoint)
break
end
end
thePalette = av.GetSymbolWin.GetPalette
mlst = thePalette.GetList(#PALETTE_LIST_MARKER)
theGraphicSymboltoUse = mlst.Get(40)
theGraphicSymbol = BasicMarker.Make
theGraphicSymbol.Copy(theGraphicSymbolToUse)
theGraphicSymbol.SetColor(Color.GetBlue)
theGraphicSymbol.SetSize(10)
thedrawpoint = theDisplay.ReturnUserPoint
theGraphicpoint = GraphicShape.Make(thedrawpoint)
theGraphicpoint.SetSymbol(theGraphicSymbol)
theLinkNum = GraphicText.Make(" "+" ",thedrawpoint)
theLinkNum.GetSymbol.SetSize(12)
theGroup = GraphicGroup.Make
theGroup.Add(theGraphicpoint)
theGroup.Add(theLinkNum)
theGroup.SetName((" ").asString)
theGraphicList.Add(theGroup)
theGraphicList.Invalidate
av.ProcessAllInvals

Das könnte Ihnen auch gefallen