var request = require('./lib/request');

exports.getInEverySystem = function (geom, callback) {
  // Get geom in all configured coordinate systems.
  // Use POST request to send GeoJSON as is.
  //
  return request.postJSON({
    url: '/api/geometry',
    data: {
      geometry: geom,
    },
  }, callback);
};

exports.parseCoordinates = function (params, callback) {
  // Parameters
  //   params, object with props
  //     coordinateSystem
  //     coordinatesText
  //   callback
  //     fn (err, latlng), where
  //       latlng
  //         { lat, lng } in WGS84
  //
  return callback(null, {
    lat: 0,
    lng: 0,
  });
};

var request = require('./lib/request');

exports.getInEverySystem = function (geom, callback) {
  // Get geom in all configured coordinate systems.
  // Use POST request to send GeoJSON as is.
  //
  return request.postJSON({
    url: '/api/geometry',
    data: {
      geometry: geom,
    },
  }, callback);
};

exports.parseCoordinates = function (params, callback) {
  // Parse textual coordinates in various systems and convert to WGS84.
  //
  // Parameters
  //   params, object with props
  //     system
  //     text
  //   callback
  //     fn (err, coords), where
  //       coords is an array of objects with props:
  //         system
  //           string, system name e.g. 'WGS84'
  //         xy
  //           object { x, y }
  //
  return request.getJSON({
    url: '/api/geometry/parse',
    data: {
      system: params.system,
      text: params.text,
    },
  }, callback);
};

Implement stores.geometry parseCoordinates