Quantcast
Channel: OpenCities Map Wiki
Viewing all articles
Browse latest Browse all 1284

- Using joins to create custom searches

$
0
0
Current Revision posted to Bentley Map | OpenCities Map Wiki by Inga Morozoff on 3/9/2020 6:48:51 PM

This article will present the details required to perform custom searches by creating a Join using Bentley Map. Two types are illustrated – Map Manager Joins using XFM Features, and SQL Server Spatial Joins using database Views and Tables.

Contents

Introduction. 2

Map Manager Join. 4

SQL Server Spatial Database Join. 7

 

An introduction to joins

Introduction

Bentley Map supports two types of joins to reveal feature properties from multiple tables.

A simple join can be defined via the Map Manager which provides the ability to join the properties of selected features through a common attribute.   Joining features in this way makes the properties of the other feature available whenever the selected features are reviewed or browsed.

A spatial database join is used for performance improvements and provides a means to execute searches on the database properties when querying a feature.  

For example, without a database join, the ability to perform a search for your query is restricted to only those properties found in the features table:


With a database join, a search for the query can be performed on multiple tables.


 

Map Manager Join        

The Map Manager in Bentley Map provides the tools to create a join from the Context menu – right-click on any Feature name to access the context menu.


In the following example, both the LOTS and BUILDINGS tables contain the property BUILDINGID.


This allows you to perform a simple join in Bentley Map to review the properties from both tables.

To do this, create a join using the Join option from the Map Manager and select the common property between the two tables. Note that the Define Joins dialog shows the property names as defined in the Display Name in the Geospatial Administrator. This may be a different name that what’s defined in the database.

Once a join is established, the properties of both tables will be shown in the Analyze Result dialog. However, due to performance issues, the Data Browser will only show the left side property, or in this example, the Lots.


This type of join is saved in the Map model in which they are defined and can also be created with a key-in.

Joins can be created by using key-ins as below:

MAP JOIN ADD feature1.property1=feature2.property2- creates a join between feature 1 and feature 2.

MAP JOIN SHOW - Shows the Joins dialog.

MAP JOIN CLEAR - Removes all joins.

MAP JOIN REMOVE feature1.property1=feature2.property2 - Removes the joins specified. It should respect f1.p1=f2.p2 format. f1 must always be specific while wild cards can be used for other parameters.

SQL Server Spatial Database Join

Spatial graphical sources joins are performed at the database level for performance improvements as well as to:

  • Provide query simplification and standardization since the view query is executed at the database level rather at the desktop.

  • Enforce security granting access on a view to those users who are permitted to view those database rows.

 

When working with feature classes from spatial graphical sources, joins cannot be made from a left side feature class to a right side class that is not in the same graphical source.

In this example, LOTS and STRUCTURES both contain the property BuildingID which will be used to define the join. The STRUCTURES table contains supplementary information for the structures on each lot. On its own, the content in this table cannot be queried graphically in Bentley Map due to the lack of geometry information.


A database view can be used to create discoverable Bentley Map features containing property information from multiple tables. A database view can be described as a virtual table in the database where the data in the view is not stored as a distinct object, but is accessed via a SELECT statement.  Database views can be used for a number of functions including joining columns from multiple tables so they appear as a single table. 

Use the following SQL Script to create discoverable Bentley Map feature where:

Table_A contains the geometry and properties for a line, point or polygon feature.

Table_B contains properties related to Table_A via a common column between the two tables.

CREATE VIEW ViewName

       AS

       SELECT

              dbo.Table_A.id AS PKID,

              dbo.Table_A.GEOM,

              dbo.Table_A.Column_1,

              dbo.Table_A.Column_2,

              dbo.Table_A.Column_3,

              dbo.Table_B.Column_4,

              dbo.Table_B.Column_5,

              dbo.Table_B.Column_6,

              dbo.Table_B.Column_7

             

       FROM

              dbo.Table_A

              LEFT OUTER JOIN

       dbo.Table_B ON dbo.Table_A.CommonColumn = dbo.Table_B.CommonColumn

GO

 

 

In the following SQL, a join is created between the LOTS and STRUCTURES tables via the BuildingID column.

CREATE VIEW LotsView

       AS

       SELECT

              dbo.Lots.dgn_id AS PKID,

              dbo.Lots.GEOM,

              dbo.Lots.Address,

              dbo.Lots.PropTax,

              dbo.Lots.PropVal,

              dbo.Structures.YearBuilt,

              dbo.Structures.HeatType,

              dbo.Structures.OccupClass,

              dbo.Structures.RollNumber

             

       FROM

              dbo.LOTS

              LEFT OUTER JOIN

       dbo.Structures ON dbo.Lots.BuildingID = dbo.Structures.BuildingID

GO

 

A refresh of the Views node in the database will show the newly created View:


 

For Bentley Map to use this new information, the View needs to be registered as a feature.   This is done via the Geospatial Administrator by selecting Register Features from the SQL Server Spatial Connection node.



 

Once registered, the View will appear as a valid feature which can be further edited to show the correct display name and symbology.


When the schema is exported to the workspace, the View will be available for the users to query.   In this example, only those lots with structures that were built from 1951 and later are queried from the database.


When the features are analyzed, both the Data Browser and Analyze Results dialog will show properties as defined in the Database View.


 


 

The information presented above is intended as an introduction to database joins. Please refer to the Bentley Map Help document for more information.

 

Select this link to download the PDF file: Using Joins to Create Custom Searches 


Tags: SQL Server Spatial, Join, View, Bentley Map, Map Manager

Viewing all articles
Browse latest Browse all 1284

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>