FME Version
Files
Introduction
Welcome to the FME for Smallworld 5 tutorial. In the previous section, Importing into Smallworld, you wrote to the Smallworld cable object which only has a single geometry or spatial column. Many Smallworld objects have multiple spatial columns with different geometries (chain, area, point, text). This article covers importing data into your Smallworld 5 database, including how to import into a multiple geometry object.
Load Supply Point Multiple Spatial Columns
In this example, you are going to load the Supply Point object which has both a point (location) and text (label) geometries.
Step-by-step Instructions
1. Generate Workspace
You’re going to generate the workspace in the same way you did in the previous section. Open FME Workbench. On the Workbench Start tab, choose the Generate option.
Reader Format: | Autodesk AutoCAD RealDWG DWG/DXF |
Reader Dataset: | electric-networkproposed.dwg |
Parameters > Group Entities By | Attribute Schema |
Parameters > Expand Blocks into Entities | UNCHECK |
Writer Format: | Smallworld 4/5 |
Writer Coord. System: | OSGB-GPS-2015 |
Parameters > Service | FME |
Parameters > Alternative | |fme_training |
(Be sure to use the | symbol as the first character for Alternative)
In the Generate Workspace dialog, place a check mark on the “Import feature type definitions” checkbox.
Click OK.
2. Import Writer Feature Types from Smallworld
The “Import Writer Feature Types” dialog will appear. Click on the Parameters button, and select:
- Table List: electricity.supply_point
Click OK to close the import feature types dialog.
3. Select AutoCAD Layers
The Select Feature Types dialog will open. This is the AutoCAD layer selection.
- Select electricity_supply_point
And click OK, to generate the workspace.
4. Save Workspace
Save the workspace locally at:
<My Documents>\My FME Workspaces\Smallworld5.fmw
5. Connect Reader and Writer Feature Types
Connect the electricity_supply_point reader feature type to the new electricity.supply_point writer feature type.
Expand the attribute lists for the reader and the writer.
Note: The FME Smallworld 5 writer handles Smallworld geometries in a completely different way to Smallworld 4. The Smallworld 4 versions of the workspaces are all attached at the bottom of this article for reference. Geometry types are no longer exposed as attributes and no longer use the sworld_geometry{} list attributes. Old workspaces are still compatible in Smallworld 5.1.
6. Redirect to Inspection Application
When making more complicated workflows, it’s a good idea to try and test them before attempting to load the data into the database. In workbench, on the Writer menu, set Redirect to Inspection Application. All your output will be redirected to the Data Inspector as you build your workspace.
Also, as you build your workspace, add Data Inspector transformers to inspect the intermediate results.
7. Filter the Proposed Supply Points
You only need to insert the proposed supply points. Add a Tester transformer to filter the status attribute to keep the “Proposed” supply points.
8. Filter the Point & Text Geometries
Add a GeometryFilter and expose the Point and Text Geometries. This will split the point geometries and the text geometries into two different streams.
9. Set Geometry Name
Supply Points in the Smallworld Cambridge database have two spatial columns for location and annotation and these are named 'location' and 'label', respectively. You need to add a GeometryPropertySetter for the point and text geometries and set the appropriate geometry name.
10. Set Attribute Values and Database Operation
Add an AttributeCreator transformer to your workspace and connect it between the Tester transformer and the GeometryFilter. In the AttributeCreator add the attributes:
fme_db_operation | INSERT | insert new records only |
customer_class | New Customer | So we can recognize the new records |
The text label is set to the id value by Smallworld when the object is inserted - in this case the 'id' value.
11. Combine the Location and Label Geometries - Aggregator
The Aggregator transformer produces a new geometry structure that is an FME aggregate. An aggregate is a feature that has multiple geometries sharing the same attributes. In this case the aggregate will consist of a text (for the label) and a point (for the location) of the supply point (a heterogeneous aggregate). The aggregator requires a key for the aggregation (the Group By parameter). For many CAD to GIS problems, there may be no key attribute so a NeighborFinder transformer might be used to make a spatial join. We’re lucky – this DWG file has an id field we can use.
Add an Aggregator transformer and connect both of the GeometryPropertySetter transformers Set ports to the Aggregator input port.
12. Set Aggregator Parameters
In the parameters dialog for the Aggregator, enter these settings:
Group By: | id |
Mode: | Geometry - Assemble One Level |
Attribute Accumulation Mode: | Merge Incoming Attributes |
Aggregation Type: | Heterogenous Collection |
The Aggregator transformer merges your point (location) and text (label) features using the 'id' attribute as the key. The Mode sets the type of merge used for geometry – in this case, a simple (one level) geometry structure.
Note: in Smallworld 4, you would build the sworld_geoemtry{} list in the Aggregator transformer. This is no longer needed for Smallworld 5. Older workspaces with the sworld_geoemtry{} list configuration will still run and load the data correctly. Examples of the Smallworld 4 workspaces are attached at the end of this article.
Add a Data Inspector to the Aggregator and inspect the results.
13. Save and Run
Run the workspace and inspect the results in Data Inspector.
On the Writer menu, unset Redirect to Inspection Application and run again.
Inspect the updated data in the Professional - Smallworld Core GIS application. If you need to, use the Smallworld Versioning to roll back to the last checkpoint and correct your workspace.
Save the workspace - it should look something like this:
Summary
In this exercise, you’ve read point and text features from the AutoCAD dataset and then merged them with the Aggregator transformer. The Aggregator transformer also builds the multiple geometries used by the Smallworld writer to populate the multiple spatial columns in your Smallworld Cambridge database.
Smallworld 4 Examples
There are differences in the way that FME creates the multiple geometry features for the Smallworld 5 writer, compared to Smallworld 4. It's quite a lot easier in Smallworld 5. The example below shows how to accomplish this for Smallworld 4. The Smallworld 5 writer still support this old approach, so if you have existing workspaces, they will be compatible with Smallworld 5 and should run without any need to change them.
Comments
0 comments
Please sign in to leave a comment.