use of net.geoprism.registry.query.graph.VertexSelectGeoObjectQuery in project geoprism-registry by terraframe.
the class GeoObjectAtTimeShapefileExporter method features.
public FeatureCollection<SimpleFeatureType, SimpleFeature> features(SimpleFeatureType featureType) {
final int BLOCK_SIZE = 2000;
List<SimpleFeature> features = new ArrayList<SimpleFeature>();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
VertexServerGeoObject prev = null;
do {
final VertexSelectGeoObjectQuery query = new VertexSelectGeoObjectQuery(type, this.date, prev);
query.setLimit(BLOCK_SIZE);
final List<VertexServerGeoObject> objects = query.getResults();
prev = null;
for (VertexServerGeoObject object : objects) {
if (!object.getInvalid()) {
builder.set(GEOM, object.getGeometry());
this.attributes.forEach(attribute -> {
String name = attribute.getName();
String columnName = this.getColumnName(name);
Object value = attribute.isChangeOverTime() ? object.getValue(name, this.date) : object.getValue(name);
if (attribute instanceof AttributeTermType) {
builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeTermType) attribute, value));
} else if (attribute instanceof AttributeClassificationType) {
builder.set(columnName, GeoObjectUtil.convertToTermString((AttributeClassificationType) attribute, value));
} else if (attribute instanceof AttributeLocalType) {
builder.set(columnName, ((LocalizedValue) value).getValue());
} else {
builder.set(columnName, value);
}
});
AttributeType attribute = this.getType().getAttribute(DefaultAttribute.DISPLAY_LABEL.getName()).get();
LocalizedValue label = object.getDisplayLabel(this.date);
builder.set(this.getColumnName(attribute.getName() + " " + MdAttributeLocalInfo.DEFAULT_LOCALE), label.getValue(LocalizedValue.DEFAULT_LOCALE));
for (Locale locale : locales) {
builder.set(this.getColumnName(attribute.getName() + " " + locale.toString()), label.getValue(locale));
}
SimpleFeature feature = builder.buildFeature(object.getCode());
features.add(feature);
}
prev = object;
Thread.yield();
}
} while (prev != null);
return new ListFeatureCollection(featureType, features);
}
Aggregations