Package org.mapfish.print.map

Examples of org.mapfish.print.map.Scale


        }

        @Nonnull
        @Override
        protected ReferencedEnvelope getTileCacheBounds() {
            double scaleDenominator = new Scale(this.matrix.scaleDenominator).toResolution(this.bounds.getProjection(), getLayerDpi());
            double minX = this.matrix.topLeftCorner[0];
            double minY = this.matrix.topLeftCorner[1] - (this.matrix.getTileHeight() * this.matrix.matrixSize[1] * scaleDenominator);
            double maxX = this.matrix.topLeftCorner[0] + (this.matrix.getTileWidth() * this.matrix.matrixSize[0] * scaleDenominator);
            double maxY = this.matrix.topLeftCorner[1];
            return new ReferencedEnvelope(minX, maxX, minY, maxY, bounds.getProjection());
View Full Code Here


            //no common params for this protocol.
        }

        @Override
        public Scale getScale() {
            return new Scale(this.matrix.scaleDenominator);
        }
View Full Code Here

    private Style parseStyle(String styleJsonFileName) throws Throwable {
        Configuration config = new Configuration();
        config.setConfigurationFile(getFile(styleJsonFileName));
        final String styleJson = getSpec(styleJsonFileName);

        final CenterScaleMapBounds bounds = new CenterScaleMapBounds(CRS.decode("CRS:84"), 0, 0, new Scale(300000));
        MapfishMapContext context = new MapfishMapContext(bounds, new Dimension(500, 500), 0, 72, Constants.PDF_DPI, null, true);
        final Optional<Style> styleOptional = mapfishJsonStyleParserPlugin.parseStyle(config, httpClient, styleJson, context);

        assertTrue(styleOptional.isPresent());
View Full Code Here

        public ZoomLevels getZoomLevels() {
            return this.zoomLevels;
        }

        public Scale getScale() {
            return new Scale(this.zoomLevels.get(this.zoomLevel));
        }
View Full Code Here

            }
            MapBounds bounds;
            if (this.center != null) {
                double centerX = this.center[0];
                double centerY = this.center[1];
                Scale scaleObject = new Scale(this.scale);

                bounds = new CenterScaleMapBounds(crs, centerX, centerY, scaleObject);
            } else if (this.bbox != null) {
                final int maxYIndex = 3;
                double minX = this.bbox[0];
View Full Code Here

    @Override
    public MapBounds adjustBoundsToNearestScale(final ZoomLevels zoomLevels, final double tolerance,
                                                final ZoomLevelSnapStrategy zoomLevelSnapStrategy, final Rectangle paintArea,
                                                final double dpi) {
        final Scale scale = getScaleDenominator(paintArea, dpi);
        final ZoomLevelSnapStrategy.SearchResult result = zoomLevelSnapStrategy.search(scale, tolerance, zoomLevels);
        Coordinate center = this.bbox.centre();


        return new CenterScaleMapBounds(getProjection(), center.x, center.y, result.getScale());
View Full Code Here

            // (scale * width ) / dpi = geowidith
            geoWidthInInches = projUnit.convertTo(bboxAdjustedToScreen.getWidth(), DistanceUnit.IN);
        }

        double scale = geoWidthInInches * (dpi / paintArea.getWidth());
        return new Scale(scale);
    }
View Full Code Here

        assertRoundedScale(1234229, 1200000);
        assertRoundedScale(12342290, 12000000);
    }

    private void assertRoundedScale(double actualScale, double roundedScale) {
        MapBounds bounds = new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 0, 0, new Scale(actualScale));
        Dimension paint = new Dimension(200, 200);
        MapfishMapContext transformer = new MapfishMapContext(bounds, paint, 90, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
        assertEquals(roundedScale, transformer.getRoundedScale(), 0.00001);
    }
View Full Code Here

        assertEquals(0.707106, rotatedEnvelope.getMaxY(), 1e-6);
    }

    @Test
    public void testGetRotatedBounds_CenterScaleMapBounds() {
        MapBounds bounds = new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 0, 0, new Scale(1000));
        MapfishMapContext transformer = new MapfishMapContext(bounds, null, 90, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
        // nothing changes
        assertEquals(bounds, transformer.getRotatedBounds());
    }
View Full Code Here

        double dpi = 100;
        Rectangle screen = new Rectangle(100, 100);
        ZoomLevels zoomLevels = new ZoomLevels(15000, 20000, 25000, 30000, 350000);


        final CenterScaleMapBounds mapBounds = new CenterScaleMapBounds(CH1903, 50000, 50000, new Scale(scale));
        final ReferencedEnvelope originalBBox = mapBounds.toReferencedEnvelope(screen, dpi);

        BBoxMapBounds linear = new BBoxMapBounds(CH1903, originalBBox.getMinX(), originalBBox.getMinY(),
                originalBBox.getMaxX(), originalBBox.getMaxY());

        final MapBounds newMapBounds = linear.adjustBoundsToNearestScale(zoomLevels, 0.05,
                ZoomLevelSnapStrategy.CLOSEST_LOWER_SCALE_ON_TIE, screen, dpi);
        ReferencedEnvelope newBBox = newMapBounds.toReferencedEnvelope(screen, dpi);

        final double delta = 0.00001;
        assertEquals(originalBBox.getMedian(0), newBBox.getMedian(0), delta);
        assertEquals(originalBBox.getMedian(1), newBBox.getMedian(1), delta);

        double expectedScale = 25000;
        CenterScaleMapBounds expectedMapBounds = new CenterScaleMapBounds(CH1903, originalBBox.centre().x, originalBBox.centre().y,
                new Scale(expectedScale));
        assertEquals(expectedMapBounds.toReferencedEnvelope(screen, dpi), newBBox);
    }
View Full Code Here

TOP

Related Classes of org.mapfish.print.map.Scale

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.