Package org.geotools.mbtiles

Examples of org.geotools.mbtiles.MBTilesMetadata


        mapContent.getRequest().getFormatOptions().put("max_zoom", "11");
       
        WebMap map = format.produceMap(mapContent);
        MBTilesFile mbtiles = createMbTilesFiles(map);
       
        MBTilesMetadata metadata = mbtiles.loadMetaData();
       
        assertEquals("World_Lakes", metadata.getName());
        assertEquals("0", metadata.getVersion());
        assertEquals("World, null", metadata.getDescription());
        assertEquals(-0.17578125, metadata.getBounds().getMinimum(0), 0.001);
        assertEquals(-0.087890625, metadata.getBounds().getMaximum(0), 0.001);
        assertEquals(0.17578125, metadata.getBounds().getMaximum(1), 0.001);
        assertEquals(0.087890625, metadata.getBounds().getMinimum(1), 0.001);
        assertEquals(MBTilesMetadata.t_type.OVERLAY, metadata.getType());
        assertEquals(MBTilesMetadata.t_format.PNG, metadata.getFormat());
       
        assertEquals(1, mbtiles.numberOfTiles());

        MBTilesFile.TileIterator tiles = mbtiles.tiles();
        assertTrue(tiles.hasNext());
View Full Code Here


        MBTilesFile mbtiles = new MBTilesFile(f);
        mbtiles.init();
        // Add tiles to the file(Internally uses the MBtilesFileWrapper)
        format.addTiles(mbtiles, mapContent.getRequest(), null);
        // Ensure everything is correct
        MBTilesMetadata metadata = mbtiles.loadMetaData();
       
        assertEquals("World_Lakes", metadata.getName());
        assertEquals("0", metadata.getVersion());
        assertEquals("World, null", metadata.getDescription());
        assertEquals(-0.17578125, metadata.getBounds().getMinimum(0), 0.001);
        assertEquals(-0.087890625, metadata.getBounds().getMaximum(0), 0.001);
        assertEquals(0.17578125, metadata.getBounds().getMaximum(1), 0.001);
        assertEquals(0.087890625, metadata.getBounds().getMinimum(1), 0.001);
        assertEquals(MBTilesMetadata.t_type.OVERLAY, metadata.getType());
        assertEquals(MBTilesMetadata.t_format.PNG, metadata.getFormat());
       
        assertEquals(1, mbtiles.numberOfTiles());

        MBTilesFile.TileIterator tiles = mbtiles.tiles();
        assertTrue(tiles.hasNext());
View Full Code Here

        // File file = getDataDirectory().findFile("data", "test.mbtiles");
        assertNotNull(file);
        assertTrue(file.exists());

        MBTilesFile mbtiles = new MBTilesFile(file);
        MBTilesMetadata metadata = mbtiles.loadMetaData();
        assertEquals(11, mbtiles.maxZoom());
        assertEquals(10, mbtiles.minZoom());
        assertEquals("World", metadata.getName());

        assertEquals(-0.17578125, metadata.getBounds().getMinimum(0), 0.0001);
        assertEquals(-0.087890625, metadata.getBounds().getMinimum(1), 0.0001);
        assertEquals(0.17578125, metadata.getBounds().getMaximum(0), 0.0001);
        assertEquals(0.087890625, metadata.getBounds().getMaximum(1), 0.0001);

        try {
            mbtiles.close();
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

        @Override
        public void setMetadata(String name, ReferencedEnvelope box, String imageFormat, int srid,
                List<MapLayerInfo> mapLayers, int[] minmax, GridSubset gridSubset)
                throws IOException, ServiceException {
            MBTilesMetadata metadata = new MBTilesMetadata();

            metadata.setName(name);
            metadata.setVersion("0");

            if (mapLayers.size() == 1) {
                ResourceInfo r = mapLayers.get(0).getResource();
                metadata.setDescription(r.getDescription());
                metadata.setType(MBTilesMetadata.t_type.BASE_LAYER);
            } else {
                String descr = "";
                for (MapLayerInfo l : mapLayers) {
                    descr += l.getResource().getDescription() + ", ";
                }
                descr = descr.substring(0, descr.length()-2);
                metadata.setDescription(descr);
                metadata.setType(MBTilesMetadata.t_type.OVERLAY);
            }

            try {
                metadata.setBounds(box.transform(WGS_84, true));
            } catch (Exception e) {
                LOGGER.log(Level.WARNING, "Failed to transform bounding box", e);
            }

            // save metadata
            metadata.setFormat(JPEG_MIME_TYPE.equals(imageFormat) ? MBTilesMetadata.t_format.JPEG
                    : MBTilesMetadata.t_format.PNG);
            LOGGER.fine("Creating tile entry" + metadata.getName());
            mbTiles.saveMetaData(metadata);
        }
View Full Code Here

TOP

Related Classes of org.geotools.mbtiles.MBTilesMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.