Home Return Compass Ordinal Abbreviation From A Direction

    Return Compass Ordinal Abbreviation From A Direction

    0

    This code will return a compass Intercardinal (or ordinal) direction based on a numeric direction. It supports the article here on returning a weather forecast with OpenWeatherMap. In some cases the cardinal directions or N, S, E, and W are suitable. Other times the 16 Intercardinal (NNE, NE, ENE etc.) are appropriate. We’re returning a more full set of 32 secondary-intercardinal directions for the sake of accuracy.

    By at least the middle of the eighteenth century the 32-point system had been further extended with the use of half- and quarter-points to give a total of 128 directions – this is well outside the comprehension of most people so we’ve avoided its use.

    32 Point Compass Rose

    A 32 Point Compass Rose. Source: WikiPedia.

    The 32 points on the compass rose are returned in our PHP code based upon the values from the following table on Wikipedia.

    32 Points of a Compass

    The 32 Points of a Compass. Source: WikiPedia.

    PHP Code

    When referenced by any of our shortcodes, the following should be copied into your custom functions file along with the shortcode function.

    We’ll likely update this post soon with a function to return just the 16-point Intercardinals. The following function returns the 16-point cardinal.

    Shortt URL for this post: http://shor.tt/1XHx