11package org .mapfish .print .map ;
22
33import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .assertTrue ;
54import static org .mapfish .print .Constants .PDF_DPI ;
65
76import org .geotools .api .referencing .FactoryException ;
1312public class ScaleTest {
1413 public static final CoordinateReferenceSystem SPHERICAL_MERCATOR ;
1514 public static final CoordinateReferenceSystem CH1903 ;
15+ public static final CoordinateReferenceSystem CH2056 ;
1616 private static final double DELTA = 0.00001 ;
1717 private static final double SCALE = 108335.72891406555 ;
1818 private static final double RESOLUTION = 38.21843770023979 ;
@@ -21,6 +21,7 @@ public class ScaleTest {
2121 try {
2222 SPHERICAL_MERCATOR = CRS .decode ("EPSG:3857" );
2323 CH1903 = CRS .decode ("EPSG:21781" );
24+ CH2056 = CRS .decode ("EPSG:2056" );
2425 } catch (FactoryException e ) {
2526 throw new RuntimeException (e );
2627 }
@@ -50,31 +51,22 @@ public void geodetic() {
5051 }
5152
5253 @ Test
53- public void geodeticCH1903XPositionDependence () {
54+ public void geodeticCH2056XPositionDependence () {
5455 // This test verifies that the geodetic scale calculation correctly uses position.x
55- // for the horizontal coordinate. In projections like CH1903 (Swiss Oblique Mercator)
56+ // for the horizontal coordinate. In projections like CH2056 (Swiss Oblique Mercator)
5657 // or UTM, shifting a point in X direction while keeping Y constant affects the
5758 // geodetic distance, unlike EPSG:3857 where distortion is primarily latitude-dependent.
58- final Scale scale = new Scale (25000.0 , CH1903 , PDF_DPI );
59+ final Scale scale = new Scale (25000.0 , CH2056 , PDF_DPI );
5960
6061 // Calculate geodetic scale at two positions with same Y but different X
61- // Using coordinates in CH1903 CRS (EPSG:21781) for Switzerland
62- final Coordinate position1 = new Coordinate (600000 .0 , 200000 .0 );
63- final Coordinate position2 = new Coordinate (700000 .0 , 200000 .0 );
62+ // Using coordinates in CH2056 CRS (EPSG:2056)
63+ final Coordinate position1 = new Coordinate (2600000 .0 , 1200000 .0 );
64+ final Coordinate position2 = new Coordinate (2650000 .0 , 1299970 .0 );
6465
65- final double geodeticScale1 = scale .getGeodeticDenominator (CH1903 , PDF_DPI , position1 );
66- final double geodeticScale2 = scale .getGeodeticDenominator (CH1903 , PDF_DPI , position2 );
66+ final double geodeticScale1 = scale .getGeodeticDenominator (CH2056 , PDF_DPI , position1 );
67+ final double geodeticScale2 = scale .getGeodeticDenominator (CH2056 , PDF_DPI , position2 );
6768
68- // The geodetic scales should be different when X position changes
69- // If position.y was incorrectly used for both coordinates, they would be the same
70- // Allow a tolerance, but the difference should be noticeable
71- final double difference = Math .abs (geodeticScale1 - geodeticScale2 );
72- // Expecting at least 100 units difference in scale denominator for this shift
73- final String message =
74- String .format (
75- "Expected significant difference in geodetic scale when X changes "
76- + "(got %.2f vs %.2f, difference %.2f)" ,
77- geodeticScale1 , geodeticScale2 , difference );
78- assertTrue (message , difference > 100.0 );
69+ assertEquals (geodeticScale1 , 24997.0 , 1.0 );
70+ assertEquals (geodeticScale2 , 24993.0 , 1.0 );
7971 }
8072}
0 commit comments