Class LayerDescriptionClass

Namespace
ESRI.ArcGIS.Carto
Assembly
ESRI.Server.Carto.dll
[ClassInterface(ClassInterfaceType.None)]
[Guid("5D9E564D-930C-4179-B108-4CEA9B4ACF01")]
public class LayerDescriptionClass : LayerDescription, ILayerDescription, IMapTableDescription, IMapTableTimeDescription, IXMLSerialize, IPersistStream, IPersist
Inheritance
LayerDescriptionClass
Implements
Inherited Members

Constructors

LayerDescriptionClass()

public LayerDescriptionClass()

Explicit Interface Implementations

DefinitionExpression

The definition expression for the layer.

virtual string DefinitionExpression { get; set; }

Returns

string

Remarks

A DefinitionExpression can be set on a layer in order to limit layer features available for display or query. This only applies for the
request and does not replace the definition query set in the source
map.

When UseStandardizedQueries is True:

  • the DefintionExpression of a LayerDescription retrieved from IMapServerInfo.DefaultMapDescription is always empty regardless of whether a definition expression is set on the layer in the source map. Use IMapTableInfo3::DefinitionExpression, to find out what is the definition expression set, if there is any, to the layer in the source map.
  • an expression set in the LayerDescription will be appened to the one set for the layer in the source map.
  • you can only use StandardizedQueries. This means you will always  format a query on a date field the same way or if you want to find all features where the value in a string field contains a specified keyword, you can use the same function name regardless of the underlying database type. Queries containing anything specific to the underlying database, for example, a function that is only supported by the database but is not part of the StandardizedQueries specification will fail.

When UseStandardizedQueries is False:

  • a layer can have a default definition expression that is set for that layer in the source map.
  • an expression set in the LayerDescription will override the one set for the layer in the source map.
  • the query must conform to the underlying database's syntax and use functions supported by that database.

 

Let's look at some examples. You have a layer in your map that represents sales regions. The layer includes fields: REGIONS, SALES and MANAGER.

Example #1: In the source map the layer has a definition query, "REGION = North". No DefintionExpression is specified in LayerDescription. Only those features where REGION = North will be displayed in your map.

Example #2: In the source map the layer has a definition query, "REGION = ‘North’". You apply a DefinitionExpression in LayerDescription as "SALES > 1000". The LayerDescription DefinitionExpression overrides the definition query set in the source map. Only those features where SALES > 1000 will be displayed in your map.

If you wish to use the DefinitionExpression as a way of getting a subset of the features already filtered by the definition query in the map you will need to save the original expression and then add it to the new expression to form one compound expression, “REGION = ‘North’ AND SALES > 1000”. This will display map features that are belong to the North region and have sales over 1000.

Example #3: In the source map the layer has no definition query. You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Only those features where SALES > 1000 will be displayed in your map.

The following MapServer methods will honor DefinitionExpression: Find, Identify, QueryFeatureCount2, QueryFeatureIds2, QueryFeatureData2 and QueryHyperlinks2.

Although the DefinitionExpression set in the LayerDescription will override any any definition query set in the source map, there are MapServer methods that only honor the expression set in the source document. Any expression set in DefinitionExpression in the LayerDescription will be ignored. These mothods include: QueryFeatureCount, QueryFeatureIds, and QueryFeatureData. MapDescription, which contains the LayerDescriptions, are not a parameter for these methods.

DefinitionExpression does not affect spatial extents.

Deserialize(IXMLSerializeData)

Deserializes an object from XML.

virtual void Deserialize(IXMLSerializeData data)

Parameters

data IXMLSerializeData

GetClassID(out Guid)

virtual void GetClassID(out Guid pClassID)

Parameters

pClassID Guid

GetSizeMax(out _ULARGE_INTEGER)

virtual void GetSizeMax(out _ULARGE_INTEGER pcbSize)

Parameters

pcbSize _ULARGE_INTEGER

ID

The layer ID. This is a unique ID for the layer, and is used to identify the layer in a number of method calls.

virtual int ID { get; set; }

Returns

int

Remarks

ID is a unique identifier for a layer in a given instance of ArcGIS for Server map service. It is important to note that ID, SourceID and the index of layers (see MapLayerInfos) in map document are not the same. SourceID is used for map service interaction with the GPServer.

When a map service is published, a unique ID is assigned to all layers within the original map document (.mxd) starting from 0 (zero). This ID is accessible from IMapServerObjects2, MapLayerInfo, LayerDescription, MapServerLegendInfo, MapServerIdentifyResult, MapServerFindResult and FeatureExtent.

ID is not re-usable and does not change if the order of the layer is changed. This would change the how each layer is ordered in the index of layers. Adding new a layer results in a new ID being assigned.  IDs keep incrementing as new layers are added to the map service. The limit of id numbers available is the limit of Long data type.

Please note that if the layer order in the TOC of the original map is changed or if layers are added/removed, the IDs will change accordingly.

IMapTableDescription_DefinitionExpression

The definition expression for the table.

virtual string IMapTableDescription_DefinitionExpression { get; set; }

Returns

string

Remarks

A DefinitionExpression can be set on a layer or a table in order to limit layer features or rows available for display or query. This only applies for the request and does not replace the definition query set in the source map.

When UseStandardizedQueries is True:

  • the DefintionExpression of a LayerDescription retrieved from IMapServerInfo.DefaultMapDescription is always empty regardless of whether a definition expression is set on the layer in the source map. Use IMapTableInfo3::DefinitionExpression, to find out what is the definition expression set, if there is any, to the layer in the source map.
  • an expression set in the LayerDescription will be appened to the one set for the layer in the source map.
  • you can only use StandardizedQueries. This means you will always  format a query on a date field the same way or if you want to find all features where the value in a string field contains a specified keyword, you can use the same function name regardless of the underlying database type. Queries containing anything specific to the underlying database, for example, a function that is only supported by the database but is not part of the StandardizedQueries specification will fail.

When UseStandardizedQueries is False:

  • a layer can have a default definition expression that is set for that layer in the source map.
  • an expression set in the LayerDescription will override the one set for the layer in the source map.
  • the query must conform to the underlying database's syntax and use functions supported by that database.

 

Let's look at some examples. You have a layer in your map that represents sales regions. The layer includes fields: REGIONS, SALES and MANAGER.

Example #1: In the source map the layer has a definition query, "REGION = North". No DefintionExpression is specified in LayerDescription. Only those features where REGION = North will be displayed in your map.

Example #2: In the source map the layer has a definition query, "REGION = ‘North’". You apply a DefinitionExpression in LayerDescription as "SALES > 1000". The LayerDescription DefinitionExpression overrides the definition query set in the source map. Only those features where SALES > 1000 will be displayed in your map.

If you wish to use the DefinitionExpression as a way of getting a subset of the features already filtered by the definition query in the map you will need to save the original expression and then add it to the new expression to form one compound expression, “REGION = ‘North’ AND SALES > 1000”. This will display map features that are belong to the North region and have sales over 1000.

Example #3: In the source map the layer has no definition query. You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Only those features where SALES > 1000 will be displayed in your map.

The following MapServer methods will honor DefinitionExpression: Find, Identify, QueryData, QueryRowIDs, QueryRowCount, QueryFeatureCount2, QueryFeatureIds2, QueryFeatureData2 and QueryHyperlinks2.

Although the DefinitionExpression set in the LayerDescription will override any any definition query set in the source map, there are MapServer methods that only honor the expression set in the source document. Any expression set in DefinitionExpression in the LayerDescription will be ignored. These mothods include: QueryFeatureCount, QueryFeatureIds, and QueryFeatureData. MapDescription, which contains the LayerDescriptions, are not a parameter for these methods.

DefinitionExpression does not affect spatial extents.

IMapTableDescription_ID

The table ID. This is a unique ID for the layer, and is used to identify the table in a number of method calls.

virtual int IMapTableDescription_ID { get; set; }

Returns

int

Remarks

An identifier that uniquely identifies a layer or a table within a map

IPersist_GetClassID(out Guid)

virtual void IPersist_GetClassID(out Guid pClassID)

Parameters

pClassID Guid

IsDirty()

virtual void IsDirty()

LayerResultOptions

Indicate whether to include and/or modify Geometry.

virtual ILayerResultOptions LayerResultOptions { get; set; }

Returns

ILayerResultOptions

Remarks

<P>Use <A href="javascript:Jump('esriCarto/LayerResultOptions.htm')"><STRONG>LayerResultOptions</STRONG></A> when you want to customize the results of a MapServer query - for example, when you want field names (instead of field aliases) or data in native format or in some cases you may want to limit or adjust the geometry being returned.</P> <P>Since LayerResultsOptions is part of of the LayerDescription any settings made for LayerResultsOptions will only affect those methods that include the LayerDescription (or MapDescription whcih contains LayerDescriptions) as a parameter. These include <A href="javascript:Jump('esriCarto/IMapServer2_Find.htm')"><STRONG>Find</STRONG></A>, <A href="javascript:Jump('esriCarto/IMapServer2_Identify.htm')"><STRONG>Identify</STRONG></A>, <STRONG><A href="javascript:Jump('esriCarto/IMapServer3_QueryData.htm')">QueryData</A></STRONG>, <STRONG><A href="javascript:Jump('esriCarto/IMapServer3_QueryRowIDs.htm')">QueryRowIDs</A></STRONG>, <STRONG><A href="javascript:Jump('esriCarto/IMapServer3_QueryRowCount.htm')">QueryRowCount</A></STRONG>, <A href="javascript:Jump('esriCarto/IMapServer2_QueryFeatureCount2.htm')"><STRONG>QueryFeatureCount2</STRONG></A>, <A href="javascript:Jump('esriCarto/IMapServer_QueryFeatureIDs2.htm')"><STRONG>QueryFeatureIDs2</STRONG></A>, <A href="javascript:Jump('esriCarto/IMapServer2_QueryFeatureData2.htm')"><STRONG>QueryFeatureData2</STRONG></A> and <A href="javascript:Jump('esriCarto/IMapServer_QueryHyperlinks.htm')"><STRONG>QueryHyperlinks</STRONG></A>. QueryHyperLinks always returns geometry regardless InlcudeGeometry’s value, but honors GeometryResultOptions.</P>

Load(IStream)

virtual void Load(IStream pstm)

Parameters

pstm IStream

Save(IStream, int)

virtual void Save(IStream pstm, int fClearDirty)

Parameters

pstm IStream
fClearDirty int

ScaleSymbols

Indicates whether the layer should scale its symbols according to the reference scale.

virtual bool ScaleSymbols { get; set; }

Returns

bool

Remarks

In order for symbols to scale, the map must have a reference scale set and the layer must support symbol scaling. Use ScaleSymbols to activate or deactivate a layer's symbol scaling. If a map does not have a set reference scale setting, ScaleSymbols will have no effect. Use CanScaleSymbols on IMapLayerInfo2 to verify if a layer supports symbol scaling. A reference scale is set within the original map document.

You can set a new reference scale for the MapServer object by accessing the IMap interface through IMapServerObjects2. This should be done with objects in a non-pooled environment.  Changing the state of pooled objects this way will lead to unexpected results.

SelectionBufferDistance

The selection buffer distance. When drawing, and if a selection filter is specified, a buffer zone of the specified distance will be displayed around the selected features.

virtual double SelectionBufferDistance { get; set; }

Returns

double

Remarks

The selection buffer is based on Euclidian distance. The accuracy of the buffer is dependent on the spatial reference used in the map. An inappropriate spatial reference will result in inaccurate buffer distances. For best results, the map should be in an appropriate spatial reference.

In order to control the amount of information MapServer needs to process for a buffer, a maximum number of records to be buffered can be set. This value is contained in the MaxBufferCount property. The default value for this property is 100. If the number of features to be buffered exceeds MaxBufferCount no features will be buffered. The MaxBufferCount can also be changed by modifying the MaxRecordCount XML tag in the MapServer's configuration file.

 

[C#]

The following sample code shows how to create a buffer around selected features. It assumes that you already have a valid MapServer and MapDescription object.

IMapServer mapServer;
IMapDescription mapDesc;
// Select all features in layer 0
string strMapName = mapDesc.Name;
int layerID = 0;
IFIDSet FIDs = mapServer.QueryFeatureIDs(strMapName, layerID, null);
// Create buffer around selected feature
ILayerDescription layerDesc = mapDesc.LayerDescriptions.get_Element(layerID);
layerDesc.SelectionFeatures = FIDs;
layerDesc.SelectionBufferDistance = 1; // map units
layerDesc.ShowSelectionBuffer = true;

SelectionFeatures

Array of selected features.

virtual IFIDSet SelectionFeatures { get; set; }

Returns

IFIDSet

Remarks

If you want to clear the selection, set SelectionFeatures to Null/Nothing. If you forget to do this, the previous selection will be added to the current selection.

Serialize(IXMLSerializeData)

Serializes an object to XML.

virtual void Serialize(IXMLSerializeData data)

Parameters

data IXMLSerializeData

ShowLabels

Indicates whether the layer should display its dynamic labels.

virtual bool ShowLabels { get; set; }

Returns

bool

Remarks

This only applies to layers where the property HasLabels on IMapLayerInfo2 is TRUE. This means that the layer's labels must be "on" in the original map document.

ShowSelectionBuffer

Indicates whether the selection buffer should be displayed.

virtual bool ShowSelectionBuffer { get; set; }

Returns

bool

Remarks

The selection buffer is based on Euclidian distance. The accuracy of the buffer is dependent on the spatial reference used in the map. An inappropriate spatial reference will result in inaccurate buffer distances. For best results, the map should be in an appropriate spatial reference.

In order to control the amount of information MapServer needs to process for a buffer, a maximum number of records to be buffered can be set. This value is contained in the MaxBufferCount property. The default value for this property is 100. If the number of features to be buffered exceeds MaxBufferCount no features will be buffered. The MaxBufferCount can also be changed by modifying the MaxRecordCount XML tag in the MapServer's configuration file.

[C#]

The following sample code shows how to create a buffer around selected features. It assumes that you already have a valid MapServer and MapDescription object.

IMapServer mapServer;
IMapDescription mapDesc;
// Select all features in layer 0
string strMapName = mapDesc.Name;
int layerID = 0;
IFIDSet FIDs = mapServer.QueryFeatureIDs(strMapName, layerID, null);
// Create buffer around selected feature
ILayerDescription layerDesc = mapDesc.LayerDescriptions.get_Element(layerID);
layerDesc.SelectionFeatures = FIDs;
layerDesc.SelectionBufferDistance = 1; // map units
layerDesc.ShowSelectionBuffer = true;

SourceID

The id of the data source to connect to.

virtual string SourceID { get; set; }

Returns

string

Remarks

SourceID is used for map service interaction with the GPServer. It is a unique job id assigned to a geoprocessing service each time it runs on the server. This property can be used to find out which geoprocessing job has created this layer.

It is important to note that LayerID, SourceID and the index of layers (see MapLayerInfos) in map document are not the same.

Please note that this is currently not implemented for StandaloneTable.

TimeDataCumulative

Draw the data cumulatively from the first instance of time in data as time progresses.

virtual bool TimeDataCumulative { get; set; }

Returns

bool

TimeOffset

Draw time offset to overlay the data on a earlier or later time span.

virtual double TimeOffset { get; set; }

Returns

double

TimeOffsetUnits

Draw time offset units.

virtual esriTimeUnits TimeOffsetUnits { get; set; }

Returns

esriTimeUnits

UseTime

Indicates whether use time for display.

virtual bool UseTime { get; set; }

Returns

bool

Remarks

When UseTime is set to False, the layer or table becomes time unaware and time related operations will ignore any time related settings on this layer or table. For example, when UseTime=False for a layer, ExportMapImage will draw all features from this layer even when IMapTimeDescription's TimeValue is set.

Visible

Indicates whether the layer is visible as defined in the TOC (i.e. marked on).

virtual bool Visible { get; set; }

Returns

bool

Remarks

This property only reflects the layer's on/off state in the TOC. A layer's visibility property may be TRUE and the layer may still not be visible on the map. This occurs when a layer is marked "on" but is not drawn in the map display because its display is dependent on the scale of the map.

Use VisibleLayers on IMapImage to retrieve an array of layers that are both "on" in the TOC and visible in the map display.

You can also use MinScale and MaxScale on IMapLayerInfo2 to see if the layer has any scale dependencies and then use MapScale on IMapImage or ComputeScale on IMapServer2 to determine the map scale. If the map scale falls outside the specified scale range set for the layer, the layer will not display.