Attributes Editing

iMobile supports editing object attributes, which can add attributes to new point, line and surface objects and modify the properties of specified objects.

To implement attribute collection, the required class library includes com.supermap.data.jar, com.supermap.mapping.jar, so library includes libimb2d.so, libgnustl_shared.s O, libQt5Core.so, libQt5Gui.so, libQt5Svg.so, libQt5Widgets.so.

The key categories and methods are as follows:

Class Method
DatasetVector getDataset()、query()
Recordset edit()、setFieldValue()、update()

Add attributes

Step 1: Query the object according to the object ID

DatasetVector datasetVector = (DatasetVector)mCurLayer.getDataset(); 
Int[] ids = { mCurID }; 
Recordset recordset = datasetVector.query(ids,CursorType.DYNAMIC);

Step 2: Add attributes

recordset.moveFirst();	 // Make the first record the current record 
Recordset.edit();		 // Lock and edit the current record 
recordset.setFieldValue("name", name);//Set the field value according to the field name 
recordset.setFieldValue("type", type");// Set the field value according to the field name 
Recordset.update();	 //Submit modifications 
Recordset.dispose();	 //Release occupied resources

Modify attributes

Step 1: Select objects and query attributes

Selection selection = layer.getSelection();	 //Get the selection set object in the layer

Step 2: Modify attributes

if (selection.getCount() > 0) { 
  Recordet recordset = selection.toRecordset();//Select set object to record set 
  recordset.moveFirst();	 // Make the first record the current record 
  Recordset.edit();		 // Lock and edit the current record 
  recordset.setFieldValue(“name”, string);// Set the field value according to the field name 
  Recordset.update();	 //Submit modifications 
  Recordset.dispose();	 // Release the occupied resources 
}