Geospatial data structure that presents a spatial entity
Overview
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
// Default constructorpublicGeoNode()// Create a node with location details and add entity laterpublicGeoNode(double latitude,double longitude)// Create a node with location details and a reference data typepublicGeoNode(double latitude,double longitude,T entity)
Key Methods
Key method implementations provided
Get coordinates
Tuple<Double, Double>getCoordinates();
Get entity unique key
ObjectgetKey()
Get entity
TgetValue()
Example
classFriendimplementsReferenceData {Integer id;String name;// Implementation}Friend bart =newFriend(1,"bart");Friend billy =newFriend(2,"billy");Friend cumin =newFriend(3,"cumin");Friend john =newFriend(4,"john");Friend stacey =newFriend(5,"stacey");Friend bambi =newFriend(6,"bambi");Friend gazza =newFriend(7,"gazza");Friend kevin =newFriend(8,"kevin");Friend lora =newFriend(9,"lora");Friend rodney =newFriend(10,"rodney");Friend arkan =newFriend(11,"arkan");GeoNode<Friend>[] friendlocations =newGeoNode[]{newGeoNode<>(51.456821f,-0.164746f, bart),newGeoNode<>(51.456821f,-0.164746f, billy),newGeoNode<>(51.457018f,-0.1622072f, cumin),newGeoNode<>(51.457018f,-0.1622072f, john),newGeoNode<>(51.467766f,-0.2987533f, stacey),newGeoNode<>(51.467766f,-0.2987533f, bambi),newGeoNode<>(51.467766f,-0.2987533f, gazza),newGeoNode<>(51.457018f,-0.1622072f, kevin),newGeoNode<>(51.457018f,-0.1622072f, lora),newGeoNode<>(51.467766f,-0.2987533f, rodney),newGeoNode<>(51.456821f,-0.164746f, arkan)};// Add friend locations to search treeQuadTree<GeoNode<Friend>> friendsTree =newQuadTree<>(-180f,-90f,360,64800);Arrays.stream(peoplePoints).forEach(friendsTree::insert);// Perform a search of entites within a geofenceGeoFence currentLocation =newGeoFence(51.456821f,-0.164746f,2);Collection<GeoNode<Friend>> friendsNearby =friendsTree.query(currentLocation);friendsNearby.forEach(System.out::println);