use of com.runwaysdk.dataaccess.AttributeIF in project geoprism-registry by terraframe.
the class VectorTileBuilder method writeVectorTiles.
protected byte[] writeVectorTiles(String layerName, Envelope envelope, ValueQuery query) throws IOException {
OIterator<ValueObject> iterator = query.getIterator();
try {
List<Geometry> geometries = new LinkedList<Geometry>();
while (iterator.hasNext()) {
ValueObject object = iterator.next();
AttributeGeometryIF attributeIF = (AttributeGeometryIF) object.getAttributeIF(GeoserverFacade.GEOM_COLUMN);
Geometry geometry = attributeIF.getGeometry();
geometry.setUserData(this.getUserData(object));
geometries.add(geometry);
}
GeometryFactory geomFactory = new GeometryFactory();
IGeometryFilter acceptAllGeomFilter = geometry -> true;
MvtLayerParams layerParams = new MvtLayerParams();
TileGeomResult tileGeom = JtsAdapter.createTileGeom(geometries, envelope, geomFactory, layerParams, acceptAllGeomFilter);
final VectorTile.Tile.Builder tileBuilder = VectorTile.Tile.newBuilder();
// Create MVT layer
final MvtLayerProps layerProps = new MvtLayerProps();
final IUserDataConverter ignoreUserData = new UserDataConverter();
// MVT tile geometry to MVT features
final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(tileGeom.mvtGeoms, layerProps, ignoreUserData);
final VectorTile.Tile.Layer.Builder layerBuilder = MvtLayerBuild.newLayerBuilder(layerName, layerParams);
layerBuilder.addAllFeatures(features);
MvtLayerBuild.writeProps(layerBuilder, layerProps);
// Build MVT layer
final VectorTile.Tile.Layer layer = layerBuilder.build();
// Add built layer to MVT
tileBuilder.addLayers(layer);
// / Build MVT
Tile mvt = tileBuilder.build();
return mvt.toByteArray();
} finally {
iterator.close();
}
}
use of com.runwaysdk.dataaccess.AttributeIF in project geoprism-registry by terraframe.
the class VectorTileBuilder method getUserData.
protected Map<String, String> getUserData(ValueObject object) {
AttributeIF[] attributes = object.getAttributeArrayIF();
Map<String, String> data = new TreeMap<String, String>();
for (AttributeIF attribute : attributes) {
String name = attribute.getName();
if (!name.equals(GeoserverFacade.GEOM_COLUMN)) {
data.put(name, attribute.getValue());
}
}
return data;
}
Aggregations