All Products
Search
Document Center

Delete spatio-temporal objects

Last Updated: Jul 09, 2021

In most scenarios, trajectory data is appended to a database. In some scenarios, spatio-temporal objects need to be deleted. You can use Lindorm Ganos to delete spatio-temporal objects by time period, time range, and spatio-temporal object ID.

In Lindorm Ganos, you can use Lindorm Time to Live (TTL) to delete expired data. You can modify the TTL attribute of the spatio-temporal table in the Lindorm shell to delete expired data. If multiple collections are established, you must perform this operation on each collection.

For example, if the spatio-temporal collection xxx_z3 and the attribute collection xxx_attr already exist and are used to delete the data that was generated 5 minutes ago in the d column, you must execute the following statement:

Alter 'xxx_z3',{NAME=>'d',TTL=>300}
Alter 'xxx_attr',{NAME=>'d',TTL=>300}

Delete spatio-temporal objects based on the spatio-temporal range

If you delete spatio-temporal objects based on the spatio-temporal range, the two space-time collections z2/xz2 and z3/xz3 can be deleted. Other collections cannot be deleted by using this method. If an attribute collection exists, the data in spatio-temporal collections may be inconsistent with the data in the attribute collection. When only spatio-temporal tables are available, we recommend that you use this method to delete spatio-temporal objects.

Procedure

  • Configure a filter. You can use a filter to filter the objects that you want to delete. This filter is configured in the same way as the filter that is used for query.

  • Use the SimpleFeatureStore.removerFeatures API of GeoTools to delete the objects that trigger the filter.

/**
 * Delete the data that triggers the filter.
 * @param schema: the schema name.
 * @param filterString: the filter string. The string must comply with the Extended Common Query Language (ECQL) syntax.
 * @throws Exception
 */
public void removeByFilter(String schema, String filterString) throws Exception {
    SimpleFeatureStore fs = (SimpleFeatureStore) ds.getFeatureSource(schema);
    // If filterString is left empty, all the spatio-temporal objects are deleted.
    if (StringUtils.isEmpty(filterString)){
        fs.removeFeatures(Filter.INCLUDE);
        return;
    }
    Filter filterToDelete = ECQL.toFilter(filterString);
    fs.removeFeatures(filterToDelete);
}

Delete spatio-temporal objects by spatial object ID

If you delete spatio-temporal objects by spatial object ID, the data in ID collections is deleted. Other collections cannot be deleted by using this method. If only one ID collection is available, you can use this method to delete spatio-temporal data.

Procedure:

Use the SimpleFeatureStore.removerFeatures API of GeoTools to delete the objects that match the specified ID.

public void removeById(String schema,String simpleFeatureId) throws Exception{
    // The filter is configured by using FilterFactory2.
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2
    Filter filterToDelete = ff.id(ff.featureId(simpleFeatureId))
    SimpleFeatureStore fs = ds.getFeatureSource(schema);
    fs.removeFeatures(filterToDelete);
}