use of de.topobyte.osm4j.core.model.iface.OsmRelationMember in project osm4j-pbf by topobyte.
the class PbfWriter method addMemberRolesToStringTable.
private void addMemberRolesToStringTable(Collection<OsmRelation> relations) {
for (OsmRelation relation : relations) {
for (int k = 0; k < relation.getNumberOfMembers(); k++) {
OsmRelationMember j = relation.getMember(k);
stringTable.incr(j.getRole());
}
}
}
use of de.topobyte.osm4j.core.model.iface.OsmRelationMember in project osm4j-core by topobyte.
the class ListDataSetLoader method read.
public static InMemoryListDataSet read(OsmIterator iterator, boolean keepNodeTags, boolean keepWayTags, boolean keepRelationTags) throws IOException {
InMemoryListDataSet dataSet = new InMemoryListDataSet();
List<OsmNode> nodes = dataSet.getNodes();
List<OsmWay> ways = dataSet.getWays();
List<OsmRelation> relations = dataSet.getRelations();
if (iterator.hasBounds()) {
dataSet.setBounds(iterator.getBounds());
}
while (iterator.hasNext()) {
EntityContainer container = iterator.next();
switch(container.getType()) {
case Node:
OsmNode node = (OsmNode) container.getEntity();
if (!keepNodeTags) {
node = new Node(node.getId(), node.getLongitude(), node.getLatitude());
}
nodes.add(node);
break;
case Way:
OsmWay way = (OsmWay) container.getEntity();
if (!keepWayTags) {
TLongArrayList ids = new TLongArrayList();
for (int i = 0; i < way.getNumberOfNodes(); i++) {
ids.add(way.getNodeId(i));
}
way = new Way(way.getId(), ids);
}
ways.add(way);
break;
case Relation:
OsmRelation relation = (OsmRelation) container.getEntity();
if (!keepRelationTags) {
List<OsmRelationMember> members = new ArrayList<>();
for (int i = 0; i < relation.getNumberOfMembers(); i++) {
members.add(relation.getMember(i));
}
relation = new Relation(relation.getId(), members);
}
relations.add(relation);
break;
}
}
return dataSet;
}
use of de.topobyte.osm4j.core.model.iface.OsmRelationMember in project osm4j-core by topobyte.
the class MapDataSetLoader method read.
public static InMemoryMapDataSet read(OsmIterator iterator, boolean keepNodeTags, boolean keepWayTags, boolean keepRelationTags) throws IOException {
InMemoryMapDataSet dataSet = new InMemoryMapDataSet();
TLongObjectMap<OsmNode> nodes = dataSet.getNodes();
TLongObjectMap<OsmWay> ways = dataSet.getWays();
TLongObjectMap<OsmRelation> relations = dataSet.getRelations();
if (iterator.hasBounds()) {
dataSet.setBounds(iterator.getBounds());
}
while (iterator.hasNext()) {
EntityContainer container = iterator.next();
switch(container.getType()) {
case Node:
OsmNode node = (OsmNode) container.getEntity();
if (!keepNodeTags) {
node = new Node(node.getId(), node.getLongitude(), node.getLatitude());
}
nodes.put(node.getId(), node);
break;
case Way:
OsmWay way = (OsmWay) container.getEntity();
if (!keepWayTags) {
TLongArrayList ids = new TLongArrayList();
for (int i = 0; i < way.getNumberOfNodes(); i++) {
ids.add(way.getNodeId(i));
}
way = new Way(way.getId(), ids);
}
ways.put(way.getId(), way);
break;
case Relation:
OsmRelation relation = (OsmRelation) container.getEntity();
if (!keepRelationTags) {
List<OsmRelationMember> members = new ArrayList<>();
for (int i = 0; i < relation.getNumberOfMembers(); i++) {
members.add(relation.getMember(i));
}
relation = new Relation(relation.getId(), members);
}
relations.put(relation.getId(), relation);
break;
}
}
return dataSet;
}
use of de.topobyte.osm4j.core.model.iface.OsmRelationMember in project osm4j-core by topobyte.
the class EntityFinderIgnoreMissing method findMemberRelationsRecursively.
private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
TLongSet ids = new TLongHashSet();
while (!queue.isEmpty()) {
OsmRelation relation = queue.remove();
for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
if (member.getType() != EntityType.Relation) {
continue;
}
long id = member.getId();
if (ids.contains(id)) {
continue;
}
ids.add(id);
try {
OsmRelation child = entityProvider.getRelation(id);
outRelations.add(child);
queue.add(child);
} catch (EntityNotFoundException e) {
// ignore silently
}
}
}
}
use of de.topobyte.osm4j.core.model.iface.OsmRelationMember in project osm4j-core by topobyte.
the class EntityFinderLogMissing method findMemberRelationsRecursively.
private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
TLongSet ids = new TLongHashSet();
while (!queue.isEmpty()) {
OsmRelation relation = queue.remove();
for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
if (member.getType() != EntityType.Relation) {
continue;
}
long id = member.getId();
if (ids.contains(id)) {
continue;
}
ids.add(id);
try {
OsmRelation child = entityProvider.getRelation(id);
outRelations.add(child);
queue.add(child);
} catch (EntityNotFoundException e) {
logRelationNotFound(id);
}
}
}
}
Aggregations