class GeoPackageGeometryBuilder {

    public List<AbstractTileGeometry<?>> buildGeometries(GeoPackageTileLayer layer, long zoomLevel, TileRenderProperties props,
            Divider<GeographicPosition> divider)
    {
        List<AbstractTileGeometry<?>> geometries = Collections.synchronizedList(New.list());

        String terrainExtension = layer.getExtensions().get(Constants.TERRAIN_EXTENSION);

        GeoPackageQueryTracker tracker = new GeoPackageQueryTracker(myUIRegistry, layer.getName());
        List<GeoPackageTile> tiles = getTiles(layer, zoomLevel);
        for (GeoPackageTile tile : tiles)
        {
            if (StringUtils.isEmpty(terrainExtension))
            {
                TileGeometry.Builder<GeographicPosition> tileBuilder = new TileGeometry.Builder<GeographicPosition>();
                tileBuilder.setMinimumDisplaySize(384);
                tileBuilder.setMaximumDisplaySize(1280);
                tileBuilder.setRapidUpdate(true);
                setCommon(layer, tile, tileBuilder, divider, tracker);

                geometries.add(new TileGeometry(tileBuilder, props, null, layer.getId()));
            }
            else
            {
                TerrainTileGeometry.Builder<GeographicPosition> tileBuilder = new TerrainTileGeometry.Builder<GeographicPosition>();
                tileBuilder.setMinimumDisplaySize(50);
                tileBuilder.setMaximumDisplaySize(250);
                setCommon(layer, tile, tileBuilder, divider, tracker);

                ElevationImageReader elevationReader = null;
                ServiceLoader<ElevationImageReader> loader = ServiceLoader.load(ElevationImageReader.class);
                for (ElevationImageReader reader : loader)
                {
                    if (terrainExtension.equals(reader.getImageFormat()))
                    {
                        elevationReader = reader;
                        elevationReader.init(tile.getBoundingBox(), -Short.MIN_VALUE, "EPSG:4326", layer.getId());
                        break;
                    }
                }

                if (elevationReader != null)
                {
                    tileBuilder.setElevationReader(elevationReader);
                    geometries.add(new TerrainTileGeometry(tileBuilder, props, layer.getId()));
                }
                else
                {
                    LOGGER.warn("Could not load terrain for " + layer.getName() + " could not find elevation reader for format "
                            + terrainExtension);
                }
            }
        }

        return geometries;
    }

    public  GeoPackageGeometryBuilder(DataRegistry registry, UIRegistry uiRegistry);

}