Defining RepresentationClass
RepresentationClass is a feature class enabled with cartographic representation capabilities that are useful for symbolizing features in the geodatabase and editing the appearance of individual features on your maps. A representation class is also called a feature class representation. The representation information is stored in the geodatabase and can be overridden for individual features in places where graphic conflict arises or when fine-tuning of symbology is required.
The workspace extension for managing representation classes is called RepresentationWorkspaceExtension. In the IRepresentationWorkspaceExtension interface, the method CreateRepresentationClass can be used to create new representation classes.
Creating feature class representations on a feature class results in the addition of two new fields: RuleID (fieldtype long to store RepresentationRule ID value) and Override (fieldtype binary large object [BLOB] to store feature-specific override information). A reference to a new or existing RepresentationRules object, which is a collection of rules used to represent features, must be present to create a new representation class. These representation rules are managed at the metadata level. See the following code examples:
[C#]
public IRepresentationWorkspaceExtension GetRepWSExt(IWorkspace pWorkspace)
{
IWorkspaceExtensionManager pExtManager;
IUID pUID;
pExtManager = pWorkspace;
pUID = new UID();
pUID.Value = "{FD05270A-8E0B-4823-9DEE-F149347C32B6}";
GetRepWSExt = pExtManager.FindExtension(pUID);
}
public IRepresentationClass CreateRepClass(IFeatureClass pFClass)
{
IDataset pDataset;
IWorkspace pWorkspace;
IRepresentationWorkspaceExtension pRepWSExt;
IRepresentationRules pRules;
pDataset = pFClass;
pWorkspace = pDataset.Workspace;
pRepWSExt = GetRepWSExt(pWorkspace);
pRules = new RepresentationRules();
CreateRepClass = pRepWSExt.CreateRepresentationClass(pFClass, pFClass.AliasName
+ "_Rep", "My_RuleID", "My_Override", false, pRules, null);
}
[VB.NET]
Public Function GetRepWSExt(ByVal pWorkspace As IWorkspace) As IRepresentationWorkspaceExtension
Dim pExtManager As IWorkspaceExtensionManager
Dim pUID As IUID
pExtManager = pWorkspace
pUID = New UID
pUID.Value = "{FD05270A-8E0B-4823-9DEE-F149347C32B6}"
GetRepWSExt = pExtManager.FindExtension(pUID)
End Function
Public Function CreateRepClass(ByVal pFClass As IFeatureClass) As IRepresentationClass
Dim pDataset As IDataset
Dim pWorkspace As IWorkspace
Dim pRepWSExt As IRepresentationWorkspaceExtension
Dim pRules As IRepresentationRules
pDataset = pFClass
pWorkspace = pDataset.Workspace
pRepWSExt = GetRepWSExt(pWorkspace) 'Uses function previously described.
pRules = New RepresentationRules
CreateRepClass = pRepWSExt.CreateRepresentationClass(pFClass, pFClass.AliasName + "_Rep", "My_RuleID", "My_Override", False, pRules, Nothing)
End Function
A feature class can have multiple representation classes associated with it, giving you the ability to produce multiple maps from a single geodatabase. The representation class, however, is always associated with a single feature class to which it belongs.
Representation rules and basic symbols
Every representation class consists of a set of representation rules that govern the symbology for its feature representations. A regular RepresentationRule consists of multiple layers of basic symbols. These symbols are BasicMarkerSymbol, BasicLineSymbol, and BasicFillSymbol for drawing markers, line strokes, and polygon fill patterns, respectively.
More complex symbology can be achieved by including one or more geometric effects in a representation rule. A GeometricEffect is a dynamic process that alters geometry at draw time. It can also change geometry type. For example, point, line, or polygon geometries can be processed through a GeometricEffectBuffer to produce buffer polygons around them.
Use the IRepresentationRuleInit interface to convert a standard ArcGIS symbol to a basic symbol that can be used by a representation rule object to represent features in a representation class.
Marker placements
BasicMarkerSymbol is used to draw marker symbols and has marker, size, and angle as its graphic attributes. These properties can be managed using the IGraphicAttributes interface. The attributes are listed in the esriGraphicAttribute enumeration and are prefixed with esriGAMarker, such as esriGAMarkerSize. All BasicMarkerSymbol classes implement the IBasicMarkerSymbol interface, which has a single property, MarkerPlacement, on it.
A MarkerPlacement class is a marker placement style for placing markers. You can place either single or multiple markers depending on what MarkerPlacement you choose. For example, MarkerPlacementOnPoint places a single marker over a point, while MarkerPlacementAlongLine places multiple markers along a line.
The default marker placement for any basic marker symbol is OnPoint. Use the IMarkerPlacement interface to create and manipulate the properties of placement styles. The esriMarkerPlacementAttributes enumeration lists graphic attributes for all marker placements where each attribute is prefixed with esriGA(name)(attribute), such as esriGAInsidePolygonGridAngle, where InsidePolygon is the marker placement style and GridAngle is its graphic attribute. See the following code example:
[C#]
IBasicMarkerSymbol pBasMarker;
IGraphicAttributes pGraphicAttributes;
pBasMarker = new BasicMarkerSymbolClass();
pGraphicAttributes = pBasMarker;
pGraphicAttributes.Value(1) = CreateMarker();
pGraphicAttributes.Value(2) = 5;
pGraphicAttributes.Value(3) = 30;
[VB.NET]
Dim pBasMarker As IBasicMarkerSymbol
Dim pGraphicAttributes As IGraphicAttributes
pBasMarker = New BasicMarkerSymbolClass
pGraphicAttributes = pBasMarker
'Assign attributes.
pGraphicAttributes.Value(1) = CreateMarker() 'Define marker symbol.
pGraphicAttributes.Value(2) = 5 'Define size of marker.
pGraphicAttributes.Value(3) = 30 'Define angle of marker.
[C#]
public IRepresentationMarker CreateMarker()
{
IRepresentationMarker pMarker;
IGeometry pGeom;
ISegmentCollection pSegCol;
IEnvelope pEnvelope;
IFillPattern pFillPattern;
IRgbColor pColor;
IGraphicAttributes pGA;
IRepresentationRule pRR;
IBasicFillSymbol pBasicFill;
IRepresentationGraphics pGraphics;
pMarker = new RepresentationMarker();
pGraphics = pMarker;
pGeom = new Polygon();
pSegCol = pGeom;
pEnvelope = new Envelope();
pEnvelope.PutCoords( - 0.5, - 0.5, 0.5, 0.5);
pSegCol.SetRectangle pEnvelope;
pFillPattern = new SolidColorPattern();
pColor = new RgbColor();
pColor.Red = 0;
pColor.Green = 0;
pColor.Blue = 250;
pGA = pFillPattern;
pGA.Value(0) = pColor; //Define color.
pBasicFill = new BasicFillSymbol();
pBasicFill.FillPattern = pFillPattern;
pRR = new RepresentationRule();
pRR.InsertLayer(0, pBasicFill);
pGraphics.Add pGeom, pRR; //Add graphics to marker.
return pMarker;
}
[VB.NET]
Public Function CreateMarker() As IRepresentationMarker
Dim pMarker As IRepresentationMarker
Dim pGeom As IGeometry
Dim pSegCol As ISegmentCollection
Dim pEnvelope As IEnvelope
Dim pFillPattern As IFillPattern
Dim pColor As IRgbColor
Dim pGA As IGraphicAttributes
Dim pRR As IRepresentationRule
Dim pBasicFill As IBasicFillSymbol
Dim pGraphics As IRepresentationGraphics
pMarker = New RepresentationMarker
pGraphics = pMarker
pGeom = New Polygon
pSegCol = pGeom
pEnvelope = New Envelope
pEnvelope.PutCoords( -0.5, -0.5, 0.5, 0.5)
Dim pEnvelope As pSegCol.SetRectangle
pFillPattern = New SolidColorPattern
pColor = New RgbColor
pColor.Red = 0
pColor.Green = 0
pColor.Blue = 250
pGA = pFillPattern
pGA.Value(0) = pColor
pBasicFill = New BasicFillSymbol
pBasicFill.FillPattern = pFillPattern
pRR = New RepresentationRule
pRR.InsertLayer(0, pBasicFill)
Dim pGeom As pGraphics.Add
Dim pRR As pGraphics.Add
Return pMarker
End Function
BasicLineSymbol is used to draw stroke symbols. All BasicLineSymbol classes implement the IBasicLineSymbol interface, which has a single property, Stroke. LineStroke has width, caps, joins, and color for its graphic attributes. These attributes can be manipulated using the IGraphicAttributes interface. Use the ILineStroke interface to create and manipulate the properties of a new stroke symbol such as esriGraphicAttributeesriGAStroke.
BasicFillSymbol is used to draw fill symbols. All BasicFillSymbol classes implement the IBasicFillSymbol interface, which has a single property, FillPattern. There are three types of fill patterns: GradientPattern, LinePattern, and SolidColorPattern.
Graphic attributes of fill pattern classes
The following table shows the graphic attributes of each of these fill pattern classes:
Fill pattern class
|
Graphic attributes
|
GradientPattern
|
Algorithm
Angle
Color 1
Color 2
Intervals
Style
Percentage
|
LinePattern
|
Angle
Color
Offset
Step
Width
|
SolidColorPattern
|
Color
|
These attributes can be manipulated using the IGraphicAttributes interface. The attributes are listed in the esriGraphicAttribute enumeration and are prefixed with esriGA (fill pattern type), for example, esriGASolidColorPatternColor. Use the IFillPattern interface to create and manipulate the properties of a new fill pattern symbol.
GraphicAttributes are attributes used to define graphic properties for all MarkerPlacements, GeometricEffects, BasicMarkerSymbol, LineStroke, GradientPattern, LinePattern, and SolidColorPattern objects. A RepresentationClass also has a single graphic attribute for controlling its visibility property. All graphic attributes are enumerated into esriGraphicAttributes, esriGeometricEffectAttributes, and esriMarkerPlacementAttributes enumerations.
You must implement IMarkerPlacement, IGraphicAttributes, and IPersistVariant interfaces to create custom MarkerPlacements and IGeometricEffect, IGraphicAttributes, and IPersistVariant interfaces to create custom GeometricEffects.
Feature representations and overrides
Each feature in a feature class representation will be associated with a feature representation that is a cartographic depiction of the geographic feature. Use the GetRepresentation method on the IRepresentationClass interface to reference feature representations with respect to various map contexts.
Representations can be displayed using information from any of the following options:
- RepresentationRule stored in the RuleID field.
- RepresentationRule along with override information stored in the Override field.
- RepresentationGraphics, also known as free representation. The value of RuleID is –1 and the entire graphic is written into the Override field. So a free representation can be considered an override.
Use the IRepresentation interface to manage the properties of a feature representation such as creating or modifying its shape overrides. Use the IOverride interface to manage the attribute overrides present for a feature representation. This interface cannot be used to set new attribute overrides. To set new attribute overrides, use the IRepresentation.Value property with the correct set of GraphicAttributes and the index of the attribute you want to alter.
Creating feature class representations
Creating feature class representations on a feature class results in the addition of two new fields: RuleID (fieldtype long to store RepresentationRule ID value) and Override (fieldtype BLOB to store feature-specific override information). A reference to a new or existing RepresentationRules object, which is a collection of rules used to represent features, must be present to create a new representation class. These representation rules are managed at the metadata level.
Creating a new feature class or modifying representation rules of an existing representation class requires an exclusive schema lock. As a result, for ArcSDE databases, only the owner of the database can create new feature class representations or modify rules of existing representation classes.
Deleting a representation class results in the deletion of the RuleID and Override fields except when the feature class is in a DB2 ArcSDE geodatabase.
See Also:
Sample: Create a custom marker placement for placing markers around a pointDevelopment licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |