use of de.topobyte.osm4j.core.model.impl.Tag in project osm4j-pbf by topobyte.
the class PrimParser method convert.
public OsmWay convert(Osmformat.Way w) {
long id = w.getId();
TLongArrayList nodes = new TLongArrayList();
long lastId = 0;
for (long j : w.getRefsList()) {
nodes.add(j + lastId);
lastId = j + lastId;
}
List<OsmTag> tags = new ArrayList<>();
for (int j = 0; j < w.getKeysCount(); j++) {
tags.add(new Tag(strings[w.getKeys(j)], strings[w.getVals(j)]));
}
OsmMetadata metadata = null;
if (fetchMetadata && w.hasInfo()) {
Osmformat.Info info = w.getInfo();
metadata = convertMetadata(info);
}
return new Way(id, nodes, tags, metadata);
}
use of de.topobyte.osm4j.core.model.impl.Tag in project osm4j-pbf by topobyte.
the class PrimParser method convert.
public OsmNode convert(Osmformat.Node n) {
long id = n.getId();
double lat = parseLat(n.getLat());
double lon = parseLon(n.getLon());
List<OsmTag> tags = new ArrayList<>();
for (int j = 0; j < n.getKeysCount(); j++) {
tags.add(new Tag(strings[n.getKeys(j)], strings[n.getVals(j)]));
}
OsmMetadata metadata = null;
if (fetchMetadata && n.hasInfo()) {
Osmformat.Info info = n.getInfo();
metadata = convertMetadata(info);
}
return new Node(id, lon, lat, tags, metadata);
}
use of de.topobyte.osm4j.core.model.impl.Tag in project osm4j-pbf by topobyte.
the class PrimParser method convert.
public List<OsmNode> convert(Osmformat.DenseNodes nodes) {
List<OsmNode> results = new ArrayList<>(nodes.getIdCount());
Osmformat.DenseInfo denseInfo = null;
boolean hasVisible = false;
if (fetchMetadata && nodes.hasDenseinfo()) {
denseInfo = nodes.getDenseinfo();
hasVisible = denseInfo.getVisibleCount() != 0;
}
long id = 0, lat = 0, lon = 0;
int version = 0, uid = 0, userSid = 0;
long timestamp = 0, changeset = 0;
// Index into the keysvals array.
int j = 0;
for (int i = 0; i < nodes.getIdCount(); i++) {
id += nodes.getId(i);
lat += nodes.getLat(i);
lon += nodes.getLon(i);
double latf = parseLat(lat), lonf = parseLon(lon);
List<OsmTag> tags = new ArrayList<>();
OsmMetadata metadata = null;
if (fetchMetadata && nodes.hasDenseinfo()) {
version = denseInfo.getVersion(i);
timestamp += denseInfo.getTimestamp(i);
uid += denseInfo.getUid(i);
userSid += denseInfo.getUserSid(i);
changeset += denseInfo.getChangeset(i);
boolean visible = true;
if (hasVisible) {
visible = denseInfo.getVisible(i);
}
metadata = new Metadata(version, timestamp * dateGranularity, uid, strings[userSid], changeset, visible);
}
// 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(strings[keyid], strings[valid]));
}
// Skip over the '0' delimiter.
j++;
}
results.add(new Node(id, lonf, latf, tags, metadata));
}
return results;
}
use of de.topobyte.osm4j.core.model.impl.Tag in project osm4j-core by topobyte.
the class ImplUtil method cloneTags.
private static List<? extends OsmTag> cloneTags(OsmEntity entity) {
List<Tag> tags = new ArrayList<>();
for (int i = 0; i < entity.getNumberOfTags(); i++) {
OsmTag tag = entity.getTag(i);
tags.add(new Tag(tag.getKey(), tag.getValue()));
}
return tags;
}
use of de.topobyte.osm4j.core.model.impl.Tag in project osm4j-pbf by topobyte.
the class PrimParser method convert.
public OsmRelation convert(Osmformat.Relation r) {
long id = r.getId();
long lastMid = 0;
List<OsmTag> tags = new ArrayList<>();
for (int j = 0; j < r.getKeysCount(); j++) {
tags.add(new Tag(strings[r.getKeys(j)], strings[r.getVals(j)]));
}
List<RelationMember> members = new ArrayList<>();
for (int j = 0; j < r.getMemidsCount(); j++) {
long mid = lastMid + r.getMemids(j);
lastMid = mid;
String role = strings[r.getRolesSid(j)];
Osmformat.Relation.MemberType type = r.getTypes(j);
EntityType t = getType(type);
RelationMember member = new RelationMember(mid, t, role);
members.add(member);
}
OsmMetadata metadata = null;
if (fetchMetadata && r.hasInfo()) {
Osmformat.Info info = r.getInfo();
metadata = convertMetadata(info);
}
return new Relation(id, members, tags, metadata);
}
Aggregations