Types of Named Resources / Named Tables |
Named table resources can point to a generic XY table in a JDBC datasource. This is an example of a named table definition for a database table with X/Y geometry columns. This uses the DBDataSourceMetadata element to specify the X and Y geometry columns defined in the database table. The X/Y database table is not expected to have a geometry column.
In this example, the database connection definition to a X/Y table in Oracle is defined using the following tokens. The connection could also be defined as a named connection instead of inline.
It defines a DBDataSourceMetadata element indicating the name of the geometry X and Y columns.
<?xml version="1.0" encoding="UTF-8"?> <NamedDataSourceDefinition version="MXP_WorkSpace_1_5"> <DBConnection dbType="oracle"> <ConnectionName>/myOracleConnection</ConnectionName> <JDBCDriverParameters> <JDBCUrl>jdbc:oracle:thin:scott/tiger@localhost:1521:MyDB</JDBCUrl> <DriverPropertySet> <Property name="user" value="scott"></Property> <Property name="password" value="tiger"></Property> </DriverPropertySet> </JDBCDriverParameters> </DBConnection> <DataSourceDefinitionSet> <DBDataSourceDefinition id="ora1"> <DataSourceName>oracle1</DataSourceName> <DBTable owner="@owner@" useQuotes="true">table1</DBTable> <DBDataSourceMetadata> <FeatureXYAttributes srsName="@srsname@"> <XAttribute>@x_attribute@</XAttribute> <YAttribute>@y_attribute@</YAttribute> </FeatureXYAttributes> </DBDataSourceMetadata> </DBDataSourceDefinition> </DataSourceDefinitionSet> <DataSourceRef ref="ora1"/> </NamedDataSourceDefinition>
In the X/Y table, it is also possible to add a style to the X/Y table features, either by specifying an existing style column in the table, or define an inline style in the named table.
If the X/Y table has a column which contains the styles per row, it can be used by adding a FeatureStyleAttribute element to the DBDataSourceMetadata element. In the X/Y table example, you would add the FeatureStyleAttribute to the DBDataSourceMetadata, where: @STYLE_ATTRIBUTE@ is the name of the column containing the per row style for the feature.
<DBDataSourceMetadata> <FeatureXYAttributes srsName="@srsName@"> <XAttribute>@X_ATTRIBUTE@</XAttribute> <YAttribute>@Y_ATTRIBUTE@</YAttribute> </FeatureXYAttributes> <FeatureStyleAttribute type="mapbasic">@STYLE_ATTRIBUTE@</FeatureStyleAttribute> </DBDataSourceMetadata>
If the X/Y table does not have a column that contains the styles per row, you can use an inline style definition by adding a FeatureStyle element to the DBDataSourceMetadata element. You can use any type of supported FeatureStyle for the X/Y table. For example, you could add a PointStyle to the X/Y feature attributes, where:
<DBDataSourceMetadata> <FeatureXYAttributes srsName="@srsName@"> <XAttribute>@X_ATTRIBUTE@</XAttribute> <YAttribute>@Y_ATTRIBUTE@</YAttribute> </FeatureXYAttributes> <FeatureStyle> <PointStyle> <FontSymbol family="@font_name@" size="@font_size@" size-unit="@size_unit@" stroke="@stroke@" stroke-opacity="@opacity@" text="@font_char@"/> </PointStyle> </FeatureStyle> </DBDataSourceMetadata>