public Scale getNearestScale ( final ZoomLevels zoomLevels , final double tolerance , final ZoomLevelSnapStrategy zoomLevelSnapStrategy , final boolean geodetic , final Rectangle paintArea , final double dpi ) { final Scale scale = getScale ( paintArea , dpi ) ; final Scale correctedScale ; final double scaleRatio ; if ( geodetic ) { final double currentScaleDenominator = scale . getGeodeticDenominator ( getProjection ( ) , dpi , getCenter ( ) ) ; scaleRatio = scale . getDenominator ( dpi ) / currentScaleDenominator ; correctedScale = scale . toResolution ( scale . getResolution ( ) / scaleRatio ) ; } else { scaleRatio = 1 ; correctedScale = scale ; } DistanceUnit unit = DistanceUnit . fromProjection ( getProjection ( ) ) ; final ZoomLevelSnapStrategy . SearchResult result = zoomLevelSnapStrategy . search ( correctedScale , tolerance , zoomLevels ) ; final Scale newScale ; if ( geodetic ) { newScale = new Scale ( result . getScale ( unit ) . getDenominator ( PDF_DPI ) * scaleRatio , getProjection ( ) , dpi ) ; } else { newScale = result . getScale ( unit ) ; } return newScale ; }
Get the nearest scale .