Geospatial data structure that presents a spatial entity


This data structure is used for geospatial analytics whereby a requirement to gain what is nearby with respect to location. GeoNode provides the base implementation for custom entities to extend.

The GeoNode class provides a generic data structure for spatial entities to be store and searched through the use of a spatial index

Understanding the structure and how to use this datatype will enable you to develop custom spatial entity based analytics.

Key Features

  • Provide latitude and longitude coordinates

  • Container for spatial entity

GeoNode can be located within the fractalworks-geospatial-processor project under the following package


Class Definition

class GeoNode<T extends ReferenceData> implements Coordinates, ReferenceData


// Default constructor
public GeoNode()

// Create a node with location details and add entity later
public GeoNode(double latitude, double longitude)

// Create a node with location details and a reference data type
public GeoNode(double latitude, double longitude, T entity)

Key Methods

Key method implementations provided

Get coordinates

Tuple<Double, Double> getCoordinates();

Get entity unique key

Object getKey() 

Get entity

T getValue()


class Friend implements ReferenceData {
        Integer id;
        String name;
    // Implementation

Friend bart = new Friend(1, "bart");
Friend billy = new Friend(2, "billy");
Friend cumin = new Friend(3, "cumin");
Friend john = new Friend(4, "john");
Friend stacey = new Friend(5, "stacey");
Friend bambi = new Friend(6, "bambi");
Friend gazza = new Friend(7, "gazza");
Friend kevin = new Friend(8, "kevin");
Friend lora = new Friend(9, "lora");
Friend rodney = new Friend(10, "rodney");
Friend arkan = new Friend(11, "arkan");
GeoNode<Friend>[] friendlocations = new GeoNode[]{
    new GeoNode<>(51.456821f, -0.164746f, bart),
    new GeoNode<>(51.456821f, -0.164746f, billy),
    new GeoNode<>(51.457018f, -0.1622072f, cumin),
    new GeoNode<>(51.457018f, -0.1622072f, john),
    new GeoNode<>(51.467766f, -0.2987533f, stacey),
    new GeoNode<>(51.467766f, -0.2987533f, bambi),
    new GeoNode<>(51.467766f, -0.2987533f, gazza),
    new GeoNode<>(51.457018f, -0.1622072f, kevin),
    new GeoNode<>(51.457018f, -0.1622072f, lora),
    new GeoNode<>(51.467766f, -0.2987533f, rodney),
    new GeoNode<>(51.456821f, -0.164746f, arkan)

// Add friend locations to search tree
QuadTree<GeoNode<Friend>> friendsTree = new QuadTree<>(-180f, -90f, 360, 64800);;

// Perform a search of entites within a geofence
GeoFence currentLocation = new GeoFence(51.456821f, -0.164746f, 2);
Collection<GeoNode<Friend>> friendsNearby = friendsTree.query(currentLocation);

Last updated