Class TransformationUtils


  • public class TransformationUtils
    extends Object
    Utils to do transformations.
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.locationtech.jts.geom.Envelope expandToFitRatio​(org.locationtech.jts.geom.Envelope original, double width, double height)
      Extend an envelope to have the same ratio as the given width and height.
      static AffineTransform getPixelToWorld​(Rectangle pixelRectangle, org.locationtech.jts.geom.Envelope worldEnvelope)  
      static org.locationtech.jts.geom.util.AffineTransformation getRectangleToWorld​(Rectangle pixelRectangle, org.locationtech.jts.geom.Envelope worldEnvelope)  
      static AffineTransform getWorldToPixel​(org.locationtech.jts.geom.Envelope worldEnvelope, Rectangle pixelRectangle)
      Get the affine transform that brings from the world envelope to the rectangle.
      static org.locationtech.jts.geom.util.AffineTransformation getWorldToRectangle​(org.locationtech.jts.geom.Envelope worldEnvelope, Rectangle pixelRectangle)
      Get the affine transform that brings from the world envelope to the rectangle.
      static org.locationtech.jts.geom.Envelope scaleToHeight​(org.locationtech.jts.geom.Envelope original, double newHeight)
      Scale an envelope to have a given height.
      static org.locationtech.jts.geom.Envelope scaleToWidth​(org.locationtech.jts.geom.Envelope original, double newWidth)
      Scale an envelope to have a given width.
      static org.locationtech.jts.geom.Coordinate transformCoordinate​(AffineTransform transformation, org.locationtech.jts.geom.Coordinate coordinate)  
      static org.locationtech.jts.geom.Envelope transformEnvelope​(AffineTransform transformation, org.locationtech.jts.geom.Envelope env)
      Given a transformation, transform an envelope by it.
      static org.locationtech.jts.geom.Envelope transformEnvelope​(org.locationtech.jts.geom.util.AffineTransformation transformation, org.locationtech.jts.geom.Envelope env)
      Given a transformation, transform an envelope by it.
    • Constructor Detail

      • TransformationUtils

        public TransformationUtils()
    • Method Detail

      • getWorldToPixel

        public static AffineTransform getWorldToPixel​(org.locationtech.jts.geom.Envelope worldEnvelope,
                                                      Rectangle pixelRectangle)
        Get the affine transform that brings from the world envelope to the rectangle.
        Parameters:
        worldEnvelope - the envelope.
        pixelRectangle - the destination rectangle.
        Returns:
        the transform.
      • getWorldToRectangle

        public static org.locationtech.jts.geom.util.AffineTransformation getWorldToRectangle​(org.locationtech.jts.geom.Envelope worldEnvelope,
                                                                                              Rectangle pixelRectangle)
        Get the affine transform that brings from the world envelope to the rectangle.
        Parameters:
        worldEnvelope - the envelope.
        pixelRectangle - the destination rectangle.
        Returns:
        the transform.
      • getRectangleToWorld

        public static org.locationtech.jts.geom.util.AffineTransformation getRectangleToWorld​(Rectangle pixelRectangle,
                                                                                              org.locationtech.jts.geom.Envelope worldEnvelope)
                                                                                       throws org.locationtech.jts.geom.util.NoninvertibleTransformationException
        Throws:
        org.locationtech.jts.geom.util.NoninvertibleTransformationException
      • scaleToWidth

        public static org.locationtech.jts.geom.Envelope scaleToWidth​(org.locationtech.jts.geom.Envelope original,
                                                                      double newWidth)
        Scale an envelope to have a given width.
        Parameters:
        original - the envelope.
        newWidth - the new width to use.
        Returns:
        the scaled envelope placed in the original lower left corner position.
      • scaleToHeight

        public static org.locationtech.jts.geom.Envelope scaleToHeight​(org.locationtech.jts.geom.Envelope original,
                                                                       double newHeight)
        Scale an envelope to have a given height.
        Parameters:
        original - the envelope.
        newHeight - the new height to use.
        Returns:
        the scaled envelope placed in the original lower left corner position.
      • expandToFitRatio

        public static org.locationtech.jts.geom.Envelope expandToFitRatio​(org.locationtech.jts.geom.Envelope original,
                                                                          double width,
                                                                          double height)
        Extend an envelope to have the same ratio as the given width and height.
        Parameters:
        original - the envelope.
        width - the reference width.
        height - the reference height.
        Returns:
        the extended envelope, centered on the original one.
      • transformEnvelope

        public static org.locationtech.jts.geom.Envelope transformEnvelope​(AffineTransform transformation,
                                                                           org.locationtech.jts.geom.Envelope env)
        Given a transformation, transform an envelope by it.
        Parameters:
        transformation - the AffineTransform to use.
        env - the envelope to transform.
        Returns:
        the transformed envelope.
      • transformCoordinate

        public static org.locationtech.jts.geom.Coordinate transformCoordinate​(AffineTransform transformation,
                                                                               org.locationtech.jts.geom.Coordinate coordinate)
      • transformEnvelope

        public static org.locationtech.jts.geom.Envelope transformEnvelope​(org.locationtech.jts.geom.util.AffineTransformation transformation,
                                                                           org.locationtech.jts.geom.Envelope env)
        Given a transformation, transform an envelope by it.
        Parameters:
        transformation - the AffineTransformation to use.
        env - the envelope to transform.
        Returns:
        the transformed envelope.