public Coordinate viewToWorld ( Coordinate coordinate ) { if ( coordinate != null ) { Vector2D position = new Vector2D ( coordinate ) ; double inverseScale = 1 / mapView . getCurrentScale ( ) ; position . scale ( inverseScale , - inverseScale ) ; Bbox bounds = mapView . getBounds ( ) ; // -cam: center X axis around cam. +bbox.w/2: to place the origin in the center of the screen double translateX = - mapView . getViewState ( ) . getX ( ) + ( bounds . getWidth ( ) / 2 ) ; double translateY = - mapView . getViewState ( ) . getY ( ) - ( bounds . getHeight ( ) / 2 ) ; // Inverted Y-axis here... position . translate ( - translateX , - translateY ) ; // TODO: implement rotation support. return new Coordinate ( position . getX ( ) , position . getY ( ) ) ; } return null ; }
Transform a coordinate from view space to world space .