On this page
Connectivity Rules allow you to define how features can be spatially connected to one another. For example, you may specify that railway stations must be connected to railway lines. Furthermore, you can define whether features must be connected via other features. For example, for a road network you may want to set up a rule whereby roads can only connect to other roads via junctions.
Any error resulting from invalid connectivity in the current visible Map Extent, is displayed within the Connectivity Panel and is also hinted on the map through red error graphics. Editors can pan to these errors and attempt to resolve the issues shown.

This type of behaviour is configured inside the application builder using Connection rules and Junction management.
Connection rules
A connection rule is used to define what types of connections between line and/or point features are valid when editing data inside of Sweet.
You can define which features are allowed to connect and where about on the connecting features this connection can occur, for example only at either end of a line, or only at midpoints. It is also possible to specify that a connection always goes via another feature.
Cardinality
Cardinality allows you to define how many connections are valid. For example you might want to say a minimum of one road must be connected to another road with a maximum of five connections.
Custom scripted cardinality rules can be used to tailor this behaviour further, allowing the attributes of the connecting features to also be taken into account. For example water mains pipes may have a Pressure attribute, and a scripted cardinality rule might prevent the sum of pressures going into a connection point from being allowed to exceed a specific limit.
Setting a maximum cardinality of zero means that the features input into the rule can never be connected.

Junction management
Junction management is used to add logic that automatically inserts and/or removes junctions from the map as connectivity changes.
For example when connecting two road line features, junction management can be configured to automatically add a junction feature where these line features connect. An additional option can also then automatically delete this junction if one of these two road sections are deleted and the junction is therefore orphaned.

Adding a connectivity rule

- Click on Data Rules Editor to switch to the rules view.
- In the Data Rules menu click Connectivity.
- Click on the Connection rules or Junction management tab and then use the button to add a new rule.
Configuring a connection rule
When you have added a connection rule you can then define how features are allowed to connect together.
In the following configuration example there is a rule which states that bus stops must connect to roads anywhere along the line. The rule will mean that any bus stops not placed on the road network will be flagged as being invalid.
General configuration section

- Select a Name for your connectivity rule.
- Specify the Cardinality Constraints for the rule. Input a minimum and/or maximum number of allowed connections, or configure an additional scripted cardinality check.
- Specify whether to Allow other types of connections – it is possible to set it so that any other type of connection between the features in the rule is invalid. Also specify whether the Source and destination feature can be the same feature.
- Set a Display Message that will appear in the Connectivity Panel when a feature breaks this connectivity rule. This can be used to help inform an editor on how to resolve the connectivity violation.
- Specify whether the rule applies in reverse.
- Make certain Fixing Options available to your editor users for when the connectivity rule is broken and a feature appears inside the Connectivity Panel.
Connecting features configuration section
In this section you select the features which will take part in the rule.
Unless the option to apply the rule in reverse is switched to yes, the connectivity rule applies to placement and connection of the Source Feature to other features on the map. This means that in the below example a Bus Stop must be connected to a road segment, but a road segment doesn’t have to have a bus stop connected.

- As the Source, choose the layer for the connection to start with.
- Optionally select whether this connection is to be via another feature.
- As the Destination, choose the feature to connect to.
For Line features you can also set what type of connection is valid:
- Start
- End
- Either end
- Anywhere
- Only Midpoints
Configuring a junction management rule
When you have added a junction management rule you can then define behaviour to aid with the automatic creation of junctions between connecting features.

- Select a Name for your connectivity rule.
- Choose whether to automatically Insert missing junctions if none is present when a new connection is made. It is also possible to Remove orphaned junctions created when features are deleted or moved meaning the connection is no longer present.
- Specify the Source and Destination layer for which the junction management rule applies. This can be the same type of feature. Specify the Junction layer.
Rules which are not valid are automatically removed and will not be saved. A junction management rule must include a Source, Junction and Destination layer. Also, if Insert missing junctions is switched on, then a feature template must be selected.
Advanced: SQL filters
In Sweet for ArcGIS you can specify SQL filters on the data to determine what subset of features connect to what subset of features. For example, you can have a road feature service that has a field that defines its classification. You can then set a rule which only applies to roads with a certain classification – motorways could only connect with a slip road, but not to a minor road directly.

Advanced: Additional cardinality checks
Configure an additional scripted cardinality check to run against the connecting features. The script must return true
or false
.
Example – electric voltage check
/** Returns whether the connection is valid, based on the sum of the
* destination features voltage.
*/
var totalvolts = 0;
for (var f in $connection.end) {
totalvolts += $connection.end[f].graphic.voltage;
}
if (totalvolts >= 100) {
// Connection is invalid
return false;
}
// Connection is valid
return true;