Skip to content
Advertisement

Creating a EntityIterable from multiple Entity objects

I’m trying to implement a “nearby” filter with Xodus, having this code:

JavaScript
JavaScript

The algorithm may not be the best, but, the main question here is how to build a new EntityIterable based from multiple Entity objects? Is that possible?

My solution to basically collect “nearby” entities is to iterate over all entities with the custom GeoPoint property then for each Entity found, comparing the distance of its GeoPoint property and if that is a hit then all these entities should be collected into one EntityIterable.

How do you build a EntityIterable from a list of Entity objects?

UPDATE:

Explaining how this works step-by-step:

This code below gets all the entities with the given property name, e.g. geoLocation

JavaScript

Then for all the entities with such geoLocation property for example iterate over it to compute if it meets the distance target:

JavaScript

Adding the entity to the new List if it meets the target.

From here what needs to be done is to either remove all entities in the EntityIterable entities which does not equal to the ID’s of the matched entities in the entityList OR to intersect these matched entities to referenceToScope.get() and not to EntityIterable entities (just to avoid confusion, this entities iterable is a just a temp one)

Advertisement

Answer

Here’s how to solve this:

JavaScript

This will effectively remove all entities that fails to match the target distance.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement