use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.
the class BoundSetterTest method setNewBoundTest.
/**
* Tests the bound setting when there is no bound upstream.
*/
@Test
public void setNewBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
BoundSetter setter = new BoundSetter(newBound);
setter.setSink(inspector);
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
EntityContainer ec = inspector.getProcessedEntities().iterator().next();
Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
Bound bound = (Bound) ec.getEntity();
Assert.assertEquals(bound, newBound);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.
the class BoundSetterTest method removeNoBoundTest.
/**
* Tests the bound removal when there is no bound upstream.
*/
@Test
public void removeNoBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
BoundSetter setter = new BoundSetter(null);
setter.setSink(inspector);
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
EntityContainer ec = inspector.getProcessedEntities().iterator().next();
Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.
the class BoundSetterTest method overwriteBoundTest.
/**
* Tests the bound setting.
*/
@Test
public void overwriteBoundTest() {
SinkEntityInspector inspector = new SinkEntityInspector();
Bound newBound = new Bound(2, 1, 4, 3, "NewBound");
BoundSetter setter = new BoundSetter(newBound);
setter.setSink(inspector);
setter.process(new BoundContainer(new Bound("Test")));
setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
setter.complete();
setter.close();
Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
EntityContainer ec = iterator.next();
Assert.assertEquals(EntityType.Bound, ec.getEntity().getType());
Bound bound = (Bound) ec.getEntity();
Assert.assertEquals(bound, newBound);
// Ensure there is no second bound
ec = iterator.next();
Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.
the class AreaFilter method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer container) {
Node node;
node = container.getEntity();
// Check if we're storing entities for later.
if (storeEntities) {
allNodes.add(container);
}
// Only add the node if it lies within the box boundaries.
if (isNodeWithinArea(node)) {
availableNodes.set(node.getId());
// If we're not storing entities, we pass it on immediately.
if (!storeEntities) {
emitNode(container);
}
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project osmosis by openstreetmap.
the class BoundComputer method process.
@Override
public void process(NodeContainer nodeContainer) {
Node node = nodeContainer.getEntity();
if (nodesSeen) {
left = Math.min(left, node.getLongitude());
right = Math.max(right, node.getLongitude());
bottom = Math.min(bottom, node.getLatitude());
top = Math.max(top, node.getLatitude());
} else {
left = node.getLongitude();
right = node.getLongitude();
top = node.getLatitude();
bottom = node.getLatitude();
nodesSeen = true;
}
objects.add(nodeContainer);
}
Aggregations