Overview
This topic discusses the JSON representation of data source objects. A dataSource is a table, feature class, or raster that resides in a registered workspace (either a folder or geodatabase).
The following dataSource objects are discussed:
- Table data source
- Query table data source
- Raster data source
- Join table data source
Table data source
{
"type": "table",
"workspaceId": "<registered workspace id>",
"dataSourceName": "<table name>",
"gdbVersion": "<version name>"
}
{
"type": "table",
"workspaceId": "MAP",
"dataSourceName": "MAP.user1.Taxlots",
"gdbVersion": "MAP.Version1"
}
Query table data source
A query table data source is a layer/table that is defined by a SQL query. Query layers allow both spatial and nonspatial information stored in a DBMS to be easily integrated into map service operations. Since queryTable uses SQL to directly query database tables and views, spatial information used by a queryTable is not required to be in a geodatabase.
{
"type": "queryTable",
"workspaceId": "<registered workspace id>",
"query": "<SQL query>",
"oidFields": "<field1>,<field2>,<field3>",
"geometryType": "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon>",
"spatialReference": {<spatial reference>}
}
{
"type": "queryTable",
"workspaceId": "SqlMAP",
"query": "SELECT * FROM TaxLots",
"oidFields": "taxlotid",
"geometryType": "esriGeometryPolygon",
"spatialReference": {"wkid": 4326}
}
Keep in mind the following for the properties above:
- When querying a table that stores geometry in the database native format, the result is returned as a layer that can be used in any operation supported by dynamic layer. For example, use this layer in an export operation by specifying a renderer.
- When a query layer is added as a dynamic layer to a map service, the extent defaults to the full extent of the spatial reference provided in the request.
- When querying a table that stores geometry in a non-native format, the result is returned as a table that can be used in query operations.
- When querying a table that does not have a geometry column, do not include
geometry
andType spatial
.Reference - For the
oid
property, there are only certain field types that can be used as a unique identifier. These field types include integer, string, GUID, and date. If a single integer field is specified, map server uses the values in that field directly to uniquely identify all features and rows returned from aFields query
. However, if a single string field or a group of fields is used as the unique identifier, map server maps those unique values to an integer.Table - Since the value in the unique identifier field uniquely identifies a row or feature object, values in that field must always be unique and not null. Map server operations will behave unpredictably when non-unique or null values are encountered. It is your responsibility to guarantee that values in this field meet this requirement. Map server does not enforce the uniqueness of values in the unique identifier field of a
query
. If multiple fields are chosen, the values in these fields will be used as a key to generate a unique integer value. This resultant field is always calledTable ESRI_
unless a field of that name already exists. The value of theOID ESRI_
field might possibly change for each request.OID
- Since the value in the unique identifier field uniquely identifies a row or feature object, values in that field must always be unique and not null. Map server operations will behave unpredictably when non-unique or null values are encountered. It is your responsibility to guarantee that values in this field meet this requirement. Map server does not enforce the uniqueness of values in the unique identifier field of a
Raster data source
Raster data source is a file-based raster that resides in a registered raster workspace.
{
"type": "raster",
"workspaceId": "<registered workspace id>",
"dataSourceName": "<raster name>"
}
{
"type": "raster",
"workspaceId": "rasterWS",
"dataSourceName": "NewOrleans.tif"
}
Join table data source
A join table data source is the result of a join operation.
{
"type": "joinTable",
"leftTableSource": <layerSource>,
"rightTableSource": <layerSource>,
"leftTableKey": "<field name from left table>",
"rightTableKey": "<field name from right table>",
"joinType": "<esriLeftOuterJoin | esriLeftInnerJoin>"
}
{
"type": "joinTable",
"leftTableSource":
{
"type": "mapLayer",
"mapLayerId": 0
},
"rightTableSource":
{
"type": "dataLayer",
"dataSource":
{
"type": "table",
"workspaceId": "MAP",
"dataSourceName": "MAP.user1.TaxLots",
"gdbVersion": "MAP.Version1"
}
},
"leftTableKey": "STATE_FIPS",
"rightTableKey": "FIPS",
"joinType": "esriLeftOuterJoin"
}
Keep in mind the following for the properties above:
- Nested joins are supported. To use nested joins, set either
left
orTable Source right
to be aTable Source join
.Table - The layer type is determined by the
left
property. IfTable Source left
is a table, the resultingTable Source join
is a table. If theTable left
property is a layer, the resultingTable Source join
is a layer.Table - For performance reasons it is ideal to have the
left
andTable Source right
properties point to a data source from the same workspace and have both properties be indexed.Table Source