Search in sources :

Example 1 with AttributeIF

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();
    }
}
Also used : VectorLayerPublisherIF(net.geoprism.ontology.VectorLayerPublisherIF) TableEntity(net.geoprism.registry.TableEntity) IUserDataConverter(com.wdtinc.mapbox_vector_tile.adapt.jts.IUserDataConverter) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) IGeometryFilter(com.wdtinc.mapbox_vector_tile.adapt.jts.IGeometryFilter) JtsAdapter(com.wdtinc.mapbox_vector_tile.adapt.jts.JtsAdapter) ValueObject(com.runwaysdk.dataaccess.ValueObject) VectorTile(com.wdtinc.mapbox_vector_tile.VectorTile) MvtLayerBuild(com.wdtinc.mapbox_vector_tile.build.MvtLayerBuild) MvtLayerParams(com.wdtinc.mapbox_vector_tile.build.MvtLayerParams) PSQLException(org.postgresql.util.PSQLException) ValueQuery(com.runwaysdk.query.ValueQuery) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF) SQLException(java.sql.SQLException) DefaultAttribute(org.commongeoregistry.adapter.constants.DefaultAttribute) JSONException(org.json.JSONException) LocalizationFacade(com.runwaysdk.localization.LocalizationFacade) GeoEntity(com.runwaysdk.system.gis.geo.GeoEntity) ResultSet(java.sql.ResultSet) Locale(java.util.Locale) Map(java.util.Map) AttributeGeometryIF(com.runwaysdk.gis.dataaccess.AttributeGeometryIF) Tile(com.wdtinc.mapbox_vector_tile.VectorTile.Tile) Geometry(com.vividsolutions.jts.geom.Geometry) LinkedList(java.util.LinkedList) AttributeIF(com.runwaysdk.dataaccess.AttributeIF) Database(com.runwaysdk.dataaccess.database.Database) MasterListVersion(net.geoprism.registry.MasterListVersion) JtsGeometry(org.postgis.jts.JtsGeometry) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) Envelope(com.vividsolutions.jts.geom.Envelope) GeoserverFacade(com.runwaysdk.system.gis.mapping.GeoserverFacade) Collection(java.util.Collection) IOException(java.io.IOException) Layer(com.wdtinc.mapbox_vector_tile.VectorTile.Tile.Layer) RegistryConstants(net.geoprism.registry.RegistryConstants) TileGeomResult(com.wdtinc.mapbox_vector_tile.adapt.jts.TileGeomResult) UserDataConverter(net.geoprism.ontology.UserDataConverter) OIterator(com.runwaysdk.query.OIterator) List(java.util.List) TreeMap(java.util.TreeMap) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MvtLayerProps(com.wdtinc.mapbox_vector_tile.build.MvtLayerProps) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) IUserDataConverter(com.wdtinc.mapbox_vector_tile.adapt.jts.IUserDataConverter) IUserDataConverter(com.wdtinc.mapbox_vector_tile.adapt.jts.IUserDataConverter) UserDataConverter(net.geoprism.ontology.UserDataConverter) VectorTile(com.wdtinc.mapbox_vector_tile.VectorTile) Tile(com.wdtinc.mapbox_vector_tile.VectorTile.Tile) TileGeomResult(com.wdtinc.mapbox_vector_tile.adapt.jts.TileGeomResult) Layer(com.wdtinc.mapbox_vector_tile.VectorTile.Tile.Layer) LinkedList(java.util.LinkedList) AttributeGeometryIF(com.runwaysdk.gis.dataaccess.AttributeGeometryIF) Geometry(com.vividsolutions.jts.geom.Geometry) JtsGeometry(org.postgis.jts.JtsGeometry) Layer(com.wdtinc.mapbox_vector_tile.VectorTile.Tile.Layer) MvtLayerProps(com.wdtinc.mapbox_vector_tile.build.MvtLayerProps) VectorTile(com.wdtinc.mapbox_vector_tile.VectorTile) ValueObject(com.runwaysdk.dataaccess.ValueObject) MvtLayerParams(com.wdtinc.mapbox_vector_tile.build.MvtLayerParams) IGeometryFilter(com.wdtinc.mapbox_vector_tile.adapt.jts.IGeometryFilter)

Example 2 with AttributeIF

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;
}
Also used : AttributeIF(com.runwaysdk.dataaccess.AttributeIF) TreeMap(java.util.TreeMap)

Aggregations

AttributeIF (com.runwaysdk.dataaccess.AttributeIF)2 TreeMap (java.util.TreeMap)2 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)1 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 ValueObject (com.runwaysdk.dataaccess.ValueObject)1 Database (com.runwaysdk.dataaccess.database.Database)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 AttributeGeometryIF (com.runwaysdk.gis.dataaccess.AttributeGeometryIF)1 LocalizationFacade (com.runwaysdk.localization.LocalizationFacade)1 OIterator (com.runwaysdk.query.OIterator)1 ValueQuery (com.runwaysdk.query.ValueQuery)1 GeoEntity (com.runwaysdk.system.gis.geo.GeoEntity)1 GeoserverFacade (com.runwaysdk.system.gis.mapping.GeoserverFacade)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 VectorTile (com.wdtinc.mapbox_vector_tile.VectorTile)1 Tile (com.wdtinc.mapbox_vector_tile.VectorTile.Tile)1 Layer (com.wdtinc.mapbox_vector_tile.VectorTile.Tile.Layer)1