mgrs-ios 1.1.6 Documentation

Class Grid​Utils

public class GridUtils  
  • Grid utilities

Methods

pixel(_:​_:​_:​_:​)

public static func pixel(_ width: Int, _ height: Int, _ bounds: Bounds, _ point: GridPoint) -> Pixel  
  • Get the pixel where the point fits into the bounds
  • @param width
  •        width
    
  • @param height
  •        height
    
  • @param bounds
  •        bounds
    
  • @param point
  •        point
    
  • @return pixel

xPixel(_:​_:​_:​)

public static func xPixel(_ width: Int, _ bounds: Bounds, _ longitude: Double) -> Float  
  • Get the X pixel for where the longitude in meters fits into the bounds
  • @param width
  •        width
    
  • @param bounds
  •        bounds
    
  • @param longitude
  •        longitude in meters
    
  • @return x pixel

yPixel(_:​_:​_:​)

public static func yPixel(_ height: Int, _ bounds: Bounds, _ latitude: Double) -> Float  
  • Get the Y pixel for where the latitude in meters fits into the bounds
  • @param height
  •        height
    
  • @param bounds
  •        bounds
    
  • @param latitude
  •        latitude
    
  • @return y pixel

bounds(_:​_:​_:​)

public static func bounds(_ x: Int, _ y: Int, _ zoom: Int) -> Bounds  
  • Get the tile bounds from the XYZ tile coordinates and zoom level
  • @param x
  •        x coordinate
    
  • @param y
  •        y coordinate
    
  • @param zoom
  •        zoom level
    
  • @return bounds

tiles​Per​Side(_:​)

public static func tilesPerSide(_ zoom: Int) -> Int  
  • Get the tiles per side, width and height, at the zoom level
  • @param zoom
  •        zoom level
    
  • @return tiles per side

tile​Size(_:​)

public static func tileSize(_ tilesPerSide: Int) -> Double  
  • Get the tile size in meters
  • @param tilesPerSide
  •        tiles per side
    
  • @return tile size

zoom​Level(_:​)

public static func zoomLevel(_ bounds: Bounds) -> Double  
  • Get the zoom level of the bounds using the shortest bounds side length
  • @param bounds
  •        bounds
    
  • @return zoom level

to​Unit(_:​_:​_:​_:​)

public static func toUnit(_ fromUnit: Unit, _ longitude: Double, _ latitude: Double, _ toUnit: Unit) -> GridPoint  
  • Convert a coordinate from a unit to another unit
  • @param fromUnit
  •        unit of provided coordinate
    
  • @param longitude
  •        longitude
    
  • @param latitude
  •        latitude
    
  • @param toUnit
  •        desired unit
    
  • @return point in unit

to​Unit(_:​_:​_:​)

public static func toUnit(_ longitude: Double, _ latitude: Double,
                              _ unit: Unit) -> GridPoint  
  • Convert a coordinate to the unit, assumes the coordinate is in the
  • opposite unit
  • @param longitude
  •        longitude
    
  • @param latitude
  •        latitude
    
  • @param unit
  •        desired unit
    
  • @return point in unit

is​Omitted​Band​Letter(_:​)

public static func isOmittedBandLetter(_ letter: Character) -> Bool  
  • Is the band letter an omitted letter
  • GridConstants.BAND_LETTER_OMIT_I or
  • GridConstants.BAND_LETTER_OMIT_O
  • @param letter
  •        band letter
    
  • @return true if omitted

precision​Before(_:​_:​)

public static func precisionBefore(_ value: Double, _ precision: Double) -> Double  
  • Get the precision value before the value
  • @param value
  •        value
    
  • @param precision
  •        precision
    
  • @return precision value

precision​After(_:​_:​)

public static func precisionAfter(_ value: Double, _ precision: Double) -> Double  
  • Get the precision value after the value
  • @param value
  •        value
    
  • @param precision
  •        precision
    
  • @return precision value

intersection(_:​_:​)

public static func intersection(_ line1: Line, _ line2: Line) -> GridPoint?  
  • Get the point intersection between two lines
  • @param line1
  •        first line
    
  • @param line2
  •        second line
    
  • @return intersection point or null if no intersection

intersection(_:​_:​_:​_:​)

public static func intersection(_ line1Point1: GridPoint, _ line1Point2: GridPoint, _ line2Point1: GridPoint, _ line2Point2: GridPoint) -> GridPoint?  
  • Get the point intersection between end points of two lines
  • @param line1Point1
  •        first point of the first line
    
  • @param line1Point2
  •        second point of the first line
    
  • @param line2Point1
  •        first point of the second line
    
  • @param line2Point2
  •        second point of the second line
    
  • @return intersection point or null if no intersection

increment​Character(_:​)

public static func incrementCharacter(_ character: Character) -> Character  
  • Increment the ASCII character by one
  • @param character
  •        starting character
    
  • @return next character

decrement​Character(_:​)

public static func decrementCharacter(_ character: Character) -> Character  
  • Decrement the ASCII character by one
  • @param character
  •        starting character
    
  • @return previous character

increment​Character(_:​_:​)

public static func incrementCharacter(_ character: Character, _ increment: Int) -> Character  
  • Increment the ASCII character
  • @param character
  •        starting character
    
  • @param increment
  •        ASCII increment, positive or negative for decrement
    
  • @return incremented character

char​At(_:​_:​)

public static func charAt(_ value: String, _ index: Int) -> Character  
  • Get the character at the index in a string
  • @param value
  •        string value
    
  • @param index
  •        character index
    
  • @return character at index

index​Of(_:​_:​)

public static func indexOf(_ value: String, _ char: Character) -> Int  
  • Get the first index of the character in the string, or -1 if not contained
  • @param value
  •        string value
    
  • @param char
  •        character
    
  • @return index of character or -1

substring(_:​_:​_:​)

public static func substring(_ value: String, _ beginIndex: Int, _ endIndex: Int) -> String  
  • Get a substring of the string value from the inclusive begin index to the exclusive end index
  • @param value
  •        string value
    
  • @param beginIndex
  •        begin index, inclusive
    
  • @param endIndex
  •        end index, exclusive
    
  • @return substring as a string

substring(_:​_:​)

public static func substring(_ value: String, _ beginIndex: Int) -> String  
  • Get a substring of the string value from the inclusive begin index to the end
  • @param value
  •        string value
    
  • @param beginIndex
  •        begin index, inclusive
    
  • @return substring as a string