Skip to main content

create_geopoint

The create_geopoint processor builds a geo-point object ({ lat, lon }) from a latitude and a longitude field on any DataEntity or DataWindow. The source values are normalized with data-mate's parseGeoPoint, so any accepted lat/lon form (numbers or numeric strings) is converted to the { lat, lon } object.

Usage

Build a geo-point from a latitude and longitude field

Example of a job using the create_geopoint processor

{
"name" : "testing",
"workers" : 1,
"slicers" : 1,
"lifecycle" : "once",
"assets" : [
"standard"
],
"operations" : [
{
"_op": "test-reader"
},
{
"_op": "create_geopoint",
"lat_field": "latitude",
"lon_field": "longitude"
}
]
}

Here is a representation of what the processor will do with the configuration listed in the job above

const data = [
DataEntity.make({ latitude: 17.1333, longitude: -61.7833, otherField: 1 }),
DataEntity.make({ latitude: 'nope', longitude: 'nope', otherField: 2 }),
]

const results = await processor.run(data);

results = [
{ location: { lat: 17.1333, lon: -61.7833 }, otherField: 1 },
{ otherField: 2 },
]

When a geo-point cannot be built (a source field is missing or the value is invalid), the destination_field is left unset. The source fields are still removed when delete_source is true, as shown by the second record above.

Parameters

ConfigurationDescriptionTypeNotes
_opName of operation, it must reflect the exact name of the fileStringrequired
lat_fieldName of the field containing the latitude valueStringrequired, no default
lon_fieldName of the field containing the longitude valueStringrequired, no default
destination_fieldName of the field the geo-point object ({ lat, lon }) is written toStringoptional, defaults to location
delete_sourceDelete the lat_field and lon_field, whether or not a geo-point could be builtBooleanoptional, defaults to true