Data Lens Developer's Guide

proximity

When you add this rule to a query, it calculates an approximate distance in kilometers between two geographical points given in latitude and longitude.

The output can be used in filters; for example, to filter out points that are inside or outside of a specific region.

The rule takes the following form:

proximity(lat1,lon1,lat2,lon2)

where lat1, lon1 and lat2, lon2 represent the coordinates of the two points the distance between which is to be calculated. The returned value is a float giving an approximate distance between the points in kilometers.

For more information on using query rules in a REST API request, see Queries.

For an end-to-end description of how to create a query, see Creating a Query.

The example query below returns data points sorted by distance from a position sent in the URL parameters. This could be used, for example, to filter points of interest in a given radius from your current location.

{
    "dataset": "<dataset_id>",
    "metrics": [
      "Lat",
      "Lon",
      "distance"
    ],
    "namespace": {
      "mylat": {
        "source": [{"$input": "lat_position"}]
      },
      "mylon": {
        "source": [{"$input": "lon_position"}]
      },
      "distance": {
        "source": [
          "mylat",
          "mylon",
          "Lat",
          "Lon"
        ],
        "apply": [
          {
            "fn": "proximity",
            "type": "transform"
          }
        ]
      }
    },
    "order": [
      {
        "distance": "asc"
      }
    ],
    "limit": 10
}

The HTTP request would take the following form:

https://datalens.api.here.com/v1/queries/<query_id>/data?lat_position=0&lon_position=0&app_id={YOUR_APP_ID}&app_code={YOUR_APP_CODE}

The response includes an HTTP status code and a JSON response body.

For more information on the HTTP status codes, see HTTP Status Codes.

For more information on the elements in the JSON structure in the response body, see Query.

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.