Linked Drawings

images/icon_drawing_linked.png A linked drawing is a special kind of drawing that is created on the fly from the information in a table or query. The table or query may be in the Manifold project or it may be a table or query in an external database provider. Linked drawings are shown in the project pane using an icon that include a yellow "database" cylinder to show they are created from a database table or query. Linked drawings can show points or lines.

Linked drawings are read-only and cannot be edited to move points or lines or to add or delete points or lines, except by editing the external table that controls them. They may be formatted and subsidiary components, such as themes or labels components created from the drawing's table, may be created from the linked drawing.

For a general introduction to geocoded tables, see the Linked Drawings and Geocoded Tables topic.

To create a linked drawing of points from an external geocoded table:

  1. Choose File - Link - Drawing and open the desired database file or connect to the desired OLE DB or ODBC data source. Choose This Project in the Files of type box to create the linked drawing from a table or query within the project.

  2. Choose the table desired and check the desired fields. Specify the fields that contain latitude and longitude values (by default, the system will guess that any fields named "Latitude" and "Longitude" are the fields to use). Fields must use decimal degrees format for latitude and longitude coordinates. Press OK. A linked drawing will appear in the project pane.

For example, if the table below were located in some database provider (such as SQL Server or Oracle) or was saved in a database file such as an .mdb file it could be used to create a linked drawing.

X
Y
Comments
  1. 0
  1. 1
Oil Well


  • Oil Well
    2
    4
    Oil Well

    8
    Oil Well
    3
    9
    Oil Well
    6
    2
    Gas Well
    2

    Pump


  • Tank
    6
    3
    Oil Well
    6

    Oil Well
    6.2
    1. 2
    Pump
    1. 2
    5.8
    Tank

    If we created a linked drawing from the table above using the X field for Longitude / X and the Y field for Latitude / Y we could create a drawing of points like that seen below.

    images/sc_linked_drawing_01.png

    For each record in the table, a point has been created. If we add a new record to the table, delete a record or change an X or Y value then the corresponding point will be added to the drawing, or deleted from the drawing or moved within the drawing.

    For a step-by-step example, see the Create a Linked Drawing from a Geocoded Table example topic.

    Uses for Linked Drawings

    Linked drawings allow us to create drawings from data that is changeable and most conveniently stored within geocoded tables or queries. The classic use for a linked drawing is within a Manifold IMS application such as a vehicle tracking web site. Suppose we have a fleet of trucks or ships or other vehicles and we would like to display the location of each vehicle on a web site map. Suppose we can acquire the location of each vehicle through some other application that receives location data from a GPS in each vehicle and places it into a table in our database. Showing the location of each vehicle in Manifold is as easy as creating a linked drawing using that table.

    Because most data acquisition software for vehicle tracking applications is already programmed to update a database table, using linked drawings completely eliminates the need to teach the tracking software package how to interact with a GIS system. All the tracking software need do is update a table, as it already knows how to do.

    Linked drawings are also very useful in situations where the number of objects to be displayed is changeable. For example, suppose we work for an insurance company that sells its insurance products through independent agents. The list of approved agents will change every few days as new agents are added and as poorly performing agents are dropped. We want to create a web site that a prospective customer can use to find the nearest agent offering our insurance products. It would be very convenient to use a linked drawing in the web site so that the list of approved agents can be kept in the form of a geocoded database table.

    This reduces the task of updating the list of agents to an interaction with the database table, which allows greater flexibility in software that can be used to update the status of each agent, what products he or she offers from our company and so forth. There will always be many more software packages and programmers who know how to interact with a popular DBMS product than will know how to interact with GIS software. Therefore, using linked drawings is a good way to add dynamic updating of data to Manifold projects and to Manifold IMS web sites without requiring a lot of GIS expertise on the part of accessory software or web site programmers.

    Lines in Linked Drawings

    Although there is no standard GIS method for representing lines in geocoded tables, Manifold uses a simple convention that can be used to create lines in linked drawings from tables. When importing or linking a drawing from a geocoded table, we may optionally specify a LineID column that will be used to identify which points will be used to draw lines.

    As Manifold scans through the table it will draw lines through all contiguous sequences of two or more records for which the LineID value is the same. When the LineID value changes Manifold will start a new line. If the LineID value is the same for only one record the record will be treated as a point and no line will be drawn. The column used for LineID may be of any type, for example, it could be a numeric or a text column. Newly-created lines will inherit the LineID values of the points used to create them.

    X
    Y
    Comments
    Line Number
    1. 0
    1. 1
    line 1



  • line 1


    4
    line 1

    3
    8
    line 2


    9
    line 2
    2
    6
    2
    single point
    5
    2

    line 3
    6


  • line 3
    6
    6
    3
    line 4
    5
    6

    line 4

    1. 2
    5.2
    line 4
    5
    6.2
    5.8
    line 4
    5

    For example, consider the table above. If the Line Number field is specified as the field to use for LineID then Manifold will use the first three records to draw a line through three coordinate points because the value of 1 is the same in the given LineID field. Next, the system will draw a line through two points corresponding to the records with LineID values of 2. The next record has a LineID value of 5 but because the LineID value changes immediately to the next record it is ignored.

    The system then encounters two records with LineID of 6 so it creates a third line through two points. Finally, Manifold reads four records with a Line ID of 5 so it creates a fourth line through four coordinate points.

    From the above example note there are two key characteristics of this simple format for representing lines in tables:

    To amplify the second point, the table below would have the same effect in creating lines as the table above.

    X
    Y
    Comments
    Line Number
    1. 0
    1. 1
    line 1



  • line 1


    4
    line 1

    3
    8
    line 2
    0
    3
    9
    line 2
    0
    6

    single point



    line 3
    0
    2

    line 3
    0
    6
    3
    line 4

    6
    4
    line 4

    6.2
    5.2
    line 4

    6.2
    5.8
    line 4

    A new line would be created whenever the field used as the LineID field changed from a 0 to a 1 or back to a 0. For legibility reasons, though, most applications will use a field for LineID that more naturally identifies the lines to be created than a pattern of changing from 1's to 0's.

    For example, if our application is a vessel tracking application that shows where ships are currently located and where they have been an easy way to show the tracks of ships where each ship has a unique ship number is to use the Ship Number as the LineID field.

    X
    Y
    Comments
    Ship Number
    1. 0
    1. 1
    line 1



  • line 1


    4
    line 1

    3
    8
    line 2


    9
    line 2
    2
    6
    2
    single point
    3
    2

    line 3
    4


  • line 3

    6
    3
    line 4


    4
    line 4
    5
    6.2
    5.2
    line 4
    5
    6.2
    5.8
    line 4
    5

    We would set up our database so that the table used for the linked drawing is first sorted by Ship Number and then sub-sorted by a date/time field (not shown in the example above) that gives the time each location was acquired. Using the Ship Number field in that case as the LineID field will automatically result in lines that show the ship's track. If we like, we can even format the linked drawing so that lines use directional arrowhead styles so we can see the direction the ship is headed.

    Controls

    images/eg_linkeddrawings_03.png

    When creating a linked drawing the typical dialog seen when connecting to a database file or data source is seen above. The illustration shows a connection to an Access .mdb file but a very wide range of data sources (ODBC, ODBC.NET, OLE DB, etc.) may be used. This dialog allows us to specify how the linked drawing should be created from the table.

    Table / query
    Choose the table or query to be used as a source. Queries cannot be parameter queries.
    images/btn_show_all_columns.png
    Select All - Check all columns.
    images/btn_hide_all_columns.png
    Select None - Do not check any columns.
    images/btn_show_inverse.png
    Select Inverse - Uncheck all currently checked columns and check all other columns. A fast way to use all but one column: click Select None, check the one column not desired and then click Select Inverse.
    Columns pane
    Check columns that are to appear for each point in the linked drawing.
    X / longitude
    Choose a field to use for X coordinate or longitude.
    Y / latitude
    Choose a field to use for Y coordinate or latitude.
    LineID
    Optionally specify a field to use to determine points that are to be used to guide the creation of lines. A line will be drawn through all points having the same value in the LineID field. A new line will be started for each new value in the LineID field. Single-point lines are ignored. The LineID column may be of any type.
    Latitude / longitude coordinates
    If checked, interpret the X / longitude and Y / latitude coordinates as unprojected latitudes and longitudes using decimal degrees. Checked by default. Uncheck if the table coordinates contain projected coordinates.

    Refresh Data

    The data in an external table from which a linked drawing is created controls the contents of a linked drawing. When a record is added to or deleted from the table a corresponding point in the linked drawing will be added or deleted. If the coordinates of a record are changed in the table the corresponding point in the linked drawing will move.

    When Manifold is used interactively, linked drawings are updated whenever they are opened or whenever we press the View - Refresh Data command. When Manifold is used in Internet Map Server mode, linked drawings will automatically be refreshed on whatever interval has been specified.

    Note that unlike map server mode, in interactive usage linked drawings are not automatically refreshed. They are only refreshed (updated to any changes in the controlling table) when the drawing is opened or when the Refresh Data command is issued. The reason for this behavior to guard against situations where the linked drawing suddenly changes while we are in the middle of an editing command or a transform operation.

    Because external tables can be edited independently of what we are doing in Manifold, if linked drawings were automatically refreshed in interactive mode we could easily encounter a situation where were doing something and suddenly points might appear or disappear or move about. Suppose we were in the middle of transferring a selection from the linked drawing to an image. The sudden change would wipe out the operation.

    Caching

    Linked drawings are automatically cached locally using techniques similar to those employed in Manifold Enterprise Edition to cache shared components that are linked from an Enterprise server. If a connection to an external database table is lost during a work session Manifold will continue to operate the linked drawing using the local cache. When a project containing a linked drawing is saved, the local cache will be saved into that project .map file. When the project is opened again, the cached image will be synchronized with the current version of the database table so when the drawing is opened it will show the latest data in the table.

    Use with IMS

    Linked drawings work very well with IMS (Internet Map Server) applications. There are three main considerations to keep in mind when using linked drawings within a map server project:

    Absolute Paths

    When specifying a database table to control a linked drawing the path to the data source is often normalized by Microsoft OLE DB or ODBC drivers to an absolute path. Therefore, when moving projects and any tables used by linked drawings to a different machine, try to preserve the absolute path to the table. For example, if the table is located at C:\Manifold Projects\mytable.mdb on one machine then place it in the same location on the other machine. This is obviously an important consideration when moving files from a development machine to a production IIS machine for use with Manifold IMS in a map server application.

    If we would like to exchange data with other users we should employ linked drawings with care if the linked drawing is created from a table or query outside the Manifold project. If the table controlling a linked drawing is outside of Manifold it will not stored within the Manifold .map project file. Sending a colleague a copy of our .map file will not also send them the database table from which the linked drawing is created.

    Re-attaching a Linked Drawing to a Data Source

    If a linked drawing is disconnected from its data source, it may be reconnected using the Relink command. See the Drawing - Relink / Unlink topic.

    Linked drawings are deliberately designed to have a very damage-resistant connection to their originating tables. We can even delete the table and the drawing will still function from cache if at all possible, ready to be relinked. Renaming or removing the table or query (or renaming or removing the coordinate columns in the table or query) harms the link between the drawing and the table, but linked drawings are designed to survive such scenarios and can even be relinked to modified data with the Relink command.

    While it is not a good idea to tempt fate by deleting tables or otherwise removing data upon which linked drawings depend the robust nature of the connection combined with use of the Relink command will often allow linked drawings to survive significant damage.

    Converting a Linked Drawing to an Ordinary Drawing

    Convert a linked drawing to an ordinary drawing by right clicking on the linked drawing in the project pane and choose Unlink. This will cut links to the controlling table or query and recreate the drawing as an independent, ordinary drawing. See the Drawing - Relink / Unlink topic.

    Importing an Ordinary Drawing from a Geocoded Table

    Drawings may also be created from geocoded tables by using File - Import - Drawing and selecting a database table file or data source in the Files of type box. In this case a drawing of points will be created from the geocoded table but it will not be linked to the table.

    Creating a "Lines-only" Display

    When creating lines in a linked drawing using the LineID option Manifold will draw all points as well as lines in the drawing.

    images/sc_linked_drawing_lineid_01.png

    This can result in a cluttered display, like that seen above created from the tables used as examples earlier in this topic. The lines have been formatted using a directional line style to show their beginnings and ends. Since points are also drawn they appear above the lines in the same drawing and depending on placement can clutter the drawing.

    In interactive work we can easily remove the points, if desired. When working with IMS we cannot interactively delete the points, but we can use a convenient formatting trick to prevent them from appearing. We simply format the drawing so that points are drawn using transparent color for the foreground color.

    images/sc_linked_drawing_lineid_02.png

    This causes the entire point to disappear so no points appear in the drawing, resulting in a lines-only drawing. If we need to create an IMS display that has a combination of some lines and some points we can create two linked drawings in our project from the same table, one of which uses the LineID option and has foreground formatting for points set to transparent color so there are no points and the second drawing of which does not use the LineID option so there are no lines. By using the two drawings in a map with the lines-only drawing appearing in a layer above the other drawing we can cause points to appear below the lines.

    images/sc_linked_drawing_lineid_03.png

    The appearance in IMS will be the same except that the points will appear to be drawn below the lines.

    There are many possibilities to create exactly the display desired. For example, if a display is desired that shows lines for all points but which draws points only for single points or only for the last point in a line sequence we can use SQL to help create such a display. We begin by creating a lines-only display in one linked drawing. Next, assuming that points have fields that can be used to distinguish one point from another we can use a SQL query in our database to create a table that has only single points or terminal points (through clever use of fields that distinguish one point from another) and then create a linked drawing from the query.

    images/sc_linked_drawing_lineid_04.png

    Combining the two drawings in a map will result in a display that shows lines for all points but draws only those points that are single points or that are terminal points. The exact SQL expression that creates a table of only single points or terminal points will, of course, be dependent on what fields are available and how the geocoded table is written in the first place. For example, if we have a vehicle tracking application the code that updates the table with the latest position point may write a flag field that marks this record as the latest in the sequence for that vehicle.

    Example

    In this example we take a geocoded table of restaurant locations and we create a linked drawing. We then create a query using the table and create a linked drawing from that query.

    images/eg_link_drawing_query_01.png

    The table shows sushi restaurants in Palo Alto and Menlo Park near the Northern California USGS facility in Menlo Park. The table is similar to the geocoded table created in the Street Address Geocoding topic example.

    To create a linked drawing using this table we choose File - Link - Drawing and then in the Files of type box in the Link dialog we choose This Project ().

    images/eg_link_drawing_query_02.png

    In the resulting Link Data dialog we choose Sushi Restaurants as the table to use. The table already has fields named Latitude and Longitude so we can accept the defaults and press OK.

    images/eg_link_drawing_query_03.png

    The result is that a new linked drawing appears in our project.

    images/eg_link_drawing_query_04.png

    If we open the drawing we see that it contains a point at the location of each restaurant.

    Suppose that we would like to create a linked drawing that shows only sushi restaurants in Menlo Park. We can do that by writing a query and then creating a linked drawing from that query.

    images/eg_link_drawing_query_05.png

    We create a query with the text above. If all we are interested in are the locations of the sushi restaurants we don't need to select everything (using Select *) but we must select at least the Latitude and Longitude fields. In this case, we select everything so that the linked drawing's table will have all the fields that were in the original table.

    images/eg_link_drawing_query_06.png

    Once more we launch the File - Link - Drawing dialog and choose This Project () in the Files of type box in the Link dialog. In the Table / query box in the Link Data dialog we choose Query.

    images/eg_link_drawing_query_07.png

    One more linked drawing is created in the project pane.

    images/eg_link_drawing_query_08.png

    When we open the new linked drawing and pan and zoom it to the same location as the other linked drawing, we can see that it shows only those restaurants that are in Menlo Park (which is slightly North and West of Palo Alto).

    images/eg_link_drawing_query_09.png

    Now let's do something interesting and show the nature of the linkage between the original table and the drawing linked to the query. Let's select two of the sushi restaurants in the original table and delete them.

    images/eg_link_drawing_query_10.png

    Selecting the two records and pressing Edit - Delete will delete the records for Mikasa and Toshi's Sushiya.

    images/eg_link_drawing_query_11.png

    If we click on the Data 2 drawing (the linked drawing created from the query) and choose Edit - Refresh Data the linked drawing will refresh back through the query and cause the query to refresh itself from the (now altered) table. The result is that two points, those representing Mikasa and Toshi's restaurants, disappear.

    images/eg_link_drawing_query_12.png

    We can bring the records back by clicking onto the original Sushi Restaurants table and choosing Edit - Undo. This restores the records, which has the same effect as if we added two new records.

    images/eg_link_drawing_query_13.png

    If we click onto the Data 2 drawing and choose Edit - Refresh Data once more we see two new points appear for the restored records. If only it was that easy to bring a good sushi restaurant back into business!

    The point of the example above is to show how linked drawings are created on the fly from geocoded tables or queries that contain geocoded data. As records are edited, added to or deleted from the original tables or queries, points corresponding to those records will move, appear and disappear as the drawings linked to those tables or queries are refreshed.

    Example Scenario

    Linked drawings created from tables or queries have great flexibility. In addition to the above example, consider this scenario in which a linked drawing is used to create a particular display:

    Scenario - We have a table of populated places linked from an SQL Server database. We want to label the places so that labels for larger places appear on top of labels for smaller places.

    We create a query for each population range such as…

    SELECT [Latitude (I)], [Longitude (I)], [Pop] FROM [Places] WHERE [Pop] BETWEEN 10000 AND 50000;

    … and we link a drawing from each query.

    We then create a label component for each linked drawing and place all the label components in a map so that the label layers for larger places are higher on the display stack than those for smaller places. Each time the project is opened, the system will connect to the table on the SQL Server, re-compute the queries, update the drawings linked to the queries and update the labels bound to the drawings.

    Dynamic Drawings

    An even more powerful form of linked drawings is the use of dynamic drawings created from tables that store geometry data. See the Dynamic Drawings and Geometry in Tables topics for additional information.

    Tech Tip

    Master the use of linked drawings with geocoded tables that use straightforward, unprojected longitude and latitude coordinates before attempting to work with geocoded tables that use projected coordinate systems for their X and Y coordinates.

    Notes

    Refreshing a linked drawing created from a table that resides in an external data source will refresh the table. Refreshing a drawing linked from a query will recompute the query.

    Refreshing a query will refresh all linked drawings descended from that query.

    See Also

    Linked Drawings and Geocoded Tables

    Create a Linked Drawing from a Geocoded Table

    Formatting Lines in a Linked Drawing

    Importing and Linking Tables
    (for a discussion of ODBC and file types used for tables).

    View - Refresh Data

    Dynamic Drawings

    Back to Manifold Home Page