use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.
the class PKIStatusInfo method encode.
@Override
public void encode(Tag implicitTag, OutputStream ostream) throws IOException {
SEQUENCE seq = new SEQUENCE();
seq.addElement(status);
if (statusString.size() > 0) {
seq.addElement(statusString);
}
if (hasFailInfo) {
// convert failInfo to BIT_STRING
byte[] bytes = new byte[2];
bytes[0] = (byte) ((failInfo & 0xff000000) >>> 24);
bytes[1] = (byte) ((failInfo & 0x00ff0000) >>> 16);
// 7 unused bits
int padCount = 7;
BIT_STRING bs = new BIT_STRING(bytes, padCount);
bs.setRemoveTrailingZeroes(true);
seq.addElement(bs);
}
seq.encode(implicitTag, ostream);
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class OsmosisBinaryParser method parseDense.
@Override
protected void parseDense(Osmformat.DenseNodes nodes) {
long lastId = 0, lastLat = 0, lastLon = 0;
// Index into the keysvals array.
int j = 0;
// Stuff for dense info
long lasttimestamp = 0, lastchangeset = 0;
int lastuserSid = 0, lastuid = 0;
Osmformat.DenseInfo di = null;
if (nodes.hasDenseinfo()) {
di = nodes.getDenseinfo();
}
for (int i = 0; i < nodes.getIdCount(); i++) {
Node tmp;
List<Tag> tags = new ArrayList<Tag>(0);
long lat = nodes.getLat(i) + lastLat;
lastLat = lat;
long lon = nodes.getLon(i) + lastLon;
lastLon = lon;
long id = nodes.getId(i) + lastId;
lastId = id;
double latf = parseLat(lat), lonf = parseLon(lon);
// If empty, assume that nothing here has keys or vals.
if (nodes.getKeysValsCount() > 0) {
while (nodes.getKeysVals(j) != 0) {
int keyid = nodes.getKeysVals(j++);
int valid = nodes.getKeysVals(j++);
tags.add(new Tag(getStringById(keyid), getStringById(valid)));
}
// Skip over the '0' delimiter.
j++;
}
// Handle dense info.
if (di != null) {
int uid = di.getUid(i) + lastuid;
lastuid = uid;
int userSid = di.getUserSid(i) + lastuserSid;
lastuserSid = userSid;
long timestamp = di.getTimestamp(i) + lasttimestamp;
lasttimestamp = timestamp;
int version = di.getVersion(i);
long changeset = di.getChangeset(i) + lastchangeset;
lastchangeset = changeset;
Date date = new Date(date_granularity * timestamp);
OsmUser user;
if (uid < 0) {
user = OsmUser.NONE;
} else {
user = new OsmUser(uid, getStringById(userSid));
}
tmp = new Node(new CommonEntityData(id, version, date, user, changeset, tags), latf, lonf);
} else {
tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), latf, lonf);
}
sink.process(new NodeContainer(tmp));
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class OsmosisBinaryParser method parseWays.
@Override
protected void parseWays(List<Osmformat.Way> ways) {
for (Osmformat.Way i : ways) {
List<Tag> tags = new ArrayList<Tag>();
for (int j = 0; j < i.getKeysCount(); j++) {
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
}
long lastId = 0;
long lastLat = 0;
long lastLon = 0;
List<WayNode> nodes = new ArrayList<WayNode>();
for (int index = 0; index < i.getRefsCount(); index++) {
long identifier = lastId + i.getRefs(index);
WayNode node;
if (index < i.getLatCount() && index < i.getLonCount()) {
long lat = lastLat + i.getLat(index);
long lon = lastLon + i.getLon(index);
node = new WayNode(identifier, parseLat(lat), parseLon(lon));
lastLat = lat;
lastLon = lon;
} else {
node = new WayNode(identifier);
}
nodes.add(node);
lastId = identifier;
}
long id = i.getId();
// long id, int version, Date timestamp, OsmUser user,
// long changesetId, Collection<Tag> tags,
// List<WayNode> wayNodes
Way tmp;
if (i.hasInfo()) {
Osmformat.Info info = i.getInfo();
tmp = new Way(new CommonEntityData(id, info.getVersion(), getDate(info), getUser(info), info.getChangeset(), tags), nodes);
} else {
tmp = new Way(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), nodes);
}
sink.process(new WayContainer(tmp));
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class OsmosisBinaryParser method parseNodes.
@Override
protected void parseNodes(List<Osmformat.Node> nodes) {
for (Osmformat.Node i : nodes) {
List<Tag> tags = new ArrayList<Tag>();
for (int j = 0; j < i.getKeysCount(); j++) {
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
}
// long id, int version, Date timestamp, OsmUser user,
// long changesetId, Collection<Tag> tags,
// double latitude, double longitude
Node tmp;
long id = i.getId();
double latf = parseLat(i.getLat()), lonf = parseLon(i.getLon());
if (i.hasInfo()) {
Osmformat.Info info = i.getInfo();
tmp = new Node(new CommonEntityData(id, info.getVersion(), getDate(info), getUser(info), info.getChangeset(), tags), latf, lonf);
} else {
tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), latf, lonf);
}
sink.process(new NodeContainer(tmp));
}
}
use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.
the class CopyFilesetBuilder method process.
/**
* {@inheritDoc}
*/
public void process(NodeContainer nodeContainer) {
Node node;
node = nodeContainer.getEntity();
nodeWriter.writeField(node.getId());
nodeWriter.writeField(node.getVersion());
nodeWriter.writeField(node.getUser().getId());
nodeWriter.writeField(node.getTimestamp());
nodeWriter.writeField(node.getChangesetId());
nodeWriter.writeField(pointBuilder.createPoint(node.getLatitude(), node.getLongitude()));
nodeWriter.endRecord();
for (Tag tag : node.getTags()) {
nodeTagWriter.writeField(node.getId());
nodeTagWriter.writeField(tag.getKey());
nodeTagWriter.writeField(tag.getValue());
nodeTagWriter.endRecord();
}
if (enableBboxBuilder || enableLinestringBuilder) {
wayGeometryBuilder.addNodeLocation(node);
}
}
Aggregations