lib/util/convertGeopoint.js
function convertGeopoint (point) {
  const t = typeof point;

  if (!point || (t !== 'string' && t !== 'object')) {
    return null;
  }

  // Format: "lat, lon" or "geohash"
  if (t === 'string') {
    return fromString(point);
  }

  // Format: [lat, lon]
  if (Array.isArray(point)) {
    if (point.length === 2) {
      return toCoordinate(point[0], point[1]);
    }

    return null;
  }

  const camelCased = geoLocationToCamelCase(point);

  // Format: { lat, lon }
  if (camelCased.hasOwnProperty('lat') && camelCased.hasOwnProperty('lon')) {
    return toCoordinate(camelCased.lat, camelCased.lon);
  }

  if (camelCased.latLon) {
    // Format: { latLon: [lat, lon] }
    if (Array.isArray(camelCased.latLon)) {
      if (camelCased.latLon.length === 2) {
        return toCoordinate(camelCased.latLon[0], camelCased.latLon[1]);
      }

      return null;
    }

    // Format: { latLon: { lat, lon } }
    if (typeof camelCased.latLon === 'object' && camelCased.latLon.hasOwnProperty('lat') && camelCased.latLon.hasOwnProperty('lon')) {
      return toCoordinate(camelCased.latLon.lat, camelCased.latLon.lon);
    }

    if (typeof camelCased.latLon === 'string') {
      return fromString(camelCased.latLon);
    }
  }

  return null;
}
function convertGeopoint (point) {
  const t = typeof point;

  if (!point || (t !== 'string' && t !== 'object')) {
    return null;
  }

  // Format: "lat, lon" or "geohash"
  if (t === 'string') {
    return fromString(point);
  }

  // Format: [lat, lon]
  if (Array.isArray(point)) {
    if (point.length === 2) {
      return toCoordinate(point[0], point[1]);
    }

    return null;
  }

  const camelCased = geoLocationToCamelCase(point);

  // Format: { lat, lon }
  if (camelCased.hasOwnProperty('lat') && camelCased.hasOwnProperty('lon')) {
    return toCoordinate(camelCased.lat, camelCased.lon);
  }

  if (camelCased.latLon) {
    // Format: { latLon: [lat, lon] }
    if (Array.isArray(camelCased.latLon)) {
      if (camelCased.latLon.length === 2) {
        return toCoordinate(camelCased.latLon[0], camelCased.latLon[1]);
      }

      return null;
    }

    // Format: { latLon: { lat, lon } }
    if (typeof camelCased.latLon === 'object' && camelCased.latLon.hasOwnProperty('lat') && camelCased.latLon.hasOwnProperty('lon')) {
      return toCoordinate(camelCased.latLon.lat, camelCased.latLon.lon);
    }

    if (typeof camelCased.latLon === 'string') {
      return fromString(camelCased.latLon);
    }
  }

  return null;
}
function convertGeopoint ( point ) { const t = typeof point ; if ( ! point || ( t !== 'string' && t !== 'object' ) ) { return null ; } // Format: "lat, lon" or "geohash" if ( t === 'string' ) { return fromString ( point ) ; } // Format: [lat, lon] if ( Array . isArray ( point ) ) { if ( point . length === 2 ) { return toCoordinate ( point [ 0 ] , point [ 1 ] ) ; } return null ; } const camelCased = geoLocationToCamelCase ( point ) ; // Format: { lat, lon } if ( camelCased . hasOwnProperty ( 'lat' ) && camelCased . hasOwnProperty ( 'lon' ) ) { return toCoordinate ( camelCased . lat , camelCased . lon ) ; } if ( camelCased . latLon ) { // Format: { latLon: [lat, lon] } if ( Array . isArray ( camelCased . latLon ) ) { if ( camelCased . latLon . length === 2 ) { return toCoordinate ( camelCased . latLon [ 0 ] , camelCased . latLon [ 1 ] ) ; } return null ; } // Format: { latLon: { lat, lon } } if ( typeof camelCased . latLon === 'object' && camelCased . latLon . hasOwnProperty ( 'lat' ) && camelCased . latLon . hasOwnProperty ( 'lon' ) ) { return toCoordinate ( camelCased . latLon . lat , camelCased . latLon . lon ) ; } if ( typeof camelCased . latLon === 'string' ) { return fromString ( camelCased . latLon ) ; } } return null ; }
Converts one of the accepted geopoint format into
a standardized version

@param {*} point - geopoint field to convert
@returns {Coordinate} or null if no accepted format is found
Converts one of the accepted geopoint format into a standardized version