Package org.mapfish.print.map

Examples of org.mapfish.print.map.Scale


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


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

        BBoxMapBounds linear = new BBoxMapBounds(WGS84, 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(WGS84, originalBBox.centre().x, originalBBox.centre().y,
                new Scale(expectedScale));
        assertEquals(expectedMapBounds.toReferencedEnvelope(screen, dpi), newBBox);
    }
View Full Code Here


        }
    }

    @Test
    public void testToReferencedEnvelopeCH1903Projection() throws Exception {
        final Scale startScale = new Scale(18984.396150703426);
        final CenterScaleMapBounds bounds = new CenterScaleMapBounds(CH1903, 659596.5, 185610.5, startScale);
        final Rectangle paintArea = new Rectangle(521, 330);
        final ReferencedEnvelope envelope = bounds.toReferencedEnvelope(paintArea, OPENLAYERS_2_DPI);

        // It would be nice to nail this down in the future to the exact value but the method I used for measurement was openlayers and
View Full Code Here

        assertEquals(CH1903, envelope.getCoordinateReferenceSystem());
    }

    @Test
    public void testToReferencedEnvelopeLambertProjection() throws Exception {
        final Scale startScale = new Scale(17983.582534790035);
        final CenterScaleMapBounds bounds = new CenterScaleMapBounds(LAMBERT, 445000, 6355000, startScale);
        final Rectangle paintArea = new Rectangle(418, 512);
        final ReferencedEnvelope envelope = bounds.toReferencedEnvelope(paintArea, OPENLAYERS_2_DPI);

        // It would be nice to nail this down in the future to the exact value but the method I used for measurement was openlayers and
View Full Code Here

        assertEquals(LAMBERT, envelope.getCoordinateReferenceSystem());
    }

    @Test
    public void testToReferencedEnvelopeLatLong() throws Exception {
        final Scale startScale = new Scale(56304.83087498591);
        final CenterScaleMapBounds bounds = new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 8.2335427805083, 46.801424340241,
                startScale);
        final Rectangle paintArea = new Rectangle(521, 330);
        final ReferencedEnvelope envelope = bounds.toReferencedEnvelope(paintArea, OPENLAYERS_2_DPI);
View Full Code Here

        assertEquals(DefaultGeographicCRS.WGS84, envelope.getCoordinateReferenceSystem());
    }

    @Test
    public void testZoomOut() throws Exception {
        final Scale scale = new Scale(2500.0);
        final CenterScaleMapBounds bounds = new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 0.0, 0.0, scale);
        final Rectangle paintArea = new Rectangle(400, 200);
        final ReferencedEnvelope envelope = bounds.toReferencedEnvelope(paintArea, OPENLAYERS_2_DPI);
       
        CenterScaleMapBounds newBounds = bounds.zoomOut(1);
View Full Code Here

    private static final ZoomLevelSnapStrategy.SearchResult SCALE_12_RESULT = new ZoomLevelSnapStrategy.SearchResult(2, ZOOM_LEVELS);
    private static final ZoomLevelSnapStrategy.SearchResult SCALE_16_RESULT = new ZoomLevelSnapStrategy.SearchResult(1, ZOOM_LEVELS);

    @Test
    public void testSearchCLOSEST_LOWER_SCALE_ON_MATCHMatch() throws Exception {
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(12), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(12.01), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(12.5), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(10), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(13), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(11.88), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(11), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }
View Full Code Here

        assertEquals(SCALE_8_RESULT, CLOSEST_LOWER_SCALE_ON_TIE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }

    @Test
    public void testSearchCLOSEST_HIGHER_SCALE_ON_MATCHMatch() throws Exception {
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(12), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(12.01), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(12.5), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(10), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(13), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(11.88), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(11), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }
View Full Code Here

        assertEquals(SCALE_8_RESULT, CLOSEST_HIGHER_SCALE_ON_TIE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }

    @Test
    public void testSearchNextHighest() throws Exception {
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(12), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(12.01), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(12.5), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(10), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_16_RESULT, HIGHER_SCALE.search(new Scale(13), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(11.88), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(11), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }
View Full Code Here

        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(11), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, HIGHER_SCALE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }
    @Test
    public void testSearchLower() throws Exception {
        assertEquals(SCALE_12_RESULT, LOWER_SCALE.search(new Scale(12), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, LOWER_SCALE.search(new Scale(12.01), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, LOWER_SCALE.search(new Scale(12.5), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, LOWER_SCALE.search(new Scale(10), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, LOWER_SCALE.search(new Scale(13), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_12_RESULT, LOWER_SCALE.search(new Scale(11.88), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, LOWER_SCALE.search(new Scale(11), TOLERANCE, ZOOM_LEVELS));
        assertEquals(SCALE_8_RESULT, LOWER_SCALE.search(new Scale(9), TOLERANCE, ZOOM_LEVELS));
    }
View Full Code Here

        if (factor == 1.0) {
            return this;
        }

        final double newDenominator = this.scale.getDenominator() * factor;
        return new CenterScaleMapBounds(getProjection(), this.center.x, this.center.y, new Scale(newDenominator));
    }
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.