use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project phtree by tzaeschke.
the class TestBST16 method testEmpty.
@Test
public void testEmpty() {
Node ht = create();
checkEmpty(ht);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project phtree by tzaeschke.
the class TestBST16 method testEmptyAfterLoad.
@Test
public void testEmptyAfterLoad() {
Node ht = create();
for (int r = 0; r < 10; r++) {
for (int i = 0; i < 100000; i++) {
BSTEntry e = ht.bstGetOrCreate(i, tree);
e.set(i, new long[] { i }, i);
}
for (int i = 0; i < 100000; i++) {
BSTEntry e = ht.bstRemove(i, new long[] { i }, null, tree);
assertEquals(i, (int) e.getValue());
}
checkEmpty(ht);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project geowave by locationtech.
the class OsmXmlLoader method process.
// Sink implementation
@Override
public void process(final EntityContainer entityContainer) {
final Entity entity = entityContainer.getEntity();
if (entity instanceof Node) {
final Node node = (Node) entity;
nodes.add(node);
nodeById.put(node.getId(), node);
} else if (entity instanceof Way) {
final Way way = (Way) entity;
ways.add(way);
} else if (entity instanceof Relation) {
final Relation rel = (Relation) entity;
relations.add(rel);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project GeoGig by boundlessgeo.
the class CreateOSMChangesetOp method _call.
/**
* Executes the diff operation.
*
* @return an iterator to a set of differences between the two trees
* @see DiffEntry
*/
@Override
protected Iterator<ChangeContainer> _call() {
Iterator<DiffEntry> nodeIterator = command(DiffOp.class).setFilter(OSMUtils.NODE_TYPE_NAME).setNewVersion(newRefSpec).setOldVersion(oldRefSpec).setReportTrees(false).call();
Iterator<DiffEntry> wayIterator = command(DiffOp.class).setFilter(OSMUtils.WAY_TYPE_NAME).setNewVersion(newRefSpec).setOldVersion(oldRefSpec).setReportTrees(false).call();
Iterator<DiffEntry> iterator = Iterators.concat(nodeIterator, wayIterator);
final EntityConverter converter = new EntityConverter();
Function<DiffEntry, ChangeContainer> function = new Function<DiffEntry, ChangeContainer>() {
@Override
@Nullable
public ChangeContainer apply(@Nullable DiffEntry diff) {
NodeRef ref = diff.changeType().equals(ChangeType.REMOVED) ? diff.getOldObject() : diff.getNewObject();
RevFeature revFeature = command(RevObjectParse.class).setObjectId(ref.objectId()).call(RevFeature.class).get();
RevFeatureType revFeatureType = command(RevObjectParse.class).setObjectId(ref.getMetadataId()).call(RevFeatureType.class).get();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder((SimpleFeatureType) revFeatureType.type());
ImmutableList<PropertyDescriptor> descriptors = revFeatureType.sortedDescriptors();
ImmutableList<Optional<Object>> values = revFeature.getValues();
for (int i = 0; i < descriptors.size(); i++) {
PropertyDescriptor descriptor = descriptors.get(i);
Optional<Object> value = values.get(i);
featureBuilder.set(descriptor.getName(), value.orNull());
}
SimpleFeature feature = featureBuilder.buildFeature(ref.name());
Entity entity = converter.toEntity(feature, id);
EntityContainer container;
if (entity instanceof Node) {
container = new NodeContainer((Node) entity);
} else {
container = new WayContainer((Way) entity);
}
ChangeAction action = diff.changeType().equals(ChangeType.ADDED) ? ChangeAction.Create : diff.changeType().equals(ChangeType.MODIFIED) ? ChangeAction.Modify : ChangeAction.Delete;
return new ChangeContainer(container, action);
}
};
return Iterators.transform(iterator, function);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project GeoGig by boundlessgeo.
the class EntityConverter method toEntity.
/**
* Converts a Feature to a OSM Entity
*
* @param feature the feature to convert
* @param replaceId. The changesetId to use in case the feature has a negative one indicating a
* temporary value
* @return
*/
public Entity toEntity(SimpleFeature feature, Long changesetId) {
Entity entity;
SimpleFeatureType type = feature.getFeatureType();
long id = Long.parseLong(feature.getID());
int version = ((Integer) feature.getAttribute("version")).intValue();
Long changeset = (Long) feature.getAttribute("changeset");
if (changesetId != null && changeset < 0) {
changeset = changesetId;
}
Long milis = (Long) feature.getAttribute("timestamp");
Date timestamp = new Date(milis);
String user = (String) feature.getAttribute("user");
String[] userTokens = user.split(":");
OsmUser osmuser;
try {
osmuser = new OsmUser(Integer.parseInt(userTokens[1]), userTokens[0]);
} catch (Exception e) {
osmuser = OsmUser.NONE;
}
String tagsString = (String) feature.getAttribute("tags");
Collection<Tag> tags = OSMUtils.buildTagsCollectionFromString(tagsString);
CommonEntityData entityData = new CommonEntityData(id, version, timestamp, osmuser, changeset, tags);
if (type.equals(OSMUtils.nodeType())) {
Point pt = (Point) feature.getDefaultGeometryProperty().getValue();
entity = new Node(entityData, pt.getY(), pt.getX());
} else {
List<WayNode> nodes = Lists.newArrayList();
String nodesString = (String) feature.getAttribute("nodes");
for (String s : nodesString.split(";")) {
nodes.add(new WayNode(Long.parseLong(s)));
}
entity = new Way(entityData, nodes);
}
return entity;
}
Aggregations