Class: NationalGrid::EastingNorthing

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/national_grid/easting_northing.rb,
ext/national_grid/national_grid_easting_northing.c

Instance Method Summary collapse

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_easting_northing.c', line 16

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

  EastingNorthing* data = easting_northing(self);
  data->e = default_to_zero(easting);
  data->n = default_to_zero(northing);
  data->elevation = default_to_zero(elevation);

  return self;
}

Instance Method Details

#eastingObject



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

static VALUE easting(VALUE self) {
  return DBL2NUM(easting_northing(self)->e);
}

#elevationObject



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

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

#northingObject



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

static VALUE northing(VALUE self) {
  return DBL2NUM(easting_northing(self)->n);
}

#to_aObject



5
6
7
# File 'lib/national_grid/easting_northing.rb', line 5

def to_a
  [easting, northing, elevation]
end

#to_latitude_longitudeObject



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

static VALUE to_latitude_longitude(VALUE self) {
  LatLonDecimal data = ETRS89LatLonFromETRS89EastingNorthing(ETRS89EastingNorthingFromOSGB36EastingNorthing(*easting_northing(self)));
  if (data.geoid == 0) return Qnil;
  return new_national_grid_latitude_longitude(data);
}