Class
GridUtils
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
tilesPerSide(_:)
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
tileSize(_:)
public static func tileSize(_ tilesPerSide: Int) -> Double
- Get the tile size in meters
- @param tilesPerSide
-
tiles per side
- @return tile size
zoomLevel(_:)
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
toUnit(_:_:_:_:)
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
toUnit(_:_:_:)
- 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
isOmittedBandLetter(_:)
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
precisionBefore(_:_:)
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
precisionAfter(_:_:)
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(_:_:)
- 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
incrementCharacter(_:)
public static func incrementCharacter(_ character: Character) -> Character
- Increment the ASCII character by one
- @param character
-
starting character
- @return next character
decrementCharacter(_:)
public static func decrementCharacter(_ character: Character) -> Character
- Decrement the ASCII character by one
- @param character
-
starting character
- @return previous character
incrementCharacter(_:_:)
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
charAt(_:_:)
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
indexOf(_:_:)
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