Exercise 6: Quick-start guide for configuring the Standard builder to operate from custom queries
Schematic diagrams can be generated from pretty much any data that can be connected to via an ADO or ODBC connection (the data does not need to be inside a geodatabase). The Standard builder is generally used to generate diagrams from GIS features highlighted in a map after a selection or trace operation, but it can also be configured to generate diagrams from either data that is not in a geodatabase or is just pure tabular, nonspatial data. Since this configuration requires you to write SQL queries directly to a data source, you must have experience writing SQL queries and have a thorough understanding of your data and its structure. During this exercise, you are going to learn how to create and configure a schematic diagram template to generate diagrams from tabular, nonspatial data. The data that you will be working with is in the Brazil.gdb tutorial database, which is located in C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Mixed_Data. The configuration of the diagram template is going to be done using the SchematicBuilderSamples schematic dataset created during exercise 1.
The screen shots in this exercise show configuration parameters created during the previous exercises. Those exercises are not a prerequisite for this exercise. You can follow the steps explained in this exercise without having completed the previous exercises.
Exploring the source data that you will be using
The first phase of this configuration is all about understanding the data and connecting to the data so you can then configure queries to use the data.
- Start the ArcCatalog application.
- Navigate to C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Mixed_Data.
-
Double-click the Brazil.gdb entry to open its contents.
In the Contents tab of the Catalog window, you now see three tables prefixed with ISP_. This stands for Inside Plant. The records in these tables describe the internal workings of some gas plants. The gas plants themselves are real features that are part of a geometric network and can be found in the pug_PUG_gas_plants feature class, which is inside the pipelines feature dataset.
-
Double-click the pipelines feature dataset to expose the geometric network feature classes.
- Select the pug_PUG_gas_plants feature class and click the Preview tab.
- At the bottom of the Preview tab, use the Preview drop-down list to choose Table so you can see the data.
-
Use the scrollbar to scroll over so you can see both the NAME and the PLANT_NMBER fields.
Remarque :
You may need to resize the columns so you can see them at the same time.
You only have both PLANT_NUMBER and NAME data for three of the gas plants. The idea here is that you will want to allow an end user in ArcMap to choose to generate a diagram for one of these plants based on its Name (the end user doesn't need to know the plant_number). However, you will see in a minute that to query the records from the ISP_ tables, you have to have the PLANT_NUMBER. So these are both important details from this feature class.
-
Select the ISP_EQUIPMENTS table from the Catalog tree.
This displays as a table on the Preview tab.
-
Scroll over in the Preview tab until you can see both the NUMBER_ and the PLANT_NUMBER columns.
The NUMBER_ column gives you a unique number for each of the records. The PLANT_NUMBER column tells you which gas plant each record lies within. The basic idea that you will follow during configuration is that if a user wants to see the diagram for plant Aracaui (plant_number = 101), then you need to run a query to get all the ISP_EQUIPMENTS records for PLANT_NUMBER 101.
-
Take a quick look at ISP_VALVES by selecting it in the Catalog tree.
This table has basically the same structure, where you find a NUMBER_ and a PLANT_NUMBER column.
-
Now click the ISP_PIPES table in the Catalog tree.
This table is the key to this particular custom query application. This table gives you the connectivity between ISP_EQUIPMENTS records and ISP_VALVES records.
-
Scroll over in the Preview tab until you can see the FROM_NODE_NUM and TO_NODE_NUM columns.
For each row in this table (an individual pipe inside the plant), these columns tell you what they connect to and from based on the values in those columns matching a value from the Number_ column in either the ISP_EQUIPMENTS or ISP_VALVES table.
Connecting to an external database
-
Edit the SchematicBuilderSamples schematic dataset stored in the C:\ArcGIS\ArcTutor\Schematics\TutorialSchematicDB geodatabase by browsing to this database using ArcCatalog, right-clicking the dataset, and choosing the Edit menu option .
Remarque :
The screen shots in this exercise show configuration parameters created during the previous exercises. Those exercises are not a prerequisite for this exercise. You can follow the steps explained in this exercise without having completed the previous exercises.
-
Before going further, you need to create a new Data Source that points to the data reviewed in the Brazil.gdb database. The rest of the configuration will need to make use of this data source:
-
Right-click the Data Sources folder in the Schematic Dataset Editor tree and click New Data Source.
A Properties tab now shows information for the new data source. Keep the default name, and since Brazil.gdb is a file geodatabase, the Type is also correct.
-
Click the Browse for ESRI File Geodatabase button at the end of the GDB File text box.
This opens the ESRI File GDB Connection dialog box.
- Browse to and select the brazil.gdb database located in C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Mixed_Data.
- Click the Select button to close the dialog box.
- Click OK on the Properties tab.
You have now successfully made a connection to the other database.
-
Right-click the Data Sources folder in the Schematic Dataset Editor tree and click New Data Source.
Creating a schematic diagram template based on the Standard builder
The second phase consists of creating the schematic diagram template that will be used to generate diagrams from the tabular data.
-
Right-click the SchematicBuilderSamples entry in the Dataset Editor tree and click the New Schematic Diagram Template menu item.
A Properties tab for the new schematic diagram template automatically displays on the right side of the Editor Window.
- Type DiagramsFromCustomQueries in the Name box.
- Choose Standard Builder in the Schematic Builder section.
-
Click OK.
An entry for the DiagramsFromCustomQueries diagram template now displays in the Dataset Editor tree. Three new tabs (Associations, Layouts, and Rules) display on the right side of the Editor Window.
- Click the DiagramsFromCustomQueries entry in the Schematic Dataset Editor tree to start working on its configuration.
-
Click the Query/Identifier Editor button located in the Query area on the Properties tab.
This opens the Query/Identifier Editor dialog box:
Remarque :On your own projects, if you are working with data that does not need to be filtered, you would not need to do any more configuration for the diagram template and would just start working on the schematic feature classes. Since you want to filter, you need to set the filter up at the diagram template level.
-
Use the Data Source drop-down list to select the NewDataSource entry that was created in the Connecting to an external database section above.
The tables list now fills in with all the tables found in that data source. You want to get a list of the gas plant names and their numbers now.
-
Scroll over in the tables list until you find the entry for pug_PUG_gas_plants. Double-click this entry.
The system has added a query to the query section. It is returning all columns from that table. You want the end user in ArcMap to be given a list of just the names. So for the identifier section, that is what you will specify.
-
In the Fields list at the bottom of the form, double-click the NAME entry, which will add it to the Identifier list.
- Click OK to close the form.
-
Add an attribute to get the plant number. (This will be used to filter the data when you write the queries for your schematic feature classes.) Right-click the DiagramsFromCustomQueries entry in the Dataset Editor tree and choose New Attribute from the pop-up menu.
This opens the New Attribute properties tab on the right side of the editor. There are many types of attributes available in Schematics. In this case, you are just getting a field from the query you already wrote. Field happens to be the default Type.
- Type PlantNum in the Name field.
- Scroll over in the Fields list until you see PLANT_NUMBER. Double-click this entry to add it to the Identifier list.
-
Click OK to finish this attribute definition.
- Click Save on the Schematic Dataset Editor toolbar.
Creating the Schematic Feature Classes
-
Right-click the DiagramsFromCustomQueries diagram template entry in the Dataset Editor tree and click the New Schematic Feature Class menu item.
A Properties tab for the new schematic feature class automatically displays on the right side of the Editor Window.
- Type ISP_Equipments in the Name field.
-
Click OK.
-
Right-click the DiagramsFromCustomQueries diagram template entry in the Dataset Editor tree and click the New Schematic Feature Class menu item.
A Properties tab for the new schematic feature class automatically displays on the right side of the Editor Window.
- Type ISP_Valves in the Name field.
-
Click OK.
-
Right-click the DiagramsFromCustomQueries diagram template entry in the Dataset Editor tree and click the New Schematic Feature Class menu item.
A Properties tab for the new schematic feature class automatically displays on the right side of the Editor Window.
- Type ISP_Pipes in the Name field.
-
Use the Type drop-down list and select Link.
The pipe records are the links between the valves and equipment.
-
Click OK.
- Click Save on the Schematic Dataset Editor toolbar.
Configuring the ISP_Equipments Schematic Feature Classes
-
Use the mouse to click the ISP_Equipments entry in the Schematic Dataset Editor tree.
This opens the Properties tab for this schematic feature class.
-
Choose Query On Generate/Update from the Evaluation Mode drop-down list on the Query section.
The Query/Identifier Editor button becomes available:
-
Click the Query/Identifier Editor button .
This opens the Query/Identifier Editor dialog box.
-
Use the Data Source drop-down list to pick the NewDataSource entry from the list.
-
Double-click the ISP_EQUIPMENTS entry in the Tables list.
This automatically adds a query to the Query section.
-
This time, however, you need to change the query so it properly filters out the records based on the gas plant's number that the user will pick when generating diagrams. Modify the query by adding the following text to the end of what was automatically done for you: where plant_number = ?
Once you have typed this in, a new Parameters section automatically opens. This allows you to tell the system which attribute will be passed into the query in place of the ?. Since your configuration only had one attribute, it is already selected.
- You do need to change one thing, though. By default, the Is Text check box is checked. In your case though, this data is a number, so you need to change this check box. Click the check box for Is Text so that it becomes unchecked.
-
You can test your query at this point if you want to. Type in a valid PlantNum in the Test Value field (101, for example, is the Aracaiu gas plant), then click the Show Results button.
If the query evaluated correctly, you should see only records that have that value.
-
Double-click the NUMBER_ entry in the Fields list to add it to the Identifier list.
Every schematic feature on a diagram must be uniquely identified. In this example, you know that the NUMBER_ field is unique across all tables used to retrieve data. In your own examples, you will need to make sure you have unique values, and in some cases, you may need to do some creative things to ensure they are unique.
- Click OK to finish this definition.
Configuring the ISP_Valves Schematic Feature Classes
-
Use the mouse to click the ISP_Valves entry in the Dataset Editor tree.
This opens the Properties tab for this schematic feature class.
- Choose Query On Generate/Update from the Evaluation Mode drop-down list on the Query section.
-
Click the Query/Identifier Editor button on the Properties tab.
This opens the Query/Identifier Editor dialog box.
- Use the Data Source drop-down list to pick the NewDataSource entry from the list.
-
Double-click the ISP_VALVES entry in the Tables list.
This automatically adds a query to the Query section.
-
You need to change the query so it properly filters out the records based on the gas plant's number that the user will pick when generating diagrams. Modify the query by adding the following text to the end of what was automatically done for you: where plant_number = ?
Once you have typed this in, a new Parameters section will automatically open. This allows you to tell the system which attribute will be passed into the query in place of the ?. Since your configuration only had one attribute, it is already selected.
- You do need to change one thing, though. By default, the Is Text check box is checked. In your case though, this data is a number, so you need to change this check box. Click the check box for Is Text so that it becomes unchecked.
-
You can test your query at this point if you want to. Type in a valid PlantNum in the Test Value field (101, for example, is the Aracaiu gas plant), then click the Show Results button.
If the query evaluated correctly, you should see only records that have that value.
-
Double-click the NUMBER_ entry in the Fields list to add it to the Identifier list.
Every schematic feature on a diagram must be uniquely identified. In this example, you know that the NUMBER_ field is unique across all tables used to retrieve data. In your own examples, you will need to make sure you have unique values, and in some cases, may need to do some creative things to ensure they are unique.
-
Click OK to finish this definition.
The Query/Identifier dialog box closes, and the Properties tab for the ISP_Valves schematic feature class displays as follows:
Configuring the ISP_Pipes Schematic Feature Classes
For the last feature class configuration section, you do almost exactly the same except for the names of the feature classes and the names of the tables being queried. This time, the configuration for the queries will still be the same, but you will have to do some further work to define some attributes to tell the system which fields are used for connectivity between nodes.
-
Use the mouse to click the ISP_Pipes entry in the Dataset Editor tree.
This will open the Properties tab for this schematic feature class.
- Choose Query On Generate/Update from the Evaluation Mode drop-down list on the Query section.
-
Click the Query/Identifier Editor button on the Properties tab.
This will open the Query/Identifier Editor dialog box.
- Use the Data Source drop-down list to pick the NewDataSource entry from the list.
-
Double-click the ISP_PIPES entry in the Tables list.
This automatically adds a query to the Query section.
-
You need to change the query so it properly filters out the records based on the gas plant's number that the user will pick when generating diagrams. Modify the query by adding the following text to the end of what was automatically done for you: where plant_number = ?
Once you have typed this in, a new Parameters section will automatically open. This allows you to tell the system which attribute will be passed into the query in place of the ?. Since your configuration only had one attribute, it is already selected.
- You do need to change one thing, though. By default, the Is Text check box is checked. In your case though, this data is a number, so you need to change this check box. Click the check box for Is Text so that it becomes unchecked.
-
You can test your query at this point if you want to. Type in a valid PlantNum in the Test Value field (101, for example, is the Aracaiu gas plant), then click the Show Results button.
If the query evaluated correctly, you should see only records that have that value.
-
Double-click the OBJECTID entry in the Fields list to add it to the Identifier list.
Every schematic feature on a diagram must be uniquely identified. In this example, you know that the OBJECTID field is unique across all tables used to retrieve data. In your own examples, you will need to make sure you have unique values, and in some cases, may need to do some creative things to ensure they are unique.
-
Click OK to finish this part of the ISP_Pipes definition.
The Query/Identifier dialog box closes, and the Properties tab for the ISP_Pipes schematic feature class displays as follows:
-
Right-click the ISP_Pipes entry in the Schematic Dataset Editor tree and choose New Attribute.
This opens a Properties tab for the new attribute.
-
Use the Name drop-down list to pick OriginNode from the list of predefined attributes.
This list of attributes is predefined by the system. They all impact certain functionality in the system. OriginNode is an attribute that will tell a link which node to connect to as a starting (origin) point.
- Double-click the FROM_NODE_NUM entry in the Fields list to add it to the Identifier list—that is, the field in the ISP_PIPES table that holds the starting point connectivity information for each pipe.
-
Click OK to finish this attribute configuration.
-
Right-click the ISP_Pipes entry in the Dataset Editor tree and choose New Attribute.
This opens a Properties tab for the new attribute.
-
Use the Name drop-down list to pick ExtremityNode from the list of predefined attributes.
ExtremityNode is an attribute that will tell a link which node to connect to as an ending (extremity) point.
- Double-click the TO_NODE_NUM entry in the Fields list to add it to the Identifier list—that is, the field in the ISP_PIPES table that holds the ending point connectivity information for each pipe.
-
Click OK to finish this attribute configuration.
- Click the Save button on the editor toolbar.
- Close the Schematic Dataset Editor.
Generating a custom query schematic diagram
In this section, you are going to generate your first schematic diagram based on the newly created DiagramsFromCustomQueries diagram template.
- Start ArcMap with a blank map document.
-
Click the Generate New Schematic Diagram button on the Schematic toolbar.
The New Schematic Diagram dialog box opens.
- Click the browse button on the right of the Schematic Dataset or Folder field to open the Select schematic dataset or schematic folder dialog box.
- Browse to and select the TutorialSchematicDB geodatabase that was created in C:\ArcGIS\ArcTutor\Schematics during exercise 1.
-
Double-click this geodatabase and select the SchematicBuilderSamples schematic dataset.
- Click the Add button.
-
Make sure the DiagramsFromCustomQueries diagram template is the one selected in the Schematic Diagram Template drop-down list.
ARACAIU is already selected in the Schematic Diagram Name section because it is first in the alphabetical list.
-
Click the Schematic Diagram Name drop-down arrow to see that there is a list of all the gas plant names that came from the pug_PUG_gas_plants table.
Remember that you wanted the user to see the friendly name and not the number. That is where the PlantNum attribute came into the configuration.
-
Make sure that ARACAIU is still selected.
-
Click OK to generate the diagram.
Since there were no coordinates on these tabular records, Schematics has automatically placed all the nodes at the 0,0 coordinate. If you had x and y information in the data, then you could create predefined attributes for each of the Node schematic feature classes so that the initial position of the diagram would be using the x and y from the data instead of being placed at 0,0. In either case, the user can now start an editing session and apply algorithms, and so on, to the diagram.