SPATIALQUERY | Examples |
<SPATIALQUERY | Attribute
Description Table |
When using ArcMap Server: featurelimit ="integer" [All that meet criteria] searchorder ="optimize | spatialfirst | attributefirst" [optimize] subfields ="#ALL# | #ID# | #SHAPE# | Other fields in database" [#ALL#] where ="string" When using Image, Extract, Query, or Feature Server: accuracy ="Distance between points" [0] featurelimit ="integer" [All that meet criteria] joinexpression ="string" jointables ="string" searchorder ="optimize | spatialfirst | attributefirst" [optimize] subfields ="#ALL# | #ID# | #SHAPE# | Other fields in database" [#ALL#] where ="string" > When parent element is BUFFER: <SPATIALFILTER... /> When parent element is GET_FEATURES: <BUFFER... /> <FEATURECOORDSYS... /> <FILTERCOORDSYS... /> <SPATIALFILTER... /> When parent element is LAYER and LAYERDEF in GET_IMAGE: <BUFFER... /> <SPATIALFILTER... /> When parent element is LAYER in CONFIG: <FILTERCOORDSYS... /> <SPATIALFILTER... /> </SPATIALQUERY > |
<GET_FEATURES
outputmode="XML" geometry="true"> <LAYER id="4" /> <SPATIALQUERY subfields="#ALL#" where="NAME='Los Angeles'" /> </GET_FEATURES> |
<SPATIALQUERY subfields="#ALL#" where="UPPER(NAME)="TORONTO" > |
<SPATIALQUERY subfields="#ALL#" where="UPPER(MYSDE.US_STATES.STATE_NAME)="FLORIDA" > |
<SPATIALQUERY where="COUNTRY.STATE.FEMALES > COUNTRY.STATE.MALES" /> |
<SPATIALQUERY subfields="#ALL#" where="UPPER(NAME) = 'CANADA'"> |
<SPATIALQUERY where="DB.CITY.CITY_FIPS = DB.SCHOOLS.CITY_FIPS and DB.SCHOOLS.SCHOOL_ID = DB.SCHOOL_STATS.SCHOOL_ID and DB.CITY.CNTY_FIPS='013'" jointables="DB.SCHOOLS DB.SCHOOL_INFO" /> |
To | Refers to the master DBF table and defines the field that is used for joining. When referring to this table, the DBF table name must be used as a prefix to the field name. The entire expression is surrounded by square brackets, e.g., joinexpression="To=[mastertable.fieldname]". |
From | Refers to the DBF table that is joined to the master DBF table and the field that is used for joining, e.g., joinexpression="From=[jointable.fieldname]". |
Type=[exact] | Defines an exact match relation that permits only a single match between the master and join tables. Both one-to-one and many-to-one relations are exact match relations. In a one-to-one relation, there is only one record in the master that matches a single record in the join table. In a many-to-one relation, there are one or more records in the master that match a single join record. If there are multiple join records that match a single master record, then a composite record is only generated for the first join record. |
Type=[scan] | In a scan relation, if there are multiple join records for a master record, there is one composite record in the extended data file for each of the matching join records. Both one-to-many and many-to-many relations are scan relations. In a one-to-many relation, each record in the master can have multiple matching join records. A many-to-many relation is the same as one-to-many, except that different master records can match the same join record. |
joinexpression="To=[A.ID],From=[B.ID],Type=[scan];To=[B.NAME],From=[C.NAME], Type=[exact] " |
<SPATIALQUERY joinexpression="To=[counties.CNTY_FIPS],From=[countyinfo.FIPS],Type=[scan]; To=[countyinfo.FIPS],From=[state_roads.FIPS],Type=[scan]" jointables="countyinfo state_roads" where="counties. NAME='Washoe'" /> |
YYYY | Year | Required | Use four digits for the year. |
MM | Month (01-12) | Required | Use two digits for the month. March is 03. |
DD | Day (01-31) | Required | Use two digits for the day. The fourth is 04. |
hh | Hour (00-23) | Optional | Use a 24-hour clock. 8 a.m. is 08, and 8 p.m. is 20. |
mi | Minutes (00-59) | Optional | Use two digits for the minutes. If minutes is used, hours must also be included. |
ss | Seconds (00-59) | Optional | Use two digits for the seconds. If seconds is used, hours and minutes must also be included. |
<SPATIALQUERY where="MYDATE = {ts '2000-01-04 08:03:32'}" /> |
<SPATIALQUERY where="ARCSDE.TABLE.MYDATE = {ts '2002-03-08 21:18:00'}" /> |
Attribute | Usage | Back to Top |
---|---|---|
accuracy | Used in GET_FEATURES requests. Within a feature, generalizes points based on the distance specified and the resolution of the image. Units are the same as the service. | |
featurelimit | Used in GET_FEATURES requests. Maximum number of features to be extracted that meet criteria. The value for this featurelimit overrides any featurelimit set in GET_FEATURES. | |
joinexpression | Used for join tables with DBF files
only; jointables must be filled to contain list of tables used; not
required when a jointable is done on ArcSDE. String must form expression: "To=[master table column which will be used for joining], From=[defines a join table column which will be joined], Type=[exact or scan]". | |
jointables | List of joined table names separated by blank spaces; for ArcSDE, table name is full name including database name (e.g., DATA.STATE); for shapefiles, use the DBF filename without the extension (e.g., STATES). | |
searchorder | Used with ArcSDE layers only. Determines whether the attribute or spatial part of an ArcSDE query is processed first. "Spatialfirst" processes the spatial part of the query before the attribute part. "Attributefirst" processes the attribute part of the query first. If "optimize" is used, ArcSDE will make the judgment whether to pick "spatialfirst" or "attributefirst". | |
subfields | List of fields available for querying
or extracting. Multiple fields can be included in the subfields
list. Fields must be separated by blank space. If subfields is not used, all fields are returned. If subfields is used, only listed fields are returned. The subfields #SHAPE# or #ALL# must be included if geometry is to be returned in a FEATURES response. In addition, the GET_FEATURES geometry attribute must be set to true. The subfields list can include fields from the layer table or a joined table.
| |
where | Defines "where" part of SQL expression. Required when jointables attribute for ArcSDE tables is used. See Notes section for information on querying dates. |
Example 1: Setting a spatial query in a GET_IMAGE request. Note in this example that the DATASET fromlayer is "Countries". This refers to the LAYER id in the map configuration file, not the LAYER name. | Back to Top |
<?xml version="1.0"
encoding="UTF-8"?> <ARCXML version="1.1"> <REQUEST> <GET_IMAGE> <PROPERTIES> <ENVELOPE minx="-180" miny="-90" maxx="180" maxy="90" /> <IMAGESIZE width="643" height="502" /> </PROPERTIES> <LAYER type="featureclass" name="select layer" visible="true" id="300"> <DATASET fromlayer="Countries" /> <SPATIALQUERY> <SPATIALFILTER relation="area_intersection"> <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" /> </SPATIALFILTER> </SPATIALQUERY> <SIMPLERENDERER> <SIMPLEPOLYGONSYMBOL fillcolor="255,255,255" filltype="cross" /> </SIMPLERENDERER> </LAYER> </GET_IMAGE> </REQUEST> </ARCXML> |
Example 2: Setting a spatial query in a GET_FEATURES request. | Back to Top |
<?xml version="1.0"
encoding="UTF-8"?> <ARCXML version="1.1"> <REQUEST> <GET_FEATURES outputmode="xml" geometry="false"> <LAYER id="Countries" /> <SPATIALQUERY > <SPATIALFILTER relation="area_intersection"> <POLYGON> <RING> <POINT x="-87.73640582356195" y="41.84726275" /> <POINT x="-87.73640582356195" y="41.884308250000004" /> <POINT x="-87.68764017643805" y="41.884308250000004" /> <POINT x="-87.68764017643805" y="41.84726275" /> <POINT x="-87.73640582356195" y="41.84726275" /> </RING> </POLYGON> </SPATIALFILTER> </SPATIALQUERY> </GET_FEATURES> </REQUEST> </ARCXML> |
Example 3: Joining DBF files in CONFIG. | Back to Top |
<?xml version="1.0"
encoding="UTF-8"?> <ARCXML version="1.1"> <CONFIG> <ENVIRONMENT> <LOCALE country="US" language="en" variant="" /> <UIFONT color="0,0,0" name="Arial" size="12" style="regular" /> <SCREEN dpi="96" /> </ENVIRONMENT> <MAP> <PROPERTIES> <ENVELOPE minx="-178.215027" miny="18.924782" maxx="-66.969849" maxy="71.406647" name="Initial_Extent" /> <MAPUNITS units="decimal_degrees" /> </PROPERTIES> <WORKSPACES> <SHAPEWORKSPACE name="shp_ws-0" directory="<path to USA ESRIDATA>" /> </WORKSPACES> <LAYER type="featureclass" name="counties" visible="true" id="0"> <DATASET name="COUNTIES" type="polygon" workspace="shp_ws-0" /> <SPATIALQUERY where="counties.STATE_NAME='Nevada'" jointables="countyinfo" joinexpression="To=[counties.FIPS],From=[countyinfo.FIPS],Type=[scan]" > <SPATIALFILTER relation="area_intersection"> <ENVELOPE minx="-126" miny="31" maxx="-108" maxy="46" /> </SPATIALFILTER> </SPATIALQUERY> <SIMPLERENDERER> <SIMPLEPOLYGONSYMBOL fillcolor="27,127,27" filltype="solid" /> </SIMPLERENDERER> </LAYER> </MAP> </CONFIG> </ARCXML> |
Example 4: Joining ArcSDE tables in CONFIG. | Back to Top |
<?xml version="1.0"
encoding="UTF-8"?> <ARCXML version="1.1"> <CONFIG> <ENVIRONMENT> <LOCALE country="US" language="en" variant="" /> <UIFONT color="0,0,0" name="Arial" size="12" style="regular" /> <SCREEN dpi="96" /> </ENVIRONMENT> <MAP> <PROPERTIES> <ENVELOPE minx="-175.2" miny="-90.0" maxx="179.2" maxy="83.6" name="Initial_Extent" /> <MAPUNITS units="decimal_degrees" /> </PROPERTIES> <WORKSPACES> <SDEWORKSPACE name="sde_ws-4" server="sierra" instance="esri_sde" database="" user="world_data" encrypted="true" password="LXEMUR" /> </WORKSPACES> <LAYER type="featureclass" name="WORLD.CITY" visible="true" id="0"> <DATASET name="WORLD.CITY" type="point" workspace="sde_ws-4" /> <SPATIALQUERY where="WORLD.CITY.FIPS_CNTRY = WORLD.COUNTRYP.FIPS_CNTRY and WORLD.COUNTRYP.FIPS_CNTRY='CA' " jointables="WORLD.COUNTRYP" > <SPATIALFILTER relation="area_intersection"> <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" /> </SPATIALFILTER> </SPATIALQUERY> <SIMPLERENDERER> <SIMPLEMARKERSYMBOL color="27,227,27" width="8" /> </SIMPLERENDERER> </LAYER> </MAP> </CONFIG> </ARCXML> |
Example 5: Using both an attribute query and a spatial filter in CONFIG. | Back to Top |
<?xml version="1.0"
encoding="UTF-8"?> <ARCXML version="1.1"> <CONFIG> <ENVIRONMENT> <LOCALE country="US" language="en" variant="" /> <UIFONT color="0,0,0" name="Arial" size="12" style="regular" /> <SCREEN dpi="96" /> </ENVIRONMENT> <MAP dynamic="true"> <PROPERTIES> <ENVELOPE minx="-180" miny="-90" maxx="180" maxy="90" name="Initial_Extent" /> <MAPUNITS units="decimal_degrees" /> </PROPERTIES> <WORKSPACES> <SHAPEWORKSPACE name="shp_ws-0" directory="<path to WORLD ESRIDATA>"/> </WORKSPACES> <LAYER type="featureclass" name="CITIES" visible="true" id="2"> <DATASET name="CITIES" type="point" workspace="shp_ws-0" /> <SPATIALQUERY where="POPULATION > 2000000"> <SPATIALFILTER relation="area_intersection"> <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" /> </SPATIALFILTER> </SPATIALQUERY> <SIMPLERENDERER> <SIMPLEMARKERSYMBOL type="square" width="5" /> </SIMPLERENDERER> </LAYER> </MAP> </CONFIG> </ARCXML> |
Example 6: Using a date query in a GET_FEATURES request. | Back to Top |
<?xml version="1.0"
encoding="UTF-8" ?> <ARCXML version="1.1"> <REQUEST> <GET_FEATURES featurelimit="25" beginrecord="0" outputmode="xml" geometry="false" envelope="true" compact="true"> <LAYER id="0" /> <SPATIALQUERY subfields="#ALL#" where="MYDATE = {ts '2000-01-07'}" /> </GET_FEATURES> </REQUEST> </ARCXML> |