Geo point type

Geo point type documentation.

Overview

This type can store geo localization data. It consist of a couple of values:

  • latitude: Valid latitude values are between -90 and 90, both inclusive.
  • longitude: Valid longitude values are between -180 and 180, both inclusive.

Powerful and useful queries can be done on this data type.

Available features

NameSupported
Many multiplicityyes
Default valuesyes
Unique flagno
Required flagyes
Indexable flagyes
Sensitive flagno
Calculated valueyes
Automatic initializationyes
Calculated initial valueyes
Aggregationyes
Default type rulesno
Default display optionsno

REST API

Read format

"location": '{latitude: 10.5, longitude: 12}'

Write format

To specify the geo point, you need to provide a js object with the latitude and longitude attributes.

"location": '{latitude: 10.5, longitude: 12}'

JavaScript API

Read format

When utilizing the val() method within the wrapper, it will yield a GeoPoint object.

// this will print something like "localization: {longitude:10,latitude:20}"
log('localization: '+record.field('localization').val());

Write format

record.field('startDate').val({latitude: 10.5, longitude: 12});

Export/Import

Export format

The export format is (lat,long), regardless of the display options configured for that field.

"location","(22,30)"

Import format

The import format is (lat,long), regardless of the display options configured for that field.

"location","(22,30)"

Queries

For more information, please refer to the Query Language Documentation.

Available operators

OperatorSupported
equalsno
notEqualsno
emptyno
notEmptyno
likeno
greaterno
greaterOrEqualsno
lessno
lessOrEqualsno
betweenno
currentUserFieldno
nearyes

Query samples

// sorts companies by proximity to [ lat: 10, long: 22 ] that are at a min distance of 5000 m and at a maximum of 10000 m 
var records_sample = sys.data.find('companies', {'location':'near(5,10,5000,10000)'});
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// sorts companies by proximity to [ lat: 10, long: 22 ] that are at a min distance of 5000 m and at a maximum of 10000 m 
var query_sample = sys.data.createQuery('companies')
    .field('location').near(5,10,5000,10000)
var records_sample = sys.data.find(query_sample);
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// sorts companies by proximity to [ lat: 10, long: 22 ] that are at a min distance of 5000 m and at a maximum of 10000 m 
GET /data/contacts?near(5,10,5000,10000)

Aggregate queries

Please refer to the Aggregate Queries Documentation for more detailed information.

Available operators

OperatorSupported
sumno
avgno
firstno
lastno
minno
maxno
geoNearyes

Aggregated queries samples

// Sorts records by proximity and filters them by min and max distance. Provides the calculated distance value in a custom field 
var resultSet = sys.data.aggregate('companies', [
     [{geoNear: {coordinates: {longitude:10,latitude:5},distanceField:'distance',minDistance:5566,maxDistance:9460000}}]
]);
log('total: ' + resultSet.count());
while (resultSet.hasNext()) {
    log(resultSet.next().label());
}
// Sorts records by proximity and filters them by min and max distance. Provides the calculated distance value in a custom field 
var query = sys.data.createQuery('companies')
    query_.geoNear().coordinates({longitude:10,latitude:05}).distanceField('distance').minDistance(5566).maxDistance(9460000);
var resultSet = sys.data.aggregate(query);
log('total: ' + resultSet.count());
while (resultSet.hasNext()) {
    log(resultSet.next().label());
}
// Sorts records by proximity and filters them by min and max distance. Provides the calculated distance value in a custom field 
PUT /data/companies/aggregate

[{"geoNear": {"coordinates": {"longitude":10, "latitude":5}}, "distanceField": "distance", "minDistance": 5566, "maxDistance":9460000}]