Advanced GIS GEOG 48505850 TTU - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

Advanced GIS GEOG 48505850 TTU

Description:

MsgBox.Info('How about frog meat?','Bonjo') elseif (YourChoice = 'Japan') then. MsgBox.Info('Sashimi is good','Sumo') elseif (YourChoice = 'US') then ... – PowerPoint PPT presentation

Number of Views:169
Avg rating:3.0/5.0
Slides: 51
Provided by: Pete8
Category:
Tags: geog | gis | ttu | advanced | for | good | hamburger | how | is | long | meat

less

Transcript and Presenter's Notes

Title: Advanced GIS GEOG 48505850 TTU


1
Advanced GISGEOG 4850/5850TTU
  • Week 2, 2003 Fall

2
Characteristics of Objects
  • Object Properties Actions State
  • Car make start direction north
  • model stop speed 75 mph
  • color turn left
  • 4 doors turn right

Objects defined as a person, place, or thing
that knows the values of its attributes and can
perform operations on those attributes. Called
Class instances and operations are also called
methods or services.
3
Class and Objects
Classes a class groups objects based on common
characteristics. For example, a display extent
object belongs to the rectangle class, and an
individual belongs to the human class
All objects of a class share the same attribute
types and operations
  • Car Class

View Class
View 1
View 2
View 3
4
Class Relationship
  • Inheritance
  • Aggregation
  • Association

Two types of classes abstract and concrete.
Abstract classes do not instantiate objects,
while their descendants have objects. For
example, consider the class Doc, which has no
objects, but its descendant classes, such as View
and Chart, do have objects. Therefore, Doc is an
absbract class while View and Chart are concrete
classes.
5
Inheritance
  • is a kind of relationship

Car
Pickup
Sedan
Van
Convertible
4X4
6
Aggregation
  • is composed of relationship

Project
Car
Engine
Radio
Tire
Script
View
Table
Tuner
CD
TOC
Theme
7
Association
  • Link between two classes or objects

Runs on
Gasoline
Car
DocWin
Doc
Is viewed through Displays
8
Requests
  • Make things happen in ArcView
  • Class Request - create a new object, e.g. create
    a new theme.
  • Instance Request - retrieve or modify existing
    objects, e.g. show/hide legend
  • Different classes support different requests.
    Views accept request for zooming, but not tables
  • Polymorphism - similar request for different
    objects, e.g. Make View or Table.

9
Request Forms
  • Request begins with a Verb, e.g. GetProject,
    FindScript, AddDoc where Get, Find and Add are
    actions and Project, Script and Doc receive that
    Action
  • Request with arguments
  • some requests require additional information, or
    argument
  • eg. theView theProject.FindDoc(United
    States)

10
Action keyword
  • Add
  • As
  • Can
  • Find
  • Get
  • Has
  • Is
  • Make
  • Return
  • Set
  • Include another object in a
  • group of objects
  • Convert an object to an object
  • of a different class
  • check if the object can perform
  • the specified function
  • search for the specified object
  • and return a reference to it
  • return a reference to an object
  • indicate if the object has the
  • specified condition or state
  • return true or false
  • create a new instance
  • create a new object and return
  • a reference to it
  • assign an attribute of an object
  • aView.AddTheme(myTheme)
  • aNumber.AsString
  • aTheme.CanEdit
  • aView.FindTheme(Roads)
  • aView.GetTheme
  • aScript.HasError
  • aButton.IsVisible
  • View.Make
  • aFileName.ReturnDir
  • aButton.SetIcon

11
Naming Variables
  • Long enough to indicate the purpose
  • Avoid the class names, such as View, theme.
    Instead, use aView, myTheme, etc.
  • Always favor using local variables
  • Make the first character lowercase
  • Consistence
  • Getting Started
  • application object - av plus a request
  • eg. theProject av.GetProject
  • This Object.Request returns the current project.
    The next thing you need to do is finding the view
    within the project, and this can be done by
    typing in
  • theViewtheProject.FindDoc(United States)

12
Requests Execution
  • Object.Request
  • Postfix notation - theView.Print
  • Infix notation - 101 662
  • Prefix notation - not someCondition, but you may
    still use Postfix notation for this request -
    someCondition.not
  • Return of another object - theName
    theView.GetName
  • myNumber 2 5
  • Simplify your requests
  • theProject av.GetProject
  • theView the Project.FindDoc (World)
  • theTheme theView.FindTheme (Major Cities)
  • the following is the combination of the previous
    three lines of codes
  • theTheme av.GetProject.FindDoc(World).FindThe
    me(Major Cities)

13
Message Box (MsgBox.)
  • Message box displays information, error and
    warning messages to viewers and sometimes provide
    selections and choices and return values to the
    variables. Many requests follows the MsgBox have
    various functions (Info, YesNo, choices)
  • Now, open a new project and come to Scripts in
    TOC and double-click on Script to bring on the
    Script window. ProjectPropertiesStartUp (see
    demo)
  • Type in the following script and have it attached
    to the StartUp property in
  • MsgBox.Info (Welcome to my first script, Hello
    World)
  • Click on Compile and Run

14
  • Error message box
  • MsgBox.Error (Unable to open file,). If no
    title passed onto message box, Error is the
    default title.

15
Welcome/Shutdown
  • Remember save the scripts name as A1.Welcome
    and have it compiled before you send it to the
    Startup box.
  • Now create another shutdown script for the
    Shutdown and save your project as
    a1.ShutDownMsg in your folder
  • close project
  • aProject av.GetProject
  • MsgBox.Info(This will close your project without
    saving it, Close Project)
  • aProject.Close
  • Exit program
  • MsgBox.Info(This will end your program without
    saving it, Exit Program)
  • Av.Quit

16
Exercise
  • Design a message box with title Where you want
    to go during Fall Break? and MultiListAsString
    request for the places like Japan,
    Mexico,France, Greece
  • MsgBox.MultiListAsString(stringOption, text on
    msg,Title)
  • Create a new button in the View and assign a new
    icon and have the message box associated with
    this button.
  • If ... structure
  • If.... then
  • elseif... then
  • elseif... then
  • else
  • end

17
Options - try this
Notes use Object.Get(0) object.Get(1)..... to
indicate the names selected by the user
18
Right here!!!!
  • 'MultiListAsString, Country
  • options "Japan", "Mexico", "France", "Greece"
  • choices MsgBox.MultiListAsString( options,
    "Select some", "SELECT" )
  • if (choices nil) then
  • MsgBox.Info( "NO SELECTION", "No Selection
    Message")
  • end
  • Count choices.count
  • if (Count 4) then
  • MsgBox.Info("You have selected"
    choices.Get(0) ","choices.Get(1)","choic
    es.Get(2)"and"choices.Get(3),"Select"choices
    .count.AsString)
  • elseif (Count 3) then
  • MsgBox.Info("You have selected"
    choices.Get(0) ","choices.Get(1)"and"cho
    ices.Get(2),"Select 3")
  • elseif (Count 2) then
  • MsgBox.Info("You have selected"
    choices.Get(0) "and"choices.Get(1),"Select
    2")
  • else
  • MsgBox.Info( "You have selected"
    choices.Get(0),"How Many")
  • end

19
Now try this
Use ChoiceAsString China,France and Mexico
If (expression) then statement
statement elseif statement else end
20
Solution
  • myList "China","France","Mexico",
    "Japan","US","Korea"
  • YourChoice MsgBox.ChoiceAsString(myList,"Choose
    your destination","Where to go")
  • if (YourChoice "China") then
  • MsgBox.Info ("You must like Chinese
    food","Dragon")
  • elseif (YourChoice "France") then
  • MsgBox.Info("How about frog meat?","Bonjo")
  • elseif (YourChoice "Japan") then
  • MsgBox.Info("Sashimi is good","Sumo")
  • elseif (YourChoice "US") then
  • MsgBox.Info("Hamburger", "McDonald")
  • elseif (YourChoice"Korea") then
  • MsgBox.Info("KimGee","BinBinBo")
  • else
  • MsgBox.Info("Bean Eater","Amigo")
  • end

21
Data Types
  • string - delimited with the double quote, eg -
    myString Hello Everyone
  • Concatenate two strings with or (with one
    space bet/w strings)
  • Insert a newline bet/w 2 strings, myString
    Hello NL How are you?
  • AsFileName, AsList,,,,
  • Extract, LCase, Left, Middle, Proper, Right,
    Translate, Trim and UCase

22
Dates
  • yyear from 1 to 99
  • yy year from 01 to 99
  • yyyy year with century
  • MMonth from 1 to 12
  • MM Month from 01 to 12
  • MMMMonths name
  • MMMMMonths name
  • d day from 1 to 31
  • dd day from 01 to 31
  • dddshort form of the days name
  • dddd days name
  • m minute from 00 to 59
  • s second from 00 to 59
  • h hour from 1 to 12
  • hh hour from 01 to 12
  • hhh hour from 0 to 23
  • hhhh hour from 00 to 23
  • AMPM Am or PM string
  • TZ Time zone string

23
Date usage
  • yesterday Date.Now - (1.AsDays)
  • yesterday.SetFormat(dddd MMMM, yyyy)
  • MsgBox.Info (Yesterday was
    yesterday.AsString, )
  • Exercise Print Next Thursdays date using MsgBox
    and SetFormat

24
Using Booleans
  • aTrueObj true
  • aFalseObj false
  • iAmYounger (myBirthDay yourBirthDay)
  • MsgBox.Info(iAmYounger.AsString, )
  • Exercise
  • Type in todays date, and see your answer is
    correct or not.
  • myDate MsgBox.Input(

25
Using Enumerations
  • Create a character field as follows
  • newField Field.Make (Last_Name, FIELD_CHAR,
    40,0)
  • The FIELD_CHAR is the enumeration that specifies
    character field type.
  • All enumeration start with the pound sign

26
Using Nil
  • Non-existence of object - a nil object, such as
    the follows
  • myView av.GetProject.FindDoc (View1)
  • if (myView nil) then
  • MsgBox.Error(View1 does not exist, )
  • end
  • Nil is different from null. Some objects may be
    null (no value)
  • Test null by using the IsNull request.

27
Local/Global Variables
  • Local - used within the script
  • Global - accessed beyond the current script.
    Share objects between scripts
  • Mostly use local variable
  • Global variable (starts with an underscore_)
  • _theProject av.GetProject
  • The memory allocated to global variables must be
    cleared by
  • av.ClearGlobals
  • Global variable has to be initialized before
    compiling a script

28
  • Using Object Tags
  • Object tag alternative to using global
    variables.
  • aTheme.SetObjectTag(Alias Name) tag object
  • aliasName aTheme.GetObjectTag retrieve object
  • Using Lists
  • Avenue provides several classes of collections
    (collections are objects that contain other
    objects)
  • Collections are useful in organizing related
    information. For instance, it is easier to keep
    the names of all your themes in a list called
    allMyThemes than scattered among many different
    variables.
  • Lists are series of objects created through
    direct assignment or by request.

29
List Example
  • 'List Example
  • roadClass "LIGHT","MEDIUM","HEAVY"
  • roadClass.Add ("DAMAGED")
  • 'roadClass list is composed of LIGHT,MEDIUM,
    HEAVY, and DAMAGED string objects
  • roadAnnualCost List.Make
  • 'The Add request appends an object to the end of
    a list.
  • roadAnnualCost.Add (25000)
  • 'The Insert request places an object on the top
    of a list.
  • roadAnnualCost.Insert(12000)
  • lightRoadAnnualCost roadAnnualCost.Get(0)
  • 'The variable lightRoadAnnualCost references
  • 'the number object 12000
  • MsgBox.MultiListAsString(roadClass,"roadClass","")

30
Dictionary
  • is an efficient method to store and retrieve
    objects. In concept, they are similar to a
    two-column table with identifier and value column
    headings. Any type of object can be stored by a
    key, and the key may be from any class.
  • Try to access dictionary using Get(0), Get(1). It
    does not reference to the sequence of the
    dictionary. List is more efficient for
    sequential access

31
Example-dictionary
  • roadTravelCost Dictionary.Make(2)
  • '(2) refers to the size of hash tables not number
    of objects in the dictionary. The number of
    objects should not exceed hash size times 20.
  • roadTravelCost.Add("HEAVY",35.48)
  • roadTravelCost.Add("MEDIUM",35.00)
  • roadTravelCost.Add("LIGHT",34.28)
  • roadTravelCost.Add("GRAVEL",35.50)
  • graveRoadCost roadTravelCost.Get("GRAVEL")
  • 'The variable gravelRoadCost references
  • 'the number object 35.50 write a msgbox to show
    the value
  • 'use AsString to convert number to string
  • 'MsgBox.Info(roadTravelCost.Get(2).AsString,"")
  • MsgBox.Info(roadTravelCost.Get("GRAVEL").AsString,
    "")

32
Using Intervals and Duration
  • Objects of intervals class model a range of
    numbers with a defined set of subdivisions.
    Intervals are often used to construct a For Each
    loop. If the loop requires iterating through a
    range of numbers in equal increments, an interval
    is more efficient than a list of numbers.
  • oddInterval 1..9 by 2
  • for each oddDigit in oddInterval
  • MsgBox.Info(Odd digit
    oddDigit.AsString, )
  • end

33
Using Duration
  • default duration is one second
  • This script creates and displays a list of
    Wednesday in 2002
  • wednesdayInterval (20020102.AsDate)..(20020504.A
    sDate) by 7.AsDays
  • wednesdayList
  • for each wednesday in wednesdayInterval
  • wednesdayList.Add(wednesday)
  • end
  • MsgBox.ListAsString (wednesdayList,Wednesday in
    Spring Semester, )

34
Using Bitmaps
  • Bitmaps are collections of Boolean values. They
    are similar to lists except that each element is
    a Boolean object. Although you can create a
    bitmap with a Make request, you typically work
    with the existing bitmaps. ArcView uses bitmaps
    to identify spatial or attribute records that are
    selected or defined as part of a query.

35
Object, variables
  • ArcView treats things like numbers and text
    strings as objects as well.
  • MsgBox.Info(The view name is aViewName,
    Name)
  • Requests will return another object or not, e.g.
    theTheme.SetVisible(true), theProject
    av.GetProject
  • You might use variable (global/local) to
    reference the objects.
  • _theProject av.GetProject (global v)

36
Tools or Buttons
  • Button - Zoom in,
  • Tool - Zoom in Tool.
  • Tool has an additional property besides Click,
    Apply. It runs the script associated with it
    when applied to the active document

37
Click/Apply Scripts
  • Script associated with Zoom In Buttons Click
    property
  • av.GetProject.SetModified(true)
  • theView av.GetActiveDoc
  • theView.GetDisplay.ZoomIn(125)
  • Script associated with ZoomIn Tools Apply
    property
  • av.GetProject.SetModified(true)
  • theView av.GetActiveDoc
  • r theView.ReturnUserDoc
  • d theView.GetDisplay
  • if (r.IsNull) then
  • d.ZoomIn(125)
  • d.PanTo (d.ReturnUserPoint)
  • else
  • d.ZoomToRect(r)
  • end

38
Interacting w/ Other Appl.
  • RPC - all platforms
  • DDE - windows
  • DDL - windows
  • AppleEvents/AppleScript

39
Customizing ArcView User Interface
  • Start a new project
  • Select Project/Customize menu
  • Set Category to Menu, type to Appl
  • In File, make New Project menu invisible

40
Application Framework
  • The only instance of the Application class is the
    ArcView program, which can be accessed in Avenue
    through the keyword av. You can access almost
    all objects in ArcView from av because it
    contains all the objects that comprise ArcView.
    You can change the default name for ArcView GIS
    3.2a to any name you want by using
    av.SetName(Any Name Here)

system default
Project
Application
Extension
Script
DocGUI
Doc
DocWin
View
Table
Chart
Layout
SEd
41
Turn on/off the themes (open C\ESRI\AV_GIS30\AVT
UTOR\ARCVIEW\qstart.apr)
  • theProject av.GetProject
  • theView theProject.FindDoc(United States)
  • get the list of themes in the view
  • theThemeList theView.GetThemes
  • for each thm in theThemeList
  • turn each theme on if off, and off if on
  • if (thm.IsVisible) then
  • thm.SetVisible(false)
  • else
  • thm.SetVisible(true)
  • end if...then...else statement
  • end for each statement
  • theView.Invalidate

Start a new script and type in the codes
thm.SetVisible(thm.IsVisible.Not)
42
Now, try this on your script window
  • for each x in 1..10 by 1
  • MsgBox.Info("The numbe is"x.AsString, "What's
    the number")
  • end

43
Replace If..then..else with for each...
  • theProject av.GetProject
  • theView theProject.FindDoc(United States)
  • get the list of themes in the view
  • for each thm in theView.GetThemes
  • thm.SetVisible(thm.IsVisible.Not)
  • end for each statement

Can be replaced with av.GetActiveDoc
44
Message Box
  • Use message boxes to display information or
    accept user input
  • aRegionMsgBox.ListAsString(North,South,East
    ,West,Choose a region,County Database)
  • MsgBox.Info(aRegion Region,Loading...)

45
ListAsString(request)
  • Allow the user to select an object from aList.
    This request displays a scrolling list box of
    strings obtained by sending the AsString request
    to each object in aList. Use this request
    (instead of MsgBox.List) for lists that include
    "immutable" objects such as strings, numbers, or
    boolean values. This request returns the selected
    object or nil if the user clicks CANCEL.
  • Syntax
  • MsgBox.ListAsString (aList, aMsg, aTitle)

46
This is what we got
after selected West
47
Errors
Syntax Error a 4 b3 if b less than 4, Example) end
Run-time Error a 4 b3 a MsgBox(bAsString
is the result, Example)
Logic Error a Lake bForest aStrMsgBox.Inpu
t(Enter the theme you want to load, Load
Theme,) If (aStr Lake) and (aStrForest)
then do something end
48
Error Checking
  • theView av.GetActiveDoc
  • get the list of themes in the view
  • if (theView.GetThemes.Count0) then
  • MsgBox.Error(No themes in the view.,Cannot
    toggle themes)
  • exit
  • end
  • for each thm in theView.GetThemes
  • thm.SetVisible(thm.IsVisible.Not)
  • end for each statement

49
Tool or button?
  • button acts immediately, such as Zoom In button.
  • tool - remains depressed when its clicked, but
    usually nothing happens until you click somewhere
    in the active document, such as Zoom In Tool.
  • Tools has Apply property other than Click
    Apply is associated with scripts not click in
    tool

50
  • av.GetProject.SetModified(true)
  • theViewav.GetActiveDoc
  • theView.GetDisplay.ZoomIn(125)
  • av.GetProject.SetModified(true)
  • theViewav.GetActiveDoc
  • rtheView.ReturnUserRect
  • dtheView.GetDisplay
  • if (r.IsNull) then
  • d.ZoomIn(125)
  • d.PanTo(d.ReturnUserPoint)
  • else
  • d.ZoomToRect(r)
  • end

ZoomIn button
ZoomIn Tool
Write a Comment
User Comments (0)
About PowerShow.com