RE: مختصری از سیستم اطلاعات مکانی و نرم افزار جی آی اس آرک ویوو
امكان برنامه نويسي در محيط سيستم اطلاعات جغرافيائي يكي از مهمترين برجستگي هاي يك نرم افزار تلقي مي شود. نرم افزار Arcview با داشتن زبان برنامه نويسي Avenue در اين زمينه بسيار كارآمد است. شكل زير محيط Script و دكمه هاي مربوطه را توضيح ميدهد. بيشتر كار اين قسمت با نوشتن برنامه داخل جعبه متن انجام مي شود و ليكن امكان بارگذاري و ذخير فرمانها بصورت متن نيز فراهم شده است.
براي نگارش برنامه ابتدا كدهاي مورد نياز در محل مربوطه نوشته مي شوند و سپس كمپايل (Compile) و در مرحله آخر Run مي شوند.دكمه هاي مربوطه بر روي شكل فوق مشخص شده اند.
زبان Avenue
زبان Avenue (زبان برنامه نويسي Arcview ) يك زبان برنامه نويسي شي گراست كه امكان محاسبات نقشه و كار با بانكهاي اطلاعاتي جغرافيائي را فراهم مي آورد. ساختار زبان بسيار به ويژوال بيسيك شباهت دارد. ذيلا و در ادامه به برخي از ويژگيهاي زبان پرداخته مي شود.
انواع متغييرها در Avenue
حالت منطقي (true, false)
- اعداد (10, 0.0, 90.123)
- رشته ("hello world")
– رشته هاي از پيش تعريف شده (tab, cr, nl)
– اعداد شمارشي (#VSHSYM_HATCHED)
– ليست اشياء ( {"hello", 1, view.activeThemes, a+b} )
– يك شي با ارتباط با درون خودش در يك اسكريپت
– برنامه اجرائي فعال (av)
– شي ء تهي (nil)
– متغيرهاي محلي
– متغيرهاي عمومي
– توضيحات تك خطي (كه در برنامه با علامت ' شروع مي شوند)
– علائم گردش كار در برنامه (if-then, return, continue, etc)
صدا زدن اسكريپتها
av.Run("aScriptName", theSelfObject)
av.DelayedRun("aScriptName", theSelfObject, aNumberofSeconds)
aScriptObject.DoIt(theSelfObject)
گرامر
Script ::= {Statement}*
Statement ::= Request
| Assignment
| If
| For
| While
| Exit
| Break
| Return
| Continue
Assignment ::= Name '=' BRequest
If ::= 'if' '(' BRequest ')' 'then' Script
{'elseif' '(' BRequest ')' 'then' Script} *
{'else' Script}
'end'
For ::= 'for' 'each' Name 'in' BRequest Script 'end'
While ::= 'while' '(' BRequest ')' Script 'end'
Exit :: 'exit'
Return ::= 'return' BRequest
Break ::= 'break'
Continue ::= 'continue'
BRequest ::= Request {Symbol Request}*
Request ::= PRequest {'.' Message}*
PRequest ::= Symbol PRequest | Object
Object ::= Literal
| Variable
| '(' BRequest ')'
Literal ::= Number
| String
| 'self'
| 'arcview'
| 'av'
| 'tab'
| 'cr'
| 'nl'
| '{' {BRequest {',' BRequest}*} '}'
| Class
Message ::= Name {'(' BRequest {',' BRequest}* ')'}
Variable ::= Name | '_'Name
Class ::= Name
Name ::= a-zA-Z 0-9a-zA-Z_ *
Symbol ::= -+*&^$#@! ?><:|\/ +
| '='
| 'and'
| 'or'
| '..'
| 'min'
| 'max'
| 'by'
| 'mod'
| 'xor'
Number ::= 0-9 +(. 0-9 +)?
String ::= '"' {Character}* '"'
فرمت تاريخ
M - the month as an integer from 1 to 12
MM - same as 'M', two digits with leading zeros
MMM - the short form of the month name
MMMM - the long form of the month name
d - the day of the month as an integer from 1 to 31
dd - same as 'd', two digits with leading zeros
ddd - the short form of the day name
dddd - the long form of the day name
y - the year without century
yy - same as 'y', two digits with leading zeros
yyy - the year with century, four digits with leading zeros
yyyy - same as 'yyy'
yyyyy - the year with century, not restricted to four digits
c - the century, without a leading zero
cc - the century, with a leading zero for single digit centuries
w - week of the year (Week 0 is first week with a Thursday)
ww - week of the year, two digits with leading zeros
D - numeric day of the week (Sunday = 1), one digit always
AD - AD or BC string depending upon the year
CE - CE or BCE string depending upon the year
J - Julian Day (days since January 1, 4713 BC)
j - day of the year
jj - day of the year, three digits with leading zero
فرمت زمان
m - the minute as an integer from 00 to 59
s - the seconds value as an integer from 00 to 59
s.s - the seconds with milliseconds, 00.000
h - the hour as an integer from 1 to 12
hh - same as 'h', but with leading zero instead of blank
hhh - the hour from 0 to 23
hhhh - same as 'hhh', but with leading zero instead of blank
AMPM - locale specific AM or PM string
TZ - the locale specific time zone string.
ITZ - ISO format time zone string (+0800, -0500, etc.)
برخی از اصطلاحات زبان برنامه نويسي Avenue
break
اين عبارت گردش كار را در زمان اجراي For Each يا While خارج مي كند.عيارت فوق صرفا در مورد همين دو حلقه نيز قابل استفاده است.مثال:
Exit
اين فرمان باعث خروج از كليه script ها خواهد شد.
در صورتيكه بخواهيم از يك زير برنامه خارج شويم بايد از دستور Return استفاده كنيم.
For Each
اين دستور يكسري عمليات روي هر عضو يك مجموعه انجام مي دهد.
مثال 1:
newDir = MsgBox.Input( "Specify directory", "Directory", "")
if (newDir = nil) then
exit
elseif (newDir.AsFileName.IsDir.Not) then
MsgBox.Error( newDir.AsFileName.GetFullName++"is not a directory", "")
exit
elseif (File.IsWritable(newDir.AsFileName).Not) then
MsgBox.Error( newDir.AsFileName.GetFullName++"is not writable", "")
exit
else
theProject.SetWorkDir( newDir.AsFileName )
end
for each num in 1..10
if (num = 5) then
break
end
msgbox.info("Num is"++num.asString,"ArcView Example")
end
msgbox.info( "Complete", "")
Continue
اين عبارت براي باز گرداندن كنترل ادامه برنامه كار در حلقه ها به كار مي رود.
theView = av.GetActiveDoc
for each t in theView.GetThemes
for each f in t.GetFtab.GetFields
if (f.IsTypeNumber) then
continue
end
f.SetVisible(true)
end
t.GetFtab.Refresh
end
|