RenderHelper { public static Pair<Envelope, DoublePair> getWorldToScreenTransform( AffineTransform worldToScreen, Envelope bbox, int width, int height ) { worldToScreen.scale( 1, -1 ); worldToScreen.translate( 0, -height ); final double scalex, scaley; final ICRS crs = bbox.getCoordinateSystem(); if ( isXyOrdered( crs ) ) { scalex = width / bbox.getSpan0(); scaley = height / bbox.getSpan1(); } else { worldToScreen.scale( -1, 1 ); worldToScreen.rotate( Math.PI / 2 ); scalex = height / bbox.getSpan0(); scaley = width / bbox.getSpan1(); } worldToScreen.scale( scalex, scaley ); worldToScreen.translate( -bbox.getMin().get0(), -bbox.getMin().get1() ); return new Pair<Envelope, DoublePair>( bbox, new DoublePair( scalex, scaley ) ); }  static void renderMark( Mark mark, int size, UOM uom, RendererContext context, double x, double y,
                                   double rotation ); static double calcScaleWMS111( int mapWidth, int mapHeight, Envelope bbox, ICRS crs ); static double calcScaleWMS130( int mapWidth, int mapHeight, Envelope bbox, ICRS crs, double pixelSize ); static double calcResolution( Envelope env, int width, int height ); static Pair<Envelope, DoublePair> getWorldToScreenTransform( AffineTransform worldToScreen, Envelope bbox,
                                                                        int width, int height );  }
@Test public void testWGS84ShortIdTransform() throws Exception { final double[] min = new double[] { 4.835947, 52.442229 }; final double[] max = new double[] { 4.871100, 52.453817 }; final AffineTransform worldToScreen = new AffineTransform(); final Envelope bbox = geometryFactory.createEnvelope( min, max, CRSManager.lookup( "EPSG:4326" ) ); RenderHelper.getWorldToScreenTransform( worldToScreen, bbox, 42, 47 ); final double[] transformedPoint = new double[2]; worldToScreen.transform( min, 0, transformedPoint, 0, 1 ); assertEquals( 0, transformedPoint[0], 0.1 ); assertEquals( 47, transformedPoint[1], 0.1 ); worldToScreen.transform( max, 0, transformedPoint, 0, 1 ); assertEquals( 42, transformedPoint[0], 0.1 ); assertEquals( 0, transformedPoint[1], 0.1 ); }
@Test public void testWGS84LongIdTransform() throws Exception { final double[] min = new double[] { 52.442229, 4.835947 }; final double[] max = new double[] { 52.453817, 4.871100 }; final AffineTransform worldToScreen = new AffineTransform(); final Envelope bbox = geometryFactory.createEnvelope( min, max, CRSManager.lookup( "urn:ogc:def:crs:EPSG::4326" ) ); RenderHelper.getWorldToScreenTransform( worldToScreen, bbox, 42, 47 ); final double[] transformedPoint = new double[2]; worldToScreen.transform( min, 0, transformedPoint, 0, 1 ); assertEquals( 0, transformedPoint[0], 0.1 ); assertEquals( 47, transformedPoint[1], 0.1 ); worldToScreen.transform( max, 0, transformedPoint, 0, 1 ); assertEquals( 42, transformedPoint[0], 0.1 ); assertEquals( 0, transformedPoint[1], 0.1 ); }