source: subversion/applications/lib/ccoord/OSRef.h @ 18255

Last change on this file since 18255 was 2197, checked in by nick, 13 years ago

Support for generating grid square letters added

File size: 1.6 KB
Line 
1#ifndef OSREF_H
2#define OSREF_H
3
4#include "RefEll.h"
5#include "LatLng.h"
6#include "util.h"
7#include <cmath>
8#include <string>
9
10// Based on Jonathan Stott's JCoord.
11// Licenced under the GNU GPL.
12
13/**
14 * Class to represent an Ordnance Survey grid reference
15 *
16 * (c) 2006 Jonathan Stott
17 *
18 * Created on 11-02-2006
19 *
20 * @author Jonathan Stott
21 * @version 1.0
22 * @since 1.0
23 */
24class OSRef {
25
26private:
27  /**
28   * Easting
29   */
30  double easting;
31
32  /**
33   * Northing
34   */
35  double northing;
36
37
38  /**
39   * Create a new Ordnance Survey grid reference.
40   *
41   * @param easting
42   *          the easting in metres
43   * @param northing
44   *          the northing in metres
45   * @since 1.0
46   */
47
48public:
49  OSRef(double easting, double northing) {
50    this->easting = easting;
51    this->northing = northing;
52  }
53
54
55  /**
56   * Convert this OSGB grid reference to a latitude/longitude pair using the
57   * OSGB36 datum. Note that, the LatLng object may need to be converted to the
58   * WGS84 datum depending on the application.
59   *
60   * @return a LatLng object representing this OSGB grid reference using the
61   *         OSGB36 datum
62   * @since 1.0
63   */
64  LatLng toLatLng(); 
65
66
67  /**
68   * Get the easting.
69   *
70   * @return the easting in metres
71   * @since 1.0
72   */
73   double getEasting() {
74    return easting;
75  }
76
77
78  /**
79   * Get the northing.
80   *
81   * @return the northing in metres
82   * @since 1.0
83   */
84  double getNorthing() {
85    return northing;
86  }
87
88  std::string toSixFigureString();
89
90  std::string getGridSquare()
91  {
92        return toSixFigureString().substr(0,2);
93  }
94};
95
96#endif
Note: See TracBrowser for help on using the repository browser.