写入时空对象

更新时间: 2021-04-07 15:31:26

在索引表创建完成、时空对象创建完成后,即可调用数据写入接口将数据写入到Lindorm Ganos中。

单条记录写入

Lindorm Ganos通过GeoTools API中的SimpleFeatureWriter写入单条数据,SimpleFeatureWriter支持事务,可以通过DataStore的getFeatureWriterAppend方法获取。

SimpleFeatureType sft = ....;
SimpleFeatureWriter writer=(SimpleFeatureWriter)ds.getFeatureWriterAppend(sft.getTypeName(), Transaction.AUTO_COMMIT);
SimpleFeature toWrite=writer.next();
toWrite.setAttributes(feature.getAttributes());
toWrite.getUserData().putAll(feature.getUserData());
writer.write();
writer.close();

批量写入

Lindorm Ganos支持批量插入SimpleFeature,通过GeoTools API中的SimpleFeatureStore类实现:

List<SimpleFeature> features=...
SimpleFeatureStore featureStore = (SimpleFeatureStore) ds.getFeatureSource(sft.getTypeName());
List<FeatureId> featureIds = featureStore.addFeatures(new ListFeatureCollection(sft,features));

可参考「快速入门」章节中的代码示例

上一篇: 创建时空对象 下一篇: 查询时空对象
阿里云首页 云原生多模数据库 Lindorm 相关技术圈