Polyhash & Clustering

Cells can be clustered into arbitrary shapes using the Polyhash library available in our core SDK.

Concepts

Cluster

A cluster is a group of cells, of various sizes, that captures an arbitrary area and can be used to identify that space uniquely in the location network.

Polyhash

Polygon is the cell-based representation of a classic polygon. This polygon shape can be represented in a much smaller size, with polyhash.

[{
precision: 9,
data: [ 'u173zv08y', 'ut7g', 'dr', 'wyh', 'zg8', 'qq', 'v6hd', '08y' ]
}]

What for?

These clusters can be given a unique ID that can be used to interact with other cells, or clusters, in the UNL location network. In this way, you can define a cluster representing your business, and it can have its own streams of data, define custom routes for visitors, delivery, maintenance staff, etc., and becomes your business's address in the internet of places.

const Polyhash = require("unl-core").Polyhash;
const polygon = [
[52.3860252, 4.8828220], [52.3721408, 4.8751831], [52.3628122, 4.8804188],
[52.3578851, 4.8902035], [52.3596149, 4.9085712], [52.3625501, 4.9202442],
[52.3665334, 4.9275398], [52.3716691, 4.9126911], [52.3758612, 4.9129486],
[52.3776427, 4.9120903], [52.3860252, 4.8828220]
];
// [{
// precision: 7,
// data: [
// 'u176p0e', '3yyj', 'zh3', '72',
// 'ey', 'uq', '9bjh', '3zvc',
// 'y9', 'z0', '6p0e'
// ]
// }]
const polyhash = Polyhash.toPolyhash(polygon, 7)
// [
// { precision: 6, data: [ 'u173zk', 'm', 'q', 's', 't', 'w' ] },
// { precision: 7, data: [ 'yvp', 'w', 'x', 'y', 'z', 'yj', ... ] }
// ]
const cluster = Polyhash.toCluster(polygon, 7)
// u0COMqBaDeexPoRh4hvxrYSUjgDfbrPUn4AyoFo=
const clusterId = Polyhash.compressPolyhash(cluster)

Interacting with your newly created cluster is just like interacting with a cell via it's locationID. You can add data to a cluster, absorb events occurring within that cluster, and more.