{"size": 1116, "ext": "js", "max_stars_repo_path": "src/Format/Parsers/Coordinates/Coordinates.js", "max_stars_repo_name": "BhagyashreeSawant/Leaflet-WFST", "max_stars_repo_stars_event_min_datetime": "2015-06-18T13:46:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T09:57:08.000Z", "max_issues_repo_path": "src/Format/Parsers/Coordinates/Coordinates.js", "max_issues_repo_name": "BhagyashreeSawant/Leaflet-WFST", "max_issues_repo_issues_event_min_datetime": "2015-03-02T07:22:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-24T05:46:49.000Z", "max_forks_repo_path": "example/example_rest/interactive_geocoding/Leaflet-WFST/src/Format/Parsers/Coordinates/Coordinates.js", "max_forks_repo_name": "GeoHistoricalData/historical_geocoding", "max_forks_repo_forks_event_min_datetime": "2015-03-23T08:52:49.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T20:47:10.000Z"}
{"max_stars_count": 143, "max_issues_count": 73, "max_forks_count": 77, "avg_line_length": 19.9285714286, "max_line_length": 56, "alphanum_fraction": 0.5752688172}
/**
 * Created by PRadostev on 05.06.2015.
 */

L.GML.Coordinates = L.GML.Element.extend({

  defaultSeparator: {
    ds: '.', //decimal separator
    cs: ',', // component separator
    ts: ' ' // tuple separator
  },

  initialize: function () {
    this.elementTag = 'gml:coordinates';
  },

  parse: function (element) {

    var ds = this.defaultSeparator.ds;
    if (element.attributes.decimal) {
      ds = element.attributes.decimal.value;
    }

    var cs = this.defaultSeparator.cs;
    if (element.attributes.cs) {
      cs = element.attributes.cs.value;
    }

    var ts = this.defaultSeparator.ts;
    if (element.attributes.ts) {
      ts = element.attributes.ts.value;
    }

    var result = [];
    var coords = element.textContent.split(ts);

    var mapFunction = function (coord) {
      if (ds !== '.') {
        coord = coord.replace(ds, '.');
      }

      return parseFloat(coord);
    };

    for (var i = 0; i < coords.length; i++) {
      result.push(coords[i].split(cs).map(mapFunction));
    }

    if (result.length === 1) {
      return result[0];
    }

    return result;
  }
});
