Welcome Guest, you are in: Login

FDOT Wiki

RSS RSS

GisFramework



Search the wiki
»

QueryService

RSS
Modified on Thursday, 14 July 2011 03:07 PM by 156.75.200.64 Categorized as Service Calls
The QueryService can be used to perform queries and a number of other Map Related functions for an ArcGIS MapService.

Table of Contents [Hide/Show]


ExportMap
      ExportMapOptions
      ExportMapResult
      Example
Find
      FindOperationOptions
      Example
GetAvailableLayers
      Example
Identify
      IdentifyOptions
      Example
Query
      SpatialQueryOptions
      Example
QueryObjectIds
      Example
See Also


ExportMap

The ExportMap function is used to get an image for a MapService given a set of parameters.

ExportMapOptions

NameTypeDescription
BoundingBoxMapExtentThe extent (bounding box) of the exported image. Unless the bboxSR parameter has been specified, the bbox is assumed to be in the spatial reference of the map.
BoundingBoxSpatialReferenceSpatialReferenceThe well-known ID of the spatial reference of the bbox. If the bboxSR is not specified, the bbox is assumed to be in the spatial reference of the map.
DpiintThe device resolution of the exported image (dots per inch). If the dpi is not specified, an image with a default DPI of 96 will be exported.
ImageFormatImageFormats?The format of the exported image. The default format is png.
ImageSpatialReferenceSpatialReferenceThe well-known ID of the spatial reference of the exported image. If the imageSR is not specified, the image will be exported in the spatial reference of the map.
LayerDefinitionExpressionsIEnumerableAllows you to filter the features of individual layers in the exported map by specifying definition expressions for those layers.
LayerIdsIEnumerableDetermines which layers appear on the exported map
SizeSizeThe size (width * height) of the exported image in pixels. If the size is not specified, an image with a default size of 400 * 400 will be exported.
TransparentMapboolIf true, the image will be exported with the background color of the map set as its transparent color.

ExportMapResult

NameTypeDescription
ExtentGeometryThe extent of the map that will be exported.
HeightintThe height in pixels of the map that will be exported.
HrefstringThe url of image that is being exported.
ScaledoubleThe scale of the map being exported.
WidthintThe width in pixels of the map that will be exported.

Example

var exportOptions = new ExportMapOptions
{
     BoundingBox = options.ViewExtent,
     LayerIds = options.MapServiceLayers[i].VisibleLayerIds,
     TransparentMap = true,
     BoundingBoxSpatialReference =options.BoundingBoxSpatialReference,
     ImageFormat = ImageFormats.PNG24,
     Size =(options.ShowLegend)? new Size {Height = 1300, Width = 1500}
                     : new Size {Height = 995, Width = 1600}
};

var svs = new SpatialQueryService(options.MapServiceLayers[i].Url);
ExportMapResult result = svs.ExportMap(exportOptions,"URL FOR MAPSERVICE");

Find

The find operation performs a textual query across multiple layers in a MapService.

FindOperationOptions

NameTypeDescription
ExactMatchOnlyboolIf this false then query will use a contains.
LayersIEnumerableThis is the list of layers that will be queried against.
ReturnGeometryboolSets if the operation will return the geometry.
SearchFieldsIEnumerableThe fields to search on.
SearchTextstringThe text to search on.
SpatialReferenceSpatialReferenceThe spatial reference of the output geometry.

Example

var options = new FindOperationOptions
    {
       ExactMatchOnly = parameters.ExactMatch,
       Layers = _mapService.Layers.Where(l => layerIds.Contains(l.Id.ToString() ) ).Select(l => l.Layer).ToList(),
       ReturnGeometry = true,
       SearchFields = parameters.Attributes.Select(a => a.Name).ToList(),
       SearchText = parameters.SearchValue,
       SpatialReference = MapHandler.MapSpatialReference
     };

var client = new QueryServiceClient();
var results = client.Find(options,"URL FOR MAPSERVICE");

GetAvailableLayers

Gets a list of all of the layers for a given MapService.

Example

QueryServiceClient querySvs = new QueryServiceClient();
var results= querySvs.GetAvailableLayers(Url);

Identify

The identify function allows the query of a point across layers in a MapService.

IdentifyOptions

NameTypeDescription
GeometryGeometryThe geometry to identify on. The type of the geometry is specified by the geometryType parameter.
GeometryTypeGeometryTypesThe type of geometry specified by the geometry parameter. The geometry type could be a point, a line, a polygon or an envelope. The default geometry type is a point (esriGeometryPoint).
ImageDisplayImageDisplayThe screen image display parameters (width, height and DPI) of the map being currently viewed.
LayerOptionsLayerOptionsThe layers to perform the identify operation on
MapExtentMapExtentThe extent or bounding box of the map currently being viewed. Unless the sr parameter has been specified, the mapExtent is assumed to be in the spatial reference of the map.
ReturnGeometryboolIf true, the resultset will include the geometries associated with each result
SpatialReferenceSpatialReferenceThe well-known ID of the spatial reference of the input and output geometries as well as the mapExtent. If sr is not specified, the geometry and the mapExtent are assumed to be in the spatial reference of the map, and the output geometries are also in the spatial reference of the map.
ToleranceintThe distance in screen pixels from the specified geometry within which the identify should be performed.

Example

var options = new IdentifyOptions
    {
        Geometry = geometry,
        GeometryType = GeometryTypes.Point,
        ImageDisplay = new ImageDisplay
             {
                  Dpi = (int)MapHandler.CurrentMap.Resolution,
                  Height = (int)MapHandler.CurrentMap.ActualHeight,
                  Width = (int)MapHandler.CurrentMap.ActualWidth
             },
        Tolerance = 5,
        ReturnGeometry = true,
        LayerOptions = new LayersOptions
             {
                  IdentifyLayerLevel = IdentifyLayerLevels.All,
                  LayerIds = layerIds
             },
        MapExtent = GeometryTranslator.TranslateEnvelope(MapHandler.GetExtent()),
        SpatialReference = new SpatialReference { WellKnownId = MapHandler.CurrentMap.SpatialReference.WKID.ToString() }
      };
var client = new QueryServiceClient();
var results=client.Identify(options,"URL FOR MAPSERVICE");

Query

The query function allows ad-hoc queries against single layers in a MapService.

SpatialQueryOptions

NameTypeDescription
CriteriaCriteriaThe textual criteria that is used for the query
GeometryGeometryThe geometry to apply as the spatial filter.
InputSpatialReferenceSpatialReferenceThe well-known ID of the spatial reference of the input geometry.
LayerLayerThe layer that is being queried against.
OutputSpatialReferenceSpatialReferenceThe well-known ID of the spatial reference for the returned geometry. If outSR is not specified, the geometry is returned in the spatial reference of the map.
ReturnAllFieldsboolSets if all the fields for the features will returned from the query.
ReturnFieldsIEnumerableThe list of fields to be included in the returned resultset.
ReturnGeometryboolIf true, the resultset includes the geometry associated with each result. The default is true
SecondaryCriteriaIEnumerableAdditional textual criteria for the query.
SpatialRelationshipQuerySpatialRelationships?The spatial relationship to be applied on the input geometry while performing the query.
TextCriteriaFieldNamesIEnumerable

Example

var criteria = new Criteria
    {
        ComparisonType = ComparisonType.Equals,
        Value = ids.First(),
        Field = idField
    };

var secondaryCriteria = ids.Skip(1).Select(sc => new SecondaryCriteria
    {
        ComparisonType = ComparisonType.Equals,
        Value = sc,
        Field = idField,
        LogicalOperator = LogicalOperator.Or
     }).ToList();

var sqo = new SpatialQueryOptions
     {
        Criteria = criteria,
        InputSpatialReference = MapHandler.MapSpatialReference,
        OutputSpatialReference = MapHandler.MapSpatialReference,
        Layer = layer,
        ReturnAllFields = true,
        ReturnGeometry = true,
        SecondaryCriteria = secondaryCriteria
     };

var client = new QueryServiceClient();
var result= client.Query(sqo,"URL FOR MAPSERVICE");

QueryObjectIds

The QueryObjectIds method returns all of the objectids for a given spatial query. The method takes a SpatialQueryOptions object as a parameter.

Example

var criteria = new Criteria
    {
        ComparisonType = ComparisonType.Equals,
        Value = ids.First(),
        Field = idField
    };

var secondaryCriteria = ids.Skip(1).Select(sc => new SecondaryCriteria
    {
        ComparisonType = ComparisonType.Equals,
        Value = sc,
        Field = idField,
        LogicalOperator = LogicalOperator.Or
     }).ToList();

var sqo = new SpatialQueryOptions
     {
        Criteria = criteria,
        InputSpatialReference = MapHandler.MapSpatialReference,
        OutputSpatialReference = MapHandler.MapSpatialReference,
        Layer = layer,
        ReturnAllFields = true,
        ReturnGeometry = true,
        SecondaryCriteria = secondaryCriteria
     };

var client = new QueryServiceClient();
var result= client.QueryObjectIds(sqo,"URL FOR MAPSERVICE");



See Also

Any Questions or Comments? Email
Some of the icons created by FamFamFam.