This example shows how to add a spatial index to a geometry field in a table. We use a field of type geom, the native Manifold geometry data type. As is traditional in Manifold, we have named the geometry field Geom so in the schema and other places where field names appear we can immediately know it as a geometry field that contains type geom.
A typical use of an index is to provide a spatial index on a geom field in a table, so the geom data can be visualized in a drawing.
In most cases, Manifold will do that for us automatically. We can create a drawing from a table and Manifold will automatically create a spatial index on the geom field we choose to use, so we do not normally need to do this manually as shown in this example. It is still a useful thing to know to better understand how geometry from tables is used in drawings, or for creating spatial indexes within tables when we will use the data programmatically.
The data set we use consists of a table called Roads Table that contains a list of Roman roads. Each record represents a single Roman road, using a Geom geometry field to store a line object for each road.
We open the Roads Table table:
With the focus on the Roads Table window we choose Edit-Schema. The dialog shows the schema of the table.
We can see from the schema that there is no spatial index on the geometry Geom field, which we will need to visualize the table's geometry in a drawing. That is easy to add.
Press the Add command button.
Choose Index in the drop down menu.
In the Index dialog we provide a name for the new index. We will name it Geom_x using the recommended Manifold style of naming indexes after the field they index with a _x appended. From the drop down list of available index types, we choose spatial index for geometry (rtree).
The dialog automatically reconfigures to add the index type selected.
The Geometry box is loaded with the names of geometry fields we can use. In this table, there is only one geometry field, called Geom, so that is the field which appears by default in the Geometry box. We press OK.
The new spatial index appears in the schema in provisional, bluish color, indicating it has not yet been added to the table. To add the new spatial index to the table and close the dialog, we press Save Changes.
There is no visible change in the table, since the spatial index is not used in the table. However, we can now create a drawing based on the table, using the Geom field for geometry and the Geom_x spatial index.
Now that we have a spatial index on the Geom field we can now open up the Roads drawing that displays data taken from the Geom field. This particular data set shows roads created during the Roman empire.
The Roman roads network which appears in this topic was downloaded from the Harvard University Digital Atlas of Roman and Medieval Civilizations (DARMC) data availability web page, cited as DARMC Scholarly Data Series 2013-5: M McCormick et al. 2013 - Roman Road Network (version 2008). The data set provides a digitized form of roads shown in the Barrington Atlas.
Seen above is a section of the Appian Way, one of the most important Roman roads leading out from Rome. The structures seen to the left side of the road are the remains of tombs of rich families, which lined the Appian Way outside the boundary of the city.
Example: Add a UUID-based Index to a Table - Create a new computed field that is filled with UUID values on creation and then create an index on that field. This technique creates an indexed field that has guaranteed unique values for all records and thus the indexed field and record values may be used in other projects.
Example: Add a Computed Field to a Table - In this example we add a computed field to a table, illustrating how the computed field automatically changes when changes are made in the fields it uses for computation. We also show how computed fields can use geometry, automatically updating centroids when areas are changed. Last, we show how geometry can be created using computed fields, to create effective radius circles for antennas based on the power of the antenna..
Example: Add a Second Computed Geom Field to a Table - We can create tables with more than one geom field in the table and then we can create drawings which use those additional geom fields. This topic shows how to create a second geom that is a computed field based on the first geom. The topic also shows some "real world" methods, such as how to remember the use of a geometry function to do what we want, and how to restore a geom that has been moved. We close with some illustrations of how multiple geoms might be used, and how selection from any drawing or labels based on the same record selects the corresponding objects or labels in all other components based on that record.