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)));
}
j++; // Skip over the '0' delimiter.
}
// 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));
}
}