0

I want to create a component that transforms the longitude & latitude in degree minutes second but I do not understand how to do ? I don't have the expected result as in DMS latitude && DMS longitude I made some test but I don't know how to display it in the html

edit: I found some solutions on stackoverflow but I don't understand

thanks.

enter image description here

html

<div>
  latitude {{latitude}}
</div>

<div>
  longitude {{longitude}}
</div>

ts.file

  public latitude = '25,514685';
  public longitude = '-6,890627';

  constructor() {
    this.ParseDMS();
  }

  ParseDMS() {
    var lati = this.latitude.split('');
    var longi = this.latitude.split('');
    this.ConvertDMSToDD(lati[0], lati[1], lati[2], lati[3]);
    this.ConvertDMSToDD(longi[4], longi[5], longi[6], longi[7]);
  }

  ConvertDMSToDD(degrees: any, minutes: any, seconds: any, direction: any) {
    console.log('degrees', degrees);
    console.log('minutes', minutes);
    console.log('seconds', seconds);
    console.log('direction', direction);

    var dd = degrees + minutes / 60 + seconds / (60 * 60);
    dd = parseFloat(dd);
    if (direction == 'S' || direction == 'W') {
      dd *= -1;
    } // Don't do anything for N or E
    return console.log('dd', dd);
  }
foo42
  • 29
  • 4

0 Answers0