Basic Access and Map Services
Accessing the API's web services, common data structures and terminology, and basic map methods
Avi
Blackmore
Head Programmer/Administrator
2013
Agri ImaGIS Technologies, Inc.
Table of Contents
Basic PatternsAt present, the Satshot system is set up around a set of "sites", which are separate URLs for separate regions of the world. (This may change in future.) In order to access a
site, a client must point its HTTP transport at the appropriate URL. The general format is "https://SITEDOMAIN/xmlrpc.php". The xmlrpc.php file is the XML-RPC server program.
Available sites, and their domains, are as follows: United States (us.satshot.com), Canada (ca.satshot.com), and Mexico (mexico.satshot.com). Others may be added in the
future.
The first method which any client should call is login(). The login() method establishes the session ID and allocates space for temporary files for the given
user. Successful execution of this method is required to do anything with the Services API. The obvious counterpart to login() is logout(), which destroys the
user session and deletes all temporary files.
IMPORTANT: if the client is not going to use cookies in its HTTP transport, calls to login() must preserve the return value, as this value is the ID token required to
access services. The value should thus be appended to the URL like so: "?idtoken=VALUE", where VALUE is the token string returned from login().
Temporary data include map contexts, images, vectors, and other transient data created and manipulated by the API. For the most part, these data are tracked by the server;
only the handles returned by API methods need to be tracked client-side.
Some forms of temporary data can be made persistent, and then reloaded in another session, via various SAVE methods in the API. These include images, vectors, and other
entities. These are referred to in the documentation as "datasets", and are tied to geospatial objects.
The login() method allows multiple sessions per user account. The sessions are isolated from each other in terms of temporary data; however, changes to permanently
saved data, such as field boundaries and their datasets, will be visible to all sessions. Services API methods which make such changes use locking to prevent race conditions
on the server, but client programs should be prepared to incorporate updates that did not originate within that particular client instance.
Methods which modify or delete objects or their datasets are restricted between sessions as follows: if more than one session has the object hilited when the method is
called, the method is not allowed to proceed. Adding new datasets, or operations that read from the datasets (such as exporting), are never restricted.
The basic pattern for use of the system is to log in, load up one or more map contexts, select (or create) one or more objects, choose a scene of imagery, and then analyze
the scene within the objects. While many API methods can be called in any order, there is a basic ordering to certain operations, notably the analysis "toolchain".
Login sessions have an idle expiration time of three hours from the last API call; that is, if the session is idle for three hours, the server performs an automatic logout,
clearing temporary data and invalidating the session token. This does not apply to sessions which have been in use for three hours, if the client makes regular or frequent
API calls. A session can exist for an indefinite period, it just cannot be idle for longer than three hours.
Map ContextsA "map context" is necessary to display anything geospatial using the Satshot Services API, or to perform geospatial operations. The method load_map() (and its plural
counterpart, load_maps()) is responsible for loading a map context, and returning the opaque handle which refers to that context; this handle is a randomly-generated
string.
A map context is an instance of a map, a transient working copy placed in the current user's temporary space; these maps are used to create visual representations of the
geospatial data stored on and created by the server API. Depending on the site, there may be one map available, or many: for the United States, maps are available on a
per-state basis. Just about any method which performs geospatial operations requires a map context.
Clients may have as many map contexts open as they wish: the API places no restrictions on the number of open maps. Client programs are responsible for keeping track of map
contexts by keeping the string handles in local (client-side) variables. Map contexts are not persistent: they disappear as soon as the user logs out.
While its handle is a simple, random string, the map context itself, on the server, contains a great deal of state. Among other things, the map context has a name, projection
and associated coordinate system, extents, width and height (this is the size of the output image generated by draw_map()), and last but not least, layers.
A map layer is a single source of geospatial data, be it a vector table or a raster image, and its associated drawing information. When the server uses a map context to draw
a map image (using draw_map()), any of these layers which are set to ON are loaded and drawn in order, with later layers drawn on top of earlier
ones. Each layer data source has its own representation, or style, determining how it looks on the final map. At present, the API does not allow these styles to be modified
externally, but this may change later.
Some layers are permanent parts of a map context, while others (those which refer to transient data, such as loaded datasets) are temporary, created and destroyed by API
methods. Examples of the latter are layers used to display scenes, extracted images, analyses, edited images, or user-created vector tables such as spreadmaps and
soilmaps. These temporary layers are created with the methods create_image_display_layer() (or create_multiple_image_display_layers()) for images, and
create_vector_display_layer() (or create_multiple_vector_display_layers()) for vectors; similarly, remove_image_display_layer() (or
remove_multiple_image_display_layers()) and remove_vector_display_layer() (or remove_multiple_vector_display_layers()) remove these layers from the map.
Also, layers can be queried through API methods, returning data based on the map's current extents, or other criteria. Examples are the "public location" layers, such as
states or provinces, counties or their equivalents, Public Land Survey boundaries (townships and sections), or cities and towns. These can be queried using the method
get_map_public_locations(). Finally, any vector layer may be queried using the geospatial query methods: make point queries with
query_map_layer_at_map_coordinate()
(or query_multiple_map_layers_at_map_coordinate()), or for clients without native geospatial capability, query_map_layer_at_pixel_point() (or
query_multiple_map_layers_at_pixel_point(). These methods identify the features intersecting the given point, or within a given radius around that point. The method
query_map_layer_with_layer_shapes() allows querying one layer using features from another vector layer, performing an intersection query between the two layers.
The portion of a map's layers which is displayed at any given moment is determined by the map's extents. The extents of a map are, quite simply, the area of the map to
display: the coordinates which define a bounding box within which that portion of the map is visible. This bounding box is represented by four coordinates: the minimum x and
y positions (minx and miny), and the maximum x and y positions (maxx and maxy). These extents are, by default, returned in latitude and longitude ("latlong"), and can be set
in latlong or using another specified coordinate system. The primary method to set a map context's extents is, unsurprisingly, set_map_extents(). Setting extents is
the primary means of zooming and panning a map, though not the only one: for clients which need "point and click" zooming, the method zoom_map_at_pixel_point()
translates a "click" in a portion of a map's output image into coordinates to zoom to, with a "zoom factor" determining how to zoom around that point. Similarly,
zoom_map_at_map_coordinate() zooms the map to a geospatial coordinate, with a similar "zoom factor". zoom_map_to_map_coordinate_with_radius() is more direct,
setting the extents to the bounding box of a circle around a given point, with the given radius. Finally, zoom_map_to_pixel_rectangle() is a pixel-based form of
set_map_extents(), setting the map extents to a bounding box translated from the pixel coordinates.
A map context also has a coordinate projection system. This determines how the map is rendered as an image using draw_map(). Each map has its own default projection,
which is one of the Universal Transverse Mercator (UTM) zones: the zone selected for a map is the one which covers most of the region defined by that map, for instance, the
zone which covers most of a US state or Canadian province. A client can easily change a map context's projection by using set_map_projection(). Projections can be
specified using the Open Geospatial Consortium's "Well-Known Text" (WKT) format, or as a string of parameters for the free and standard PROJ.4 projection software (a "proj
string"). Documentation on these formats is beyond the scope of this document, but information on PROJ.4 parameters is available at http://proj.osgeo.org, and a list of
common projections (including PROJ strings) at http://www.remotesensing.org/geotiff/proj_list/. Suffice to say, there are a lot of projections to choose from.
Map DisplayThe draw_map() method is the primary means of displaying a map context as an image: it renders the map to an image file and returns the binary. However, there is an
alternative to using draw_map() for display: the API also provides WMS support via a server script. A WMS-capable client can target the script via a URL of this form:
"https://SITEDOMAIN/wms.php". (Regular API calls should still go to the xmlrpc.php server.)
WMS requests through this script have the following requirements, over and above the regular WMS request specification: The "map" parameter must be a loaded map context, and
the login token (idtoken) must be passed as a parameter called "idtoken". Otherwise, requests are as standard WMS. This means of displaying a map context may be more
suitable for clients which have native GIS capability, in particular clients which can make use of tiled requests.
The primary advantage for using WMS is that it supports tiling, using the standard Google Maps tile addressing scheme. To use this, add two parameters to the WMS url:
"mode", which must be set to "tiled", and "tile", which should be the x+y+zoom string of a Google Maps tile address. When using tiled requests, the "BBOX", "width", and
"height" parameters are unnecessary: tiles are standardized to 256x256 pixels, and the bounding box will be calculated from the tile address.
HandlesVarious methods in the API return opaque handles for temporary, server-side objects which represent user-generated geospatial datasets, such as extracted raw images,
analyses, edited images, or generated vectors. These handles, which are random strings, will be named as such in a method's documentation, for instance, "image handle" or
"vector handle". The handles act as references for the server-side objects; they are not, themselves, meaningful. Also, they are not persistent, and like map contexts,
disappear at logout. However, datasets represented by handles can be saved permanently using the methods provided for doing so, such as save_analysis() or
save_vector_to_object().
There are also some methods, such as the EXPORT methods, which can retrieve the actual data objects represented by a handle from the server: for instance,
export_image_in_simple_format() retrieves the image file represented by an image handle, while export_vector_table() does the same for a vector handle.
Saved datasets are retrieved using several methods. To get info on the set of datasets saved to particular objects, use get_saved_datasets_for_objects(). This
method will return information on all of the different dataset types supported by the Satshot system: analyses, edited images, vectors of all types, and geotagged photos.
Structured DataMany other methods return "structs", an XML-RPC type which represents a structured mapping of keys and values; various languages refer to these as structures, dictionaries,
hashmaps, associative arrays, and the like. This heavy use of structured data is meant to aid client programs in mapping values in a meaningful fashion: rarely is anything
returned as a simple array, unless it is truly a one-dimensional data set. Many methods also take structs as arguments, again, as a means of preserving meaningful
associations.
If a given method either takes a struct as an argument, or returns a struct, the method's documentation will describe the keys and values. Where specific key names are given,
those key names should be used exactly as written: assume case-sensitivity, for instance.
One common struct is the "extents struct", returned by many methods. An extents struct always has the same four keys, which correspond to the four extent coordinate parts:
"minx", "miny", "maxx", "maxy".
HilitesFinally, there are a number of methods which refer to "hilites", or hilited objects. A "hilite" is a temporary copy of a geospatial object, or a newly-created, transient
object. Hilites are used as a general "working set" or "scratch space" for vector objects, whether they be copies of permanent objects, or temporary objects that were just
created via other methods. Hilites are part of the temporary session state, and are not preserved across sessions. However, hilites can be saved as permanent objects. They
can also be created, modified, or deleted using various methods in the API.
Hilites which correspond to temporary objects created via the API, can be saved as permanent geospatial objects. Hilites which represent permanent objects can be used to
examine the data associated with the permanent objects; they are also used to analyze imagery and create derived datasets, which can then be saved or exported. And, finally,
they can be modified and then saved again, either as new objects or replacing the existing fields.
One important note about hilites: a hilited object is "locked", in the sense that any method which requires "modify" access to the object will fail if more than one session
has that object hilited. Thus, hiliting acts as a form of concurrency control.
There are several methods which create new hilited shapes, and others which select permanent objects for hiliting. These are described in full in Regions and Objects.
However, there are several other basic methods for accessing and manipulating the currently hilited shapes. The get_hilites() method is the most important, as it
retrieves a struct containing information about all of the currently hilited shapes. To get the extents of the hilites, get_hilite_extents() will return that
information. The methods rename_hilited_shape() (or rename_hilited_shapes()) will rename hilites, although this change is temporary unless
save_hilited_objects() is called, while remove_hilited_shape() (or remove_hilited_shapes()) will remove objects from hilites. Finally
clear_hilites() removes all hilited shapes.
Method ReferenceBasic system access:
Map loading and control:
Querying map layers:
Map output (drawing):
Hilite control:
Datasets:
| Prev |
Up |
Next |
| Understanding and Using the Satshot Services API, Version 2 |
Understanding and Using the Satshot Services API, Version 2 |
Groups and Users |
|
|