Class MercatorImage

  • All Implemented Interfaces:
    CoordinateTransformer


    public class MercatorImage
    extends Object
    implements CoordinateTransformer
    An image that shows a part of the world using Mercator projection. It is constructed from a defining bounding box and some pixel width and height. The MercatorImage is constructed such that the whole defining bounding box is visible within the image. That means that the image may actually represent a bigger bounding box than the one that was used at construction time. This is called the visible bounding box. The bounding box used for object creation is called the defining bounding box. The MercatorImage implements the CoordinateTransformer interface and thereby transforms lon/lat coordinates to pixel coordinates on the image.
    • Constructor Summary

      Constructors

      Constructor and Description
      MercatorImage(BBox bbox, int width, int height)
      Create a new MercatorImage with the given size and positional information.
      MercatorImage(double lon1, double lat1, double lon2, double lat2, int width, int height)
      Create a new MercatorImage with the given size and positional information.
    • Constructor Detail

      • MercatorImage

        public MercatorImage(BBox bbox,
                             int width,
                             int height)
        Create a new MercatorImage with the given size and positional information.
        Parameters:
        bbox - the bbox to cover.
        width - the width of the image.
        height - the height of the image.
      • MercatorImage

        public MercatorImage(double lon1,
                             double lat1,
                             double lon2,
                             double lat2,
                             int width,
                             int height)
        Create a new MercatorImage with the given size and positional information.
        Parameters:
        lon1 - leftmost longitude.
        lat1 - top latitude.
        lon2 - rightmost longitude.
        lat2 - bottom latitude.
        width - the width of the image in pixels.
        height - the height of the image in pixels.
    • Method Detail

      • getX

        public double getX(double lon)
      • getY

        public double getY(double lat)
      • getDefiningBoundingBox

        public BBox getDefiningBoundingBox()
        Get the bounding box that was used to create this image. Note that this may be different from the visible bounding box.
        Returns:
        the defining bounding box
      • getVisibleBoundingBox

        public BBox getVisibleBoundingBox()
        Get the bounding box that is really visible on the image. This box may differ from the input bounding box, because the image contains the whole input bounding box and may thus show an actual bounding box that is bigger.
        Returns:
        the visible bounding box
      • getWidth

        public int getWidth()
        Returns:
        the width of the image in pixels.
      • getHeight

        public int getHeight()
        Returns:
        the height of the image in pixels.
      • getLon1

        public double getLon1()
        Returns:
        the leftmost longitude of the defining bounding box.
      • getLat1

        public double getLat1()
        Returns:
        the top latitude of the defining bounding box.
      • getLon2

        public double getLon2()
        Returns:
        the rightmost longitude of the defining bounding box.
      • getLat2

        public double getLat2()
        Returns:
        the bottom latitude of the defining bounding box.
      • getImageSx

        public double getImageSx()
        The image shows a part of the whole world, which is projected onto a Mercator square whose size can be obtained using getWorldSize(). Get the relative position of the visible part of the image on this Mercator square in image space units.
        Returns:
        the x coordinate in image space where the specified leftmost coordinate is.
      • getImageSy

        public double getImageSy()
        The image shows a part of the whole world, which is projected onto a Mercator square whose size can be obtained using getWorldSize(). Get the relative position of the visible part of the image on this Mercator square in image space units.
        Returns:
        the y coordinate in image space where the specified top coordinate is.
      • getWorldSize

        public double getWorldSize()
        The image shows a part of the whole world which is projected onto a Mercator square, whose size can be obtained using this method.
        Returns:
        the internal scale used. This is equivalent to the Mercator worldsize, i.e. the size in pixels of an image that would show the whole world.