写入时空对象
在索引表创建完成、时空对象创建完成后,即可调用数据写入接口将数据写入到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));
可参考「快速入门」章节中的代码示例