Package mil.nga.grid

Class GridUtils


  • public class GridUtils
    extends Object
    Grid utilities
    Author:
    osbornb
    • Constructor Detail

      • GridUtils

        public GridUtils()
    • Method Detail

      • getPixel

        public static Pixel getPixel​(int width,
                                     int height,
                                     Bounds bounds,
                                     Point point)
        Get the pixel where the point fits into the bounds
        Parameters:
        width - width
        height - height
        bounds - bounds
        point - point
        Returns:
        pixel
      • getXPixel

        public static float getXPixel​(int width,
                                      Bounds bounds,
                                      double longitude)
        Get the X pixel for where the longitude in meters fits into the bounds
        Parameters:
        width - width
        bounds - bounds
        longitude - longitude in meters
        Returns:
        x pixel
      • getYPixel

        public static float getYPixel​(int height,
                                      Bounds bounds,
                                      double latitude)
        Get the Y pixel for where the latitude in meters fits into the bounds
        Parameters:
        height - height
        bounds - bounds
        latitude - latitude
        Returns:
        y pixel
      • getBounds

        public static Bounds getBounds​(int x,
                                       int y,
                                       int zoom)
        Get the tile bounds from the XYZ tile coordinates and zoom level
        Parameters:
        x - x coordinate
        y - y coordinate
        zoom - zoom level
        Returns:
        bounds
      • tilesPerSide

        public static int tilesPerSide​(int zoom)
        Get the tiles per side, width and height, at the zoom level
        Parameters:
        zoom - zoom level
        Returns:
        tiles per side
      • tileSize

        public static double tileSize​(int tilesPerSide)
        Get the tile size in meters
        Parameters:
        tilesPerSide - tiles per side
        Returns:
        tile size
      • getZoomLevel

        public static double getZoomLevel​(Bounds bounds)
        Get the zoom level of the bounds using the shortest bounds side length
        Parameters:
        bounds - bounds
        Returns:
        zoom level
      • toUnit

        public static Point toUnit​(Unit fromUnit,
                                   double longitude,
                                   double latitude,
                                   Unit toUnit)
        Convert a coordinate from a unit to another unit
        Parameters:
        fromUnit - unit of provided coordinate
        longitude - longitude
        latitude - latitude
        toUnit - desired unit
        Returns:
        point in unit
      • toUnit

        public static Point toUnit​(double longitude,
                                   double latitude,
                                   Unit unit)
        Convert a coordinate to the unit, assumes the coordinate is in the opposite unit
        Parameters:
        longitude - longitude
        latitude - latitude
        unit - desired unit
        Returns:
        point in unit
      • precisionBefore

        public static double precisionBefore​(double value,
                                             double precision)
        Get the precision value before the value
        Parameters:
        value - value
        precision - precision
        Returns:
        precision value
      • precisionAfter

        public static double precisionAfter​(double value,
                                            double precision)
        Get the precision value after the value
        Parameters:
        value - value
        precision - precision
        Returns:
        precision value
      • intersection

        public static Point intersection​(Line line1,
                                         Line line2)
        Get the point intersection between two lines
        Parameters:
        line1 - first line
        line2 - second line
        Returns:
        intersection point or null if no intersection
      • intersection

        public static Point intersection​(Point line1Point1,
                                         Point line1Point2,
                                         Point line2Point1,
                                         Point line2Point2)
        Get the point intersection between end points of two lines
        Parameters:
        line1Point1 - first point of the first line
        line1Point2 - second point of the first line
        line2Point1 - first point of the second line
        line2Point2 - second point of the second line
        Returns:
        intersection point or null if no intersection