Example: Two Drawings from the Same Table

This example has three objectives:

 

 

In this example we take a table with a geom field that is visualized by a drawing.  We add a second geom field to the table and create an rtree index on that field so it can be visualized by a drawing.   We copy the first drawing, paste it and adjust the pasted copy so it uses the second geom field.   We demonstrate how to use the Transform dialog to show "live" modifications in the second drawing compared to the first drawing.

 

Sometimes we may want to see what effects a Transform template that operates on geom data within a table has upon any drawing which displays that geom data.   There are two ways to accomplish such experimentation without changing the original geom data:   we can either open the Transform dialog in the context of the table, or we can open it in the context of the drawing.    See also the Notes at the end of this topic.

Transform Dialog and Tables

The Transform dialog operates on whatever open component has the focus when the Transform dialog is launched.  For example, if we open a table window and then choose Edit - Transform to launch the dialog the Transform dialog will operate on that table.  The Transform templates available will be those which make sense for that table and for the specific field within the table chosen as the target field.  Whatever previews the dialog does will be done within that table, showing the result that would happen to the target field.

 

Such previews will not be passed on and displayed in other components, for example, a drawing window that visualizes data from a geom field in the table.   That is because the preview is just a preview, not a change in the actual table data and other components, like drawings, which display the actual data will continue to display the actual data.   If we want other components to change we must change the actual data which they display.

 

The first part of this topic shows one way to do that.   If we want to experiment with data in the context of an open table but at the same time we also want to see what changes such experimentation causes in other components, such as drawings, which depend upon data in the table, that is easy to do.   

 

If we want to experiment with changes to a Geom field without actually changing the Geom field, we simply create an additional field that can function as a copy of the Geom field or as a temporary scratch pad to hold changed versions of the Geom field.   In this example we use a name of Tgeom (a mnemonic for "Temporary Geom")  for that temporary scratch pad field.   We can then create a second drawing, which in this example we name Temp Objects Drawing, shows whatever is in Tgeom.    We can then use Tgeom as the target field for Transform templates, using Geom as the source field and we can press Update Field to actually change the data within Tgeom so that any components, like Temp Objects Drawing, which utilize that field can update as well.

 

Geom never gets modified: it is just the source field from which data is copied or which is used to feed the Transform template that puts data into our temporary scratch pad field, Tgeom.   That allows us to try out as many templates as we like to see what effect they have on Tgeom in the preview in the table, and then, by pressing Update Field to update Tgeom to see what effect they have on the Temp Objects Drawing.

 

At any time when we are done experimenting we can fill Tgeom full of NULL values again or simply delete that field as well as the temporary, Temp Objects Drawing that showed its contents and the table will be back to the way it was originally, with Geom completely unmodified.

Transform Dialog and Drawings

When a drawing is open and has the focus, choosing Edit - Transform will open the Transform dialog in the context of the drawing.    Fields that are available in the dialog will be fields in the table from which the drawing takes its geom data for visualization.    In many cases, the Transform templates that are available to work on those fields will be the same as those that are available when the drawing's table is the context for the Transform dialog.  

 

When a Transform dialog is opened in the context of a drawing any previews the Transform dialog causes will be shown in the drawing.   We can exploit that effect to see what a particular template does to objects in the drawing using the preview without any need to press the Update Field button.

 

Important: The Transform Dialog can show previews for its work in a drawing if there is at least one object in the drawing.   Drawings can not host previews if they are empty, that is, where there are no records in the associated table or where the values for all records in the geom field the drawing uses are NULL values.  That is true even if the preview would involve filling the NULL values with non-NULL geom values.

 

Examples Using the Transform Dialog and a Table

Our project has an Objects table and an Objects Drawing.

 

eg_two_drawings01_01.png

 

We open the Objects Drawing, zoom to fit, and then zoom out one click on our wheel mouse so that all objects are visible.

 

eg_two_drawings01_02.png

 

We open the table.   There are three areas, two lines and two points in the table.  

 

eg_two_drawings01_03.png

 

To add another field we click on the column head with an asterisk * to launch the New Field dialog.

 

 

eg_two_drawings01_04.png

 

 

We choose a name, Tgeom, and a type, geom, for the new field and then we press the Add Field button.

 

eg_two_drawings01_05.png

 

The result is that a new geom field called Tgeom has been added to the table.  So far it is filled with NULL values.    

 

Our next step is to add an index so this new geom field can be used by drawings.

 

 

eg_two_drawings01_06.png

To do that we choose Edit - Schema to open the schema for the table.

 

 

eg_two_drawings01_07.png

 

We click on <new index> to start adding a new index.

 

eg_two_drawings01_08.png

 

We use the Manifold tradition of naming the new index for a field by that field's name with a _x appended, so for the name of our new index we will specify the name Tgeom_x.  We choose a type of rtree for the index and press the Add button.

 

 

eg_two_drawings01_09.png

 

The new index is added to the table and a box opens up that allows us to choose what Field will be indexed by this new index.  From the pull-down list of fields we choose Tgeom and press the Add button.

 

eg_two_drawings01_10.png

 

We now have added to the table's schema a new index, Tgeom_x. which indexes the Tgeom field.    We press OK.

Create a Second Drawing using the Same Table

We will now create a second drawing to use the new Tgeom field.

 

eg_two_drawings01_11.png

 

In the Project pane we right-click on the Objects table and then in the context menu we choose New Drawing.

 

eg_two_drawings01_12.png

 

In the New Drawing dialog we Name the new drawing Temp Objects Drawing.   The dialog is already loaded with the Objects table and the geometry fields in the table.  In the Geometry box we choose Tgeom.

 

eg_two_drawings01_13.png

 

The dialog knows there is already a spatial index on the Tgeom field (if not, the dialog could create a spatial index on that field for us).  We press Create Drawing.

eg_two_drawings01_14.png

The new drawing appears in the Project.  To open it we can double-click on the Temp Objects Drawing.

 

eg_two_drawings01_17.png

When we open the Temp Objects Drawing it shows nothing, because the drawing now uses a field, Tgeom, within the Objects table that as yet is full of NULL values.

 

We will now populate the Tgeom field using the Transform dialog to put values into the Tgeom field based on existing values in the Geom field.   

 

With the focus on the opened Objects table, we choose Edit - Transform.

 

eg_two_drawings01_18.png

 

In the Transform dialog we choose Tgeom in the upper box as the target field, we click on the Copy template to choose that template and then we choose Geom in the lower box as the source, value field.

 

When we press Update Field, the values for each record in the Geom field will be copied into the Tgeom field.

 

eg_two_drawings01_19.png

 

To see the objects in the open, Temp Objects Drawing we press Zoom to Fit.  We then use the mouse wheel to click out one zoom level so all the objects are in view.  The view is identical to what we see in the Objects Drawing because the objects now in the Tgeom field that the Temp Objects Drawing window shows were copied from the Geom field that the Objects Drawing window shows.

 

eg_two_drawings01_20.png

 

Using Tgeom as the target field and Geom as the source field we can choose different templates in the Transform dialog and as we click Update Field the results of the transform will be put into the Tgeom field and the Temp Objects Drawing automatically will show them.

 

eg_two_drawings01_21.png

 

For example, we can choose the Buffer template with a Distance of 5 and when we press the Update Field button the Tgeom field will get updated.

 

eg_two_drawings01_22.png

We can see the results "live" if we leave both the Objects Drawing and the Temp Objects Drawing open next to each other at the same time.

 

 

eg_two_drawings01_23.png

 

Increasing the Distance to 15 while still using Buffer and then pressing Update Field shows us what effect increasing the Distance has on the objects created by the Buffer template.

 

eg_two_drawings01_24.png

The greater Distance means the borders of the buffer areas are created further away from the edges of the objects from which they are created.

 

 

eg_two_drawings01_25.png

 

Choosing Convert to Point and pressing Update Field shows how the template creates points at the locations of coordinates which define objects in the source field.

 

eg_two_drawings01_26.png

Since we are using the Transform dialog with Geom as the source field and Tgeom as the target field the Geom field is not modified.   Only the Tgeom (a name we chose to mean "temp geom") field is modified.

 

eg_two_drawings01_27.png

 

For our last example we will click on Enclosing box and press Update Field.

eg_two_drawings01_28.png

 

The result is to place into Tgeom area objects which are the enclosing boxes for line and area objects in the source geom field, that is, the minimal sized rectangular areas that full enclose the source objects.

 

Examples Using the Transform Dialog and a Drawing

Let us re-start the above example from the point where we had a blank Temp Objects Drawing.   

 

il_trans_drawing_start_geom.png

With the drawing open and the focus on the drawing we choose Edit - Transform to open the Transform dialog in the context of the drawing window.

 

If we have been experimenting with this example and the Tgeom field is not empty, that is, full of NULL values, we can fill it with NULL values by using the expression

 

NullIf(1, 1)

 

And pressing Update Field.

 

eg_two_drawings01_29.png

 

Note that in the dialog above we entered nul into the filter box to reduce the long list of operators and functions to just those which are related to NULLs.

 

Drawings which are empty cannot show previews so our first order of business is to copy the Geom field contents into the Tgeom field so the Temp Objects Drawing has something to show:

 

eg_two_drawings01_30.png

 

We press the Update Field button since we want to actually change the data in Tgeom to values other than NULL.

 

eg_two_drawings01_31.png

There, that is better!   The drawing can now preview what we do in the Templates dialog.

 

 

eg_two_drawings01_32.png

 

When we click on the Bounds template in the Transform dialog (partial view above), right away the system previews the result in the drawing.

eg_two_drawings01_33.png

 

The Bounds template (see the Transform Templates - Geom topic) puts a point at the start and the end of each line and draws a line around the outer boundary of each area.

 

eg_two_drawings01_34.png

 

Click on the Convert to Point template and the drawing window immediately previews the points it creates.

 

eg_two_drawings01_35.png

As noted in the Notes to the Transform Dialog topic, the points created by Convert to Point are multipoints.

 

 

Notes

tech_ravi_sm.png

Tech Tip:  When the Transform dialog previews changes in a table why do not all drawings which use that table also update with a preview if the geom field they use has been changed by the preview in the table?    They do not change because the Transform dialog exists exclusively in the context of a specific open window that had the focus when the Transform dialog was opened.   That is a good thing because it allows the same table to be opened in different windows with a different Transform dialog open for each of those different windows, all showing a different preview.

 

Suppose we open the Objects table.   We then choose Window - New Window to open the same table in a second window, which automatically will be named Objects (2).   

 

We click on the Objects table window to move the focus to that window and we choose Edit - Transform to launch the Transform dialog.   For a target field we choose Tgeom, we choose the Copy command and we choose Geom as the source, value field.   The preview instantly shows Tgeom populated with copies of the Geom field.

il_trans_dual_windows1_geom.png

 

Without closing the Transform dialog open for the Objects window we click on the Objects (2) window.   Again, we choose Edit - Transform to launch the Transform dialog.   We now have two Transform dialogs open, one for the Objects window and one for the Objects (2) window.    In the Transform dialog for the Objects (2) window for a target field we also choose Tgeom, but then we click on the Expression tab and enter the expression

 

NullIf(1, 1)

 

That expression evaluates to NULL for all records so the preview instantly shows Tgeom populated with NULL values.

il_trans_dual_windows2_geom.png

We now have the very same table, the Objects table, open in two different windows at the same time.   We also have two Transform dialogs open at the same time, one for each of the two open windows, both operating upon the same table and both doing different things and showing a different preview in that same table.

 

If we wanted to, we could open the Temp Objects Drawing in a window.  We could then once more choose Edit - Transform to open the Transform dialog in the context of that drawing window.   We would now have three Transform dialogs open at the same time.  Transform dialogs that are opened for drawings will operate on the fields in the table from which the drawing visualizes data.   Many Transform templates are repeated both in a table and also in a drawing using that table.

 

In the Transform dialog we just opened for the drawing we could choose the Tgeom field as the target field and then choose the Enclosing Box template using the Geom field as the source field.   The Temp Objects Drawing will right away preview the result.

il_trans_dual_windows3_geom.png

We now have a total of three Transform dialogs open, two open directly in the context of a table and one open in the context of a drawing that shows data from that table.  All three Transform dialogs are working with different templates or an expression to do three different things and to show three different previews in their respective windows.

 

It is a good thing when a Transform dialog operates in the context of the window that had the focus when it was launched.  That allows us to open multiple windows for the same table and to launch multiple Transform dialogs that operate on data in the same table.  We can use those multiple Transform dialogs to preview different proposed modifications at the same time to make sure that what we command is what we would like, or just to learn more about what might be done or to run a "thought experiment" to explore our data.     

 

In the above discussion all three of the open Transform dialogs work on the same field, but it could be that we could have different Transform dialogs working on different fields so we can plan out how we might change data in a table when more than one field must be changed.

 

See Also

Transform Dialog

 

Transform Templates

 

Transform Templates - Drawings

 

Transform Templates - Boolean

 

Transform Templates - Datetime

 

Transform Templates - Geom

 

Transform Templates - Numeric

 

Transform Templates - Text

 

Example: Drawings use Geom Fields in Tables  - An essential discussion on how drawings are created from geom fields in tables, including how the drawing knows which coordinate system to use.

 

Example: Create a Drawing from a Geocoded Table - A geocoded table has records with a latitude and longitude for each record.   This example starts with a table containing a list of cities with a latitude and longitude field for the location of each city.   We create a geom from the latitude and longitude fields using a template in the Transform dialog and then we create a drawing that shows the cities as points.  This example shows all the infrastructure steps involved.

 

Example: Copy one Column into Another Column with Transform - How to use the Transform dialog 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 Dialog -  How the Expressions tab of the Transform Dialog may be used to change the values of fields.   We include an example of changing the price of selected products and using two different Transform dialogs open at the same time for two different table windows.

 

Example: Construct JSON String using Select and Transform - Use the Select and Transform dialogs 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: Edit a Drawing with Transform Dialog Templates -  In this example we open a drawing and edit objects in the drawing using the Transform dialog Template tab.   Includes examples of using the Add Component button and also the Edit Query button.

 

Example: Use a Transform Dialog Expression to Create Buffers in a Drawing - Use the Expression tab of the Transform Dialog 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 using the Add Component button and also the Edit Query button.

 

Example: Clip Areas with a Transform Dialog Expression - Use the Expression tab of the Transform dialog to clip areas in a drawing to fit within horizontal bounds.   Includes examples of using the Add Component button and also the Edit Query button.

 

Example: Smooth Lines with a Transform Dialog Expression - Use the Expression tab of the Transform dialog to make lines smoother in a drawing so that longer lines are smoothed more.  Includes examples of using the Edit Query button to show how different queries are created automatically depending on if we want to update a field or to add a new component.