Class: NationalGrid::LatitudeLongitude

Inherits:
Object
  • Object
show all
Includes:
Inspect, Round
Defined in:
lib/national_grid/latitude_longitude.rb,
ext/national_grid/national_grid_latitude_longitude.c

Instance Method Summary collapse

Methods included from Round

#round

Methods included from Inspect

#inspect

Constructor Details

#initialize(*args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'ext/national_grid/national_grid_latitude_longitude.c', line 16

static VALUE initialize(int argc, VALUE* argv, VALUE self) {
  VALUE latitude, longitude, elevation;
  rb_scan_args(argc, argv, "03", &latitude, &longitude, &elevation);

  LatLonDecimal* data = latitude_longitude(self);
  data->lat = default_to_zero(latitude);
  data->lon = default_to_zero(longitude);
  data->elevation = default_to_zero(elevation);

  return self;
}

Instance Method Details

#elevationObject



36
37
38
# File 'ext/national_grid/national_grid_latitude_longitude.c', line 36

static VALUE elevation(VALUE self) {
  return DBL2NUM(latitude_longitude(self)->elevation);
}

#latitudeObject



28
29
30
# File 'ext/national_grid/national_grid_latitude_longitude.c', line 28

static VALUE latitude(VALUE self) {
  return DBL2NUM(latitude_longitude(self)->lat);
}

#longitudeObject



32
33
34
# File 'ext/national_grid/national_grid_latitude_longitude.c', line 32

static VALUE longitude(VALUE self) {
  return DBL2NUM(latitude_longitude(self)->lon);
}

#to_aObject



6
7
8
# File 'lib/national_grid/latitude_longitude.rb', line 6

def to_a
  [latitude, longitude, elevation]
end

#to_easting_northingObject



40
41
42
43
44
# File 'ext/national_grid/national_grid_latitude_longitude.c', line 40

static VALUE to_easting_northing(VALUE self) {
  EastingNorthing data = OSGB36EastingNorthingFromETRS89EastingNorthing(ETRS89EastingNorthingFromETRS89LatLon(*latitude_longitude(self)));
  if (data.geoid == 0) return Qnil;
  return new_national_grid_easting_northing(data);
}