Rounding values for the PBA string
When decimal values are stored in a property that you wish to use in a PBA string, but want to limit the number of digits after the decimal, you need to do the following:
- Define the property ( or properties to be used in the PBA string. For example
- For annotation a section of storm sewer, you may want to give the size and material of the pipe. Therefore the PBA string may be : [DIAMETER]" - [MATERIAL]. In this situation I am assuming that the possible values ( via a domain) have 2 digits after the decimal point. Which would give you a PBA string of : 12.00" - RCP
- Since most of the storm sewer pipe sections come in even inches, we may want to limit the number of digits after the decimal to 0. To do this we need to change the PBA string definition to the following : [System.Math.Round([DIAMETER],0)]" - [MATERIAL] in V8 XM or to [XFM.Round([DIAMETER],0)]" - [MATERIAL] in V8i. Note that for the cexpression to function correctly, we need to put the rounding function in square brackets. The second parameter of the Round function is the number of digits after the decimal. This value can be anything from 0 to 12. The PBA string will now display as : 12" - RCP.
- Please note, that this does not round the value stored in the non-graphical property of the feature. It just rounds the value used for the PBA string.
- Also note, this method works in the labeling functionality, in the Map Manager, introduced in Bentley Map v8i SELECTseries 1 .
Creating multiple lines of text for a PBA string
Sometimes, you want to create a PBA string that has multiple lines of text in it. To do this you need to insert a special string of characters. The cexpression parser will recognize this set of characters as a new line designator and insert such into you text string. The value you need to insert into the PBA string is "\010". Therefore if you originally created a PBA string of :
[DIAMETER]" - [MATERIAL]
and want to add the pipe slope on a separate line, then you would do the following:
[DIAMETER]" - [MATERIAL]\010Slope = [SLOPE]
You can place as many of these into a text string as you want, thus creating more than 2 lines of text in your PBA string.
Using VBScript to determine PBA strings
There are times when using a VBA script is more appropiate than using a PBA expression. Remember, when selecting a new PBA entry in the symbology node, you can insert one of the following:
- Expression (typically the one used)
- SQL Query
- Origin X
- Origin Y
- VBScript
- XSLT
- SQL
In this section we will deal with the VBScript. There are a couple of things to remember in using a VBScript with the XFM engine.
- The return value from the function must be a character string.
- Any properties from the feature class that you want ot use in the function needs to be passed as parameters to the function.
- The properties passed to the function need to ben enclosed in square brackets ( [property1]).
So, lets look at a probably situation.
The customer wants to format the PBA string usign 4 different properties. These properties can be blank or not, we have to test for that also.
NOITE:
As of the writing of this, using version 08.11.07.113 of Bentley Map, the string length test ( if Len(string1) > 0 then ....) can not be used to test a null or blank value. This is becasue the parameter substitution that occurs when pre-processing the VBScript will insert the name of the parameter into the parameter string if it is null or blank. A TR will be filed for this.
Here is the VBScript.
Function formatAddress ([N_Value],[C_Value],[R_Value],[U_Value])
tempAddress = ""
If Not IsNull([N_Value]) Then
tempAddress = [N_Value]
End If
' If we have a corner value add the -C and that is all Remember if the vlaue is blank, then the property name is in the string.
If StrComp ([C_Value],"C_Value", vbTextCompare) <> 0 Then
tempAddress = tempAddress & "-C"
ElseIf StrComp ([R_Value],"R_Value", vbTextCompare) <> 0 Then
tempAddress = tempAddress & "-" & Trim([R_Value])
ElseIf StrComp ([U_Value], "U_Value", vbTextCompare) <> 0 Then
tempAddress = tempAddress & "-" & Trim([U_Value])
End If
formatAddress = tempAddress
End Function
So if there is a C_Value the string would come out of the function something like :
1313 Mockingbird Lane-C
If there is no C_Value, and if there is a R_Value, then the string would look like:
1313 Mockingbird Lane-1R
else if there is no C_Value or R_)Value and has a U_Value thent eh stirng would look like:
1313 Mockingbird Lane-123
If only the N_Value is not blank then the output stirng will look like :
1313 Mockingbird Lane
There are may other things that can be done with VBA scripts that can not be acclomplished in more simple PBA expressions. Also VBScript is well documented online at The Microsoft VBA Script Users Guide web site.
Generating the workspace from the command line
You can regenerate the workspace folders and XML files from the command line. This is done through the Geospatial Administrator command line interface. To do this you will need to identify the schema XML file and then tell the GSA to export the appropriate objects from the schema file.
The sample command line to do this is :
C:\Program Files\Bentley\Map\bin>geospatialadmincl -l=c:\gsa\gsa_intro.xml -xa
The -l parameter designates the input XML schema file. The -xa parameter tells the GSA to export all metadata. The order of the parameters is important. If you put the -xa parameter first, the GSA will run the export routine, but it will not have a schema file defined yet, so nothing will happen.
Generating a domain list from the database
There are several different ways to define a domain list in the GSA. One of the ways is to use existing values from a database table. This is a excellent option if,
- The values in the existing table represent all the possible values that will be needed.
- The values in the existing table are valid for the proposed list.
To add the SQL lookup to a property:
- You must have defined a database connection for the current GSA schema.
- Once this is done, then when you create a new property for a feature. You need to make sure the new property uses the combo box form type. ( Properties -> Add -> Combobox Property). Note, this does not have to be a database property to use the SQL domain list.
- Now in the form that opens, to create the property, make sure you set the radio button to the Embedded SQL list for the domain list specification. Also please use only one column, set the initial value to blank and set the name of the property.
- The property for the feature will be created. Now expand that property object and see that there is a domain list item under the property object.
- Select the domain list object and you will have a grid where you can define the SQL lookup for the domain list. There are 3 key parts to the SQL statement you are going to create to make this work correctly.
- First, the SQL statement must use the 'distinct' keyword on the field you want to extract data from. This way you get only one representation of each different value from that field.
- Second, you need to give an alias name for the return value. This allows us to reference it correctly ( and easily) in the property object definition.
- Last, you need to finish out the SQL statement with a 'ORDER BY' clause. This way the data will be put into the list in an increasing order.
Let's look at a sample SQL statement
select DISTINCT(material) AS MAT from water_pipes ORDER BY material
This statement should now be placed in the SQL column in the domain list specification for the property we are editing. The next thing you might want to do is check the cached column for this SQL statement. This is useful if the distinct values do not change over time. It is also useful for speeding up the creation of the domain list form item each time it is displayed. If this cache is not checked on, then the SQL statement is reposted back to the database each time the domain list form item is displayed.
One last change to be made to the property object definition. Above we added the alias to the SQL statement ( AS MAT ). This needs to be referenced in the property object definition. Click on the property tree item and in the right pane there will be 2 fields one called 'Value Col Name' and the other called 'Edit Col Name'. In each of these place the alias name from the SQL statement. In our example above, this would be the value of 'MAT'.
You are now finished setting this up. All that is left is to insert or update the placement metadata for this feature and you will be ready to use the domain list lookup from the database.
Recommended GSA workflow
When you are creating a new geospatial schema from scratch, you need to plan out what you are going to do. A suggested workflow should be:
Please follow the old axiom, "Save early, Save often", when running a GSA session. This will, in case of a power outage or system crash, save you a lot of time.
- Break your features down into the 3 basic spatial geometry types (point, line and polygon). This will assist in the definition of the features and will also allow you to prepare the feature definitions in case you need to exchange information with other Geospatial products (i.e. ESRI).
- Next you need to define the categories these features will go into. In most implementations, you will have features in different groupings, or categories. The purpose of doing this is to group like features together, so navigation and usage of the various geospatial applications are more intuitive.
- Create or define the domains you are going to use for the different features. This can be lists of values or from a database query (if from a database query, please define the database connection also).
- Create the shell definition for each feature, in the "All Users" node (If you do this in the workspace node, then only that workspace will be able to see the features). This is the basic outline of the feature (no attributes, PBS, PBA, sub-features, etc. yet). This is where you define the feature name, geometry type and category is chosen (this is why we created the categories in step 2, we will need them here). Also notice that you can not set up a feature name with a space in it. The space character is a special character in a XML file.
- Now navigate to the Properties node under the feature name and add properties. This is not a required step, if the feature does not have any properties, then you do not need to do this. If you do not define properties for the feature, then you will not be able to create PBS or PBA definitions for the feature.
- Now edit the symbology properties for the feature. Notice that the list of symbology properties varies by the feature geometry type you chose when creating the feature. Point geometry (text or cell) includes those symbology properties you would expect with text (text style and PBA) or cell (scale, angle, type, name, library). Linear and Polygon geometry contain the same types of properties. Also notice that no matter what the geometry type, you get some basic symbology properties (level, weight, color, etc). This is a good place to add your PBS settings.
- You are real close to finishing a basic schema. Repeat steps 4-6 for each feature you want to create.
- Now for each feature created add the placement metadata (highlight the feature, right click, and select Add ...... Placement metadata).
- Now go down into the User interface and add the command manager items (this is where you can really diverge the definition. If you created different workspaces, one for editing and one for reviewing, then you probably need to do this in the workspace node and not in the "ALL Users" node. This should be a separate topic since there are different routes this can take).
- Now create the workspace. This will allow you to store the definitions, resources, etc. needed to run this schema in any of the Geospatial products that use the schema.
- Now export your workspace.
- To test the workspace, select the workspace node and click on the Run tool. If you are not satisfied with the results, go back and redefine and retest.
Setting PBA annotation for Point-Text features
<insert video here>
Other References
Links