Example: Edit a Drawing with Transform Templates

In this example we open a drawing and apply Transform pane templates, using previews in blue preview color to see what the templates do.

 

 

We begin by opening a map with one layer, a drawing of Mexico that shows provinces as areas.   

 

With the focus on the open map window, in the Transform pane we choose the Geom field.   The Mexico layer will automatically be entered, since it is the only layer in the map.  We double-click the Convert template to launch it in the Transform pane.

 

 

In the Convert template we choose line as the Convert to option.  

 

Press Preview to see a preview.

 

 

The preview shows what the template will do using blue preview color in a virtual layer above all else in the map.   A blue preview caption bar appears at the top of the window with the name of the template being previewed, to let us know we are seeing a preview.

 

We can see that the Convert: line template converts area objects into line objects that correspond to the area boundaries.   If we do not click the Transform button, this is just a preview and makes no change to the data.

 

We can alter the settings for the Convert  template and preview the changes.

 

 

We change the Convert to option to point and we press Preview.

 

 

The preview instantly updates to show the many points that will be created, at each coordinate (vertex) that defines an area object in the Mexico drawing.  

 

 We press the Up button in the Transform pane to move up one level, to choose a different template.

 

We double-click on the Enclose template to launch it.

 

 

In the Enclose template we choose rectangle as the Enclose in option.  

 

Press Preview to see a preview of replacing the areas with rectangular areas that precisely enclose each area.  

 

 

In the illustration above enclosing rectangles are drawn in whatever happens to be the display order of area objects.   Normally in the case of overlapping objects we would control the order of display by using layers in a map.  If display order matters, it is not a good idea to create area objects which overlap each other within the same drawing.  Instead, we should use layers to control display order.

 

Previews are drawn above all other layers in a map.   We can see what is below by right-clicking the blue preview caption bar and choosing 50% opacity.

 

 

The partial opacity of the preview layer allows a view of objects below.  We can also turn the preview off and on by clicking the caption bar.

Transform and the Selection

We will now explore how the operation of the Transform pane can be restricted to the selection.  We begin by Ctrl-clicking onto some areas in the drawing to select them.   See the Selection topic for selecting objects in a drawing with the mouse.

 

 

First, by Ctrl-clicking it we can select the area shown above, the Mexican province of Durango.  

 

 

The selected area is displayed in red selection color.

 

 We press the Up button in the Transform pane to move up one level, to choose a different template.

 

We double-click on the Reshape template to launch it.

 

 

In the Reshape template we choose rotate as the Operation.  For the Angle, we enter 45, using Degree as the Unit.

 

We check the Transform selection only box.

 

Press Preview.

 

 

Right away the drawing window shows a preview of what the Rotate template does.  The selected area has been rotated 45 degrees.  In the illustration above we have right-clicked the preview caption bar and have chosen 100% opacity, to make the preview layer totally opaque again.

 

 

We change the Angle to 90, and then we press Preview to update the preview.

 

 

The preview rotates the area for Durango by 90 degrees.

 

If we like, we can select more areas in the drawing by Ctrl-clicking them.

 

 

The preview persists even if we make changes to the drawing.  We can Ctrl-click each object to add it to the selection, and the preview remains.

 

 

We can pan and zoom, and even change to different windows and the preview will persist.

 

 

To update the preview, we first turn it off by right-clicking onto the preview caption bar and choosing Hide Preview.

 

 

That turns off the preview.

 

 

We can then press the Preview button again, to refresh the preview taking into account the changed selection.

 

 

At any time we can uncheck the Transform selection only box.

 

 

Press Preview to update the preview.

 

 

All areas, and not just the selected ones, will be rotated.

Save Results to a New Drawing

So far all we have done has resulted in a preview in the drawing window of changes the Transform template would make.   To commit those changes we must press the Transform button.

 

Or, if we prefer, instead of making changes to the original data we can write the changes to a new component.  This will create a new component that contains only the modified objects, that is, just the rotated areas, which are created by the template.

 

 

In the Transform pane, in the pull down menu for the Result destination, choose New Table.

 

 

Enter Rotated Areas as the name for the New drawing and an analogous name for the New table.  We can specify whatever names we want.

 

Press Transform.

 

 

The preview is cleared from the map window.

 

 

Two new components, a new table and a drawing for that table, appear in the Project pane.

 

We can drag and drop the Rotated Areas drawing into the map.

 

 

The new drawing shows provinces in Mexico as rotated by the template.  The rotated provinces are copies of the original data, as rotated.   The original Mexico drawing has not been changed.

 

The illustration above we have double-clicked off the original Mexico drawing layer, more clearly to see the new layer that has been added.

Automatically Creating a Query

If desired, we can take a look at the SQL query that the template uses to work its magic.   We will switch the Result destination to the Same Field, so the query created will be simpler, without all the extra machinery required to create a new drawing and a new table component.

 

 

Press the Edit Query button and the SQL used by the template will be loaded into the Command Window as an automatically generated SQL query.

 

 

The query text in the Command Window is:

 

-- $manifold$

--

-- Auto-generated

--

-- Reshape

--   Layer: Mexico

--   Field: Geom

--   Operation: rotate

--   Angle: 90

--   Unit: Degree

--   Result: (same field)

--   Resources: all CPU cores, all GPU cores

--   Transform selection only: FALSE

--

VALUE @unitDeg FLOAT64 = CoordUnitScale(CoordUnitByName('Degree'));

UPDATE [Mexico Table] SET

  [Geom] = GeomRotate([Geom], GeomCenter([Geom], 0), -90 * @unitDeg);

 

 

The above query shows how the Rotate template works, and it also shows the call to the Selection query function that implements a restriction to only selected objects.   

 

We can modify this query or save it for later use.   Pressing the Edit Query button does not change the original drawing.  It simply opens up a Command Window with an SQL query that would be used by the template if we pressed the Transform button.

Notes

Inherited fields - Objects that are created as a result of Transform operations will whenever possible inherit the data content of the fields for that record.   If we replace a state in Mexico with the enclosing rectangle for that state, the alteration when we press Transform is to the contents of the Geom field.   Other fields for that record, for example, any field that gives the population of the state, remain unchanged.

 

See Also

Selection

 

Select Pane

 

Transform Pane

 

Command Window

 

Queries

 

Example: Two Drawings from the Same Table - Take a table with a geom field that is visualized by a drawing.  Add a second geom field to the table and create an rtree index on that field so it can be visualized by a drawing.   Copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field. Demonstrate how to use the Transform pane to show "live" modifications in the second drawing compared to the first drawing.

 

Example: Copy one Column into Another Column with Transform - How to use the Transform pane to copy the contents of one column in a table into another column, but only for selected records.  Uses the Products table from the Nwind example data set.  

 

Example: Transform Field Values using an Expression in the Transform Pane - How the Expressions tab of the Transform pane may be used to change the values of fields.  

 

Example: Construct JSON String using Select and Transform - Use the Select pane and the Transform pane to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.

 

Example: Use a Transform Expression to Create Buffers in a Drawing - Use the Expression tab of the  Transform pane to create three different sizes of buffers for different lines in a drawing and then automatically create a query which does the same thing.  Includes examples of saving results to a new component and also the Edit Query button.

 

Example: Transform Templates, Expressions and Queries - We learn to use a function by clicking on a template in the Transform pane , seeing what it does in a preview, looking at the query Manifold creates and then trying out the function in the Expression tab.