Appendix E- Feature Editing

Spectrum Spatial Analyst administrators have the capability of allowing users to insert new feature and edit the existing features of underlying data source in the browser. The insertion/editing will be done in the browser and only one record at a time will be inserted/edited.

Once a user has committed an edit, it will update the source table and other users who subsequently request the data will be able to see the updated record.

The table below lists the data sources which are supported for editing in Spectrum Spatial Analyst.

Data Source Spatial Table XY Table
Oracle 11gR2 Read/Insert/Update/Delete Read/Insert/Update
SQLServer 2008 R2/2012 Read/Insert/Update/Delete Read/Insert/Update
PostgreSQL 8+ / PostGIS 1.5 and 2.x Read/Insert/Update/Delete Read/Insert/Update
GeoPackage / Windows and Linux Read/Insert/Update/Delete NA
MapInfo TAB Read/Insert/Update/Delete NA
Note: The MapInfo TAB files are supported for editing in Windows. For more details about the limitations applicable to the insert, update and delete operations on these native files, refer to MapInfo Native TAB section of Spectrum Spatial Guide.
A user can edit or delete the record if the following conditions are met/satisfied
  1. The map configuration has editing enabled as a capability (Either Full Editing or Attribute Editing Only)
  2. The tables are present in that map configuration and are one of the types that support editing (listed in the above table).
  3. Assigning permissions on namedTables- New ACL permissions (Location Intelligence. Dataset) have been introduced in Spectrum 11.1. By which we can individually set the edit permissions of create/modify/delete access control on namedTables. A few points to be noticed here are:
    1. Only namedTables will be shown in this Dataset category because edit permissions are to be set only on namedTables.
    2. Create/Modify/Delete is controlled from this category. Earlier “Modify” permission was enough to have create/edit/delete access rights on a resource. Now, any role that has Modify permission on any namedTable, has edit access control only. For example, if a role wants to have all access rights, then they must check the Create, Modify and Delete check box (as shown in above image). Any combination is possible, a table can also have delete access right alone.
    3. Role must have execute permissions on the named table under the category of Location Intelligence.Named resources.

    If all conditions above are met, then editing is enabled in the user interface and the user will be able to initiate an edit on the table(s) they have permission on Access Control over a particular resource.

Primary Key Requirements

For Oracle data source, the primary key column must be configured to increment automatically for a successful ‘add record’ operation. This can be done by applying a sequence in the database.

Below is an example of creating a sequence on ‘cycleparks’ table and using the sequence to create a trigger for auto incrementing the primary key column MI_PRINX.
CREATE SEQUENCE STRATUS.cycleparks_seq 
START WITH     44 
INCREMENT BY   1 
NOCACHE 
NOCYCLE;

CREATE OR REPLACE TRIGGER STRATUS.cycleparks_auto_inc
BEFORE INSERT ON STRATUS.CYCLEPARKS 
FOR EACH ROW
BEGIN  
SELECT STRATUS.cycleparks_seq.NEXTVAL  
INTO  :new.MI_PRINX  
FROM   dual;
END;

As SQL server and Postgres takes care of auto incrementing the primary key, there is no additional step required.

Configuring the feature edit/insert validation form

Analyst provides a layer of validation rules that are used when editing. These rules are defined in an XML file that can be created for each and every table that can be edited. They include rules defining whether a column is required, whether it used default values, value ranges, whether a picklist is to be shown, etc.

Administrators have the flexibility of choosing which attributes of the table a user can edit including the geometry of the current feature and what types of geometry should be allowed. They also have the fine-grained control on what information a user can submit for inserting a new feature. This is a manual step and can be done by specifying the rules via an XML file. If the admin does not specify any XML, then by default, all the columns of the table will be presented for insertion/editing.

The validation XML files need to be placed into this (customerconfigurations\analyst\theme\featureEditTemplates) folder in Analyst and can be assigned to map configurations using the new (Edit Template Mapping) sub tab.

Below is the sample XML and its usage-

<FeatureEditing>
  <table>
      <table>/Samples/NamedTables/WorldTable</table>
      <showAllAttributes>false</showAllAttributes>                       
        <primaryKey>
           <includeInInsert>true</includeInInsert>                                   
           <hidden>false</hidden>                                   
           <showDisabled>true</showDisabled>
   </primaryKey>                       
          <geometrySupported>                                                                   
               <line>false</line>                                   
               <point>false</point>                                   
               <polygon>true</polygon>                       
          </geometrySupported>                        
          <columns>
	      <column>                                               
               <dbColumnName>Column_1</dbColumnName>                                               
               <name>Column 1</name>                                               
               <required>true</required>                                                                                
               <defaultValue>Enter Unique Value</defaultValue>                                               
               <minLength>4</minLength>                                      
               <maxLength>25</maxLength>                                
             </column>
	   <column>                                               
              <dbColumnName>Column_2</dbColumnName>                                               
              <name>Column 2</name>                                               
              <required>true</required>                                               
              <pickList> 
                   <Option></Option>                                                          
                   <Option>Option 1 </Option>                                               
                   <Option>Option 2</Option>                                                           
                   <Option>Option 3</Option>                                               
              </pickList>
          </column>
	        <column>                                               
               <dbColumnName>Column_3</dbColumnName>                                               
               <name>Column 3</name>                                               
               <required>false</required>                                               
               <showDisabled>true</showDisabled>                                               
               <minValue>1</minValue>                                                
               <maxValue>365</maxValue>                                   
           </column>
	 </columns>           
   </table>
</FeatureEditing>  

Please refer to the below table for more information about the XML elements and their usage.

Element Required/Optional Usage
table optional Repository path of the table
showAllAttributes required

If set to true, all the table columns will be presented in the attribute form. Also, the column names, if provided, will be ignored in this case.

If set to false, you must specify one or more columns that need to be displayed.

primaryKey > includeInInsert required Set to true for Oracle/Geopackage, false otherwise
primaryKey > hidden optional Set to false if primary key column needs to be displayed
primaryKey > showDisabled optional

Valid if primaryKey > hidden is false.

Set to true if this should be displayed but as read only.

Set to false, if a user input is required. Please note the value provided by the user will get overridden by any sequence/auto-increment set in the database.

geometrySupported optional Used for restricting the geometries that can be drawn while inserting/editing features. If none provided, the geometry toolset will allow all shapes. Inserting or editing of combination of geometries is not supported e.g. user can draw one or more polygons but not the combination of polygons, lines and points.
columns optional The columns provided here will be presented in the attribute form
dbColumnName required Name of the column as present in the actual table
name required Friendly name that will be displayed in the attribute form
required optional Set to true if a user input is mandatory
defaultValue optional Provides a default value
minLength optional For text columns, use this to specify a minimum length criteria
maxLength optional For text columns, use this to specify a maximum length criteria
minValue optional For numeric columns, use this to specify a minimum value
maxValue optional For numeric columns, use this to specify a maximum value
pickList optional Provide the options to allow user to choose one of the pre-defined values.
Note: If provided, empty option will insert null value in database or tab file.

For a given combination of map configuration and table, there can only be one configuration XML. However, multiple XML configurations can exist for the same table if the map configurations are different. This mapping among map configuration, table and XML configuration can be set using admin console.

Spectrum allows a column of the table to be marked as ‘read only’. In such cases, that column should not be provided in the template.

Applying Style to Inserted/Edited Features

The style of the inserted feature is not defined when an insert takes place. If the data source being edited has table-level styling (rather than a style column per row) the inserted feature will adopt the style of the table. If the data source being edited has per row styling enabled then the feature inserted will adopt the default style of white fill and black outline. We always recommend that the administrator applies a style override to the table while uploading it using MapInfo Professional. This will ensure that all features are shown in a desired style in Spectrum and Analyst regardless of per row styling.