TerraBits is an enhanced Tcl interface to the TerraServer-USA Web service, a programmable interface to the world's largest online database, providing free public access to a vast data store of maps and aerial photographs of the United States. Syntax of a TerraBits command is terraBits.terraServiceCommand ?options?where terraBits. is a prefix, terraServiceCommand is a standard TerraService command name, options are pairs of "-opt value" for specifying parameters and their associated values. To retrieve options of a TerraBits command, invoke the command with a "?" as argumenmt, terraBits.terraServiceCommand ?To retrieve default option values of a TerraBits command, invoke the command with "default" as argument, terraBits.terraServiceCommand defaultTo use TerraBits API, a user must open a TerraBits session first. This is done by the followng command set id [terraBits.open]The returned id is a service identification number required by many TerraBits API commands. The user must close a TerraBits session when the works are done in order to release the allocated resources. To close a TerraBits session, use the following commmand, terraBits.close $idStandard TerraBits API. This API is a Tcl wrap of TerraService and LandmarkService. terraBits.ConvertLonLatPtToNearestPlace ?options?The returned data is either a string or a tagged list. A tagged list is a special Tcl list with its odd items as a tagged name for the following even item, which can be either a tagged list or an ordinary string. XBit uses @ as the first character of a tagged name to distinguish a tagged list and an ordinary string. A tagged list is used to parse an XML string returned from a service call to TerraService or LandmarkService. For an example, the following XML string <?xml version="1.0" encoding="utf-8"?>is the result after invoking ConvertLonLatPtToUtmPt serivce via following TerraBits API command, terraBits.ConvertLonLatPtToUtmPt -id $id -lat 37.5 -lon -120The result XML string will be parsed by TerraBits and returned as a Tcl tagged list: @Zone 11 @X 234798.13038006157 @Y 4154570.1539562792The following scripts demonstrate how to retrieve 6 tiles covering Pentagon, DC and display them in a Tk canvas: # create a canvasAdvanced TerraBits API. This API is build upon the standard TerraServer Client API with additional Tcl scripts. All the API commands return a rimage and display it with XBit's view widget during data retrieval process. API commands terraBits.GetTiles, terraBits.GetNearestTiles and terraBits.GetTilesFromPlace retrieve an image in units of tiles. The width and height of an image is always in mutiple of 200, i.e., the size of a tile. API commands terraBits.GetImageByRect, terraBits.GetImageByPlace and terraBits.GetImageByLonLatPt retrieve an image in units of pixel numbers, which are specified in options -width and -height. terraBits.GetTiles ?options? retrieves image tiles from TerraServer using tile coordinates, mosaics them together to form a signal image and displays the image during the retrieval process. It returns the rimage tag of the mosaiced image when it is done.To retrieve the same Pentagon image and display it in a XBit's view widget, use the follwing command, terraBits.GetNearestTiles -theme RGBPhoto -scene 18 -scale Scale2m -x0 321300 -x1 322300 -y0 4304000 -y1 4304700 The following script retrieves an image of "White House" and displays it in a XBit's view widget: terraBits.GetImageByPlace -theme RGBPhoto -city "White House" -state DC -scale Scale500mm The following script retrieves a Topo map of Fremont, CA: terraBits.GetImageByPlace -theme Topo -city Fremont -state CA -scale Scale4m -width 2000 -height 2000 |
|