本文整理了Java中org.openstreetmap.osmosis.core.domain.v0_6.Relation
类的一些代码示例,展示了Relation
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Relation
类的具体详情如下:
包路径:org.openstreetmap.osmosis.core.domain.v0_6.Relation
类名称:Relation
[英]A data class representing a single OSM relation.
[中]表示单个OSM关系的数据类。
代码示例来源:origin: mapsforge/mapsforge
if (relation.getMembers().isEmpty()) {
return null;
List<RelationMember> members = relation.getMembers();
List<TDWay> wayMembers = new ArrayList<>();
for (RelationMember relationMember : members) {
LOGGER.finest("relation is missing a member, rel-id: " + relation.getId() + " member id: "
+ relationMember.getMemberId());
continue;
LOGGER.finest("relation has no valid members: " + relation.getId());
return null;
return new TDRelation(relation.getId(), ster.getLayer(), ster.getName(), ster.getHousenumber(), ster.getRef(),
knownWayTags, wayMembers.toArray(new TDWay[wayMembers.size()]));
代码示例来源:origin: openstreetmap/osmosis
/**
* Creates a new instance.
*
* @param sr
* The store to read state from.
* @param scr
* Maintains the mapping between classes and their identifiers
* within the store.
*/
public RelationContainer(StoreReader sr, StoreClassRegister scr) {
relation = new Relation(sr, scr);
}
代码示例来源:origin: openstreetmap/osmosis
if (this.getId() < comparisonRelation.getId()) {
return -1;
if (this.getId() > comparisonRelation.getId()) {
return 1;
if (this.getVersion() < comparisonRelation.getVersion()) {
return -1;
if (this.getVersion() > comparisonRelation.getVersion()) {
return 1;
if (this.getTimestamp() == null && comparisonRelation.getTimestamp() != null) {
return -1;
if (this.getTimestamp() != null && comparisonRelation.getTimestamp() == null) {
return 1;
if (this.getTimestamp() != null && comparisonRelation.getTimestamp() != null) {
int result;
result = this.getTimestamp().compareTo(comparisonRelation.getTimestamp());
memberListResult = compareMemberList(
comparisonRelation.members
);
return compareTags(comparisonRelation.getTags());
代码示例来源:origin: mapsforge/mapsforge
for (RelationMember relationMember : relation.getMembers()) {
if (relationMember.getMemberType().equals(EntityType.Way)
&& "outer".equalsIgnoreCase(relationMember.getMemberRole())) {
return null;
LOGGER.fine("Administrative: " + writer.getTagValue(relation.getTags(), "name")
+ " #Members: " + relation.getMembers().size()
+ " #Segments: " + bounds.size());
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-core
/**
* {@inheritDoc}
*/
@Override
public Relation getWriteableInstance() {
if (isReadOnly()) {
return new Relation(this);
} else {
return this;
}
}
代码示例来源:origin: openstreetmap/osmosis
relationWriter.writeField(relation.getId());
relationWriter.writeField(relation.getVersion());
relationWriter.writeField(relation.getUser().getId());
relationWriter.writeField(relation.getTimestamp());
relationWriter.writeField(relation.getChangesetId());
relationWriter.endRecord();
for (Tag tag : relation.getTags()) {
relationTagWriter.writeField(relation.getId());
relationTagWriter.writeField(tag.getKey());
relationTagWriter.writeField(tag.getValue());
for (RelationMember member : relation.getMembers()) {
relationMemberWriter.writeField(relation.getId());
relationMemberWriter.writeField(member.getMemberId());
relationMemberWriter.writeField(memberTypeValueMapper.getMemberType(member.getMemberType()));
代码示例来源:origin: openstreetmap/osmosis
private Relation readRelation() throws Exception {
long id;
int version;
TimestampContainer timestamp;
OsmUser user;
long changesetId;
Relation relation;
id = Long.parseLong(reader.getAttributeValue(null, ATTRIBUTE_NAME_ID));
version = Integer.parseInt(reader.getAttributeValue(null, ATTRIBUTE_NAME_VERSION));
timestamp = parseTimestamp(reader.getAttributeValue(null, ATTRIBUTE_NAME_TIMESTAMP));
user = readUser();
changesetId = readChangesetId();
relation = new Relation(new CommonEntityData(id, version, timestamp, user, changesetId));
reader.nextTag();
while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
if (reader.getLocalName().equals(ELEMENT_NAME_TAG)) {
relation.getTags().add(readTag());
} else if (reader.getLocalName().equals(ELEMENT_NAME_MEMBER)) {
relation.getMembers().add(readRelationMember());
} else {
readUnknownElement();
}
}
reader.nextTag();
return relation;
}
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
@Override
public Collection<RelationMember> getFeatureCollection(Relation entity) {
return entity.getMembers();
}
}
代码示例来源:origin: openstreetmap/osmosis
for (Relation i : contents) {
Osmformat.Relation.Builder bi = Osmformat.Relation.newBuilder();
bi.setId(i.getId());
RelationMember[] arr = new RelationMember[i.getMembers().size()];
i.getMembers().toArray(arr);
long lastid = 0;
for (RelationMember j : i.getMembers()) {
long id = j.getMemberId();
bi.addMemids(id - lastid);
for (Tag t : i.getTags()) {
bi.addKeys(stable.getIndex(t.getKey()));
bi.addVals(stable.getIndex(t.getValue()));
代码示例来源:origin: openstreetmap/osmosis
/**
* Process the relation members.
*
* @param relation The relation to be processed.
*/
private void addRelationMembers(Relation relation) {
List<RelationMember> memberReferenceList;
memberReferenceList = relation.getMembers();
for (int i = 0; i < memberReferenceList.size(); i++) {
relationMemberBuffer.add(new DbFeatureHistory<DbOrderedFeature<RelationMember>>(
new DbOrderedFeature<RelationMember>(relation.getId(), memberReferenceList.get(i), i + 1), relation
.getVersion()));
}
flushRelationMembers(false);
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Test writing out a Relation element with no tags.
*/
@Test
public final void testProcessRelationNoTags() {
Relation relation =
new Relation(new CommonEntityData(1234, 2, timestamp, new OsmUser(23, "someuser"), 0));
relation.getMembers().add(new RelationMember(2345, EntityType.Node, "noderole"));
relation.getMembers().add(new RelationMember(3456, EntityType.Way, "wayrole"));
relation.getMembers().add(new RelationMember(4567, EntityType.Relation, "relationrole"));
testRelationWriter.process(relation);
try {
testBufferedWriter.flush();
} catch (IOException e) {
e.printStackTrace();
fail("IOException");
}
String[] strArray = testWriter.toString().split("\\n", 5);
assertTrue(strArray[0].matches(relationOpeningMatch));
assertTrue(strArray[1].matches(nodeMemberMatch));
assertTrue(strArray[2].matches(wayMemberMatch));
assertTrue(strArray[3].matches(relationMemberMatch));
assertTrue(strArray[4].matches(relationClosingMatch));
}
}
代码示例来源:origin: mapsforge/mapsforge
@Override
public void addRelation(Relation relation) {
super.addRelation(relation);
TDRelation tdRelation = TDRelation.fromRelation(relation, this, this.preferredLanguages);
if (tdRelation != null) {
this.multipolygons.put(relation.getId(), tdRelation);
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Process the relation tags.
*
* @param relation The relation to be processed.
*/
private void addRelationTags(Relation relation) {
for (Tag tag : relation.getTags()) {
relationTagBuffer.add(new DbFeatureHistory<DbFeature<Tag>>(new DbFeature<Tag>(relation.getId(), tag),
relation.getVersion()));
}
flushRelationTags(false);
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Sets relation values as bind variable parameters to a relation insert query.
*
* @param statement The prepared statement to add the values to.
* @param initialIndex The offset index of the first variable to set.
* @param relation The way containing the data to be inserted.
*/
private void populateRelationParameters(PreparedStatement statement, int initialIndex, Relation relation) {
int prmIndex;
prmIndex = initialIndex;
assertEntityHasTimestamp(relation);
try {
statement.setLong(prmIndex++, relation.getId());
statement.setTimestamp(prmIndex++, new Timestamp(relation.getTimestamp().getTime()));
statement.setInt(prmIndex++, relation.getVersion());
statement.setBoolean(prmIndex++, true);
statement.setLong(prmIndex++, relation.getChangesetId());
} catch (SQLException e) {
throw new OsmosisRuntimeException("Unable to set a prepared statement parameter for a relation.", e);
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Process the relation tags.
*
* @param relation
* The relation to be processed.
*/
private void addRelationTags(Relation relation) {
for (Tag tag : relation.getTags()) {
relationTagBuffer.add(new DbFeature<Tag>(relation.getId(), tag));
}
flushRelationTags(false);
}
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
/*
* As per the hashCode definition, this doesn't have to be unique it
* just has to return the same value for any two objects that compare
* equal. Using both id and version will provide a good distribution of
* values but is simple to calculate.
*/
return (int) getId() + getVersion();
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Relation cloning test.
*/
@Test
public void testRelationClone() {
// Build the original entity.
List<Tag> tags = new ArrayList<Tag>();
tags.add(new Tag("myKey", "myValue"));
List<RelationMember> members = new ArrayList<RelationMember>();
members.add(new RelationMember(1, EntityType.Node, "myRole"));
Relation entity = new Relation(new CommonEntityData(1, 2, new Date(0), OsmUser.NONE, 3, tags), members);
// Cloning a writeable object should return the original object.
Assert.assertSame("Entity was cloned", entity, entity.getWriteableInstance());
// Get a cloned entity.
entity.makeReadOnly();
Relation clonedEntity = entity.getWriteableInstance();
// Make sure we weren't assigned the original entity.
Assert.assertNotSame("Entity was not cloned", entity, clonedEntity);
}
}
代码示例来源:origin: mapsforge/mapsforge
void filterBoundaries(Relation relation) {
if ("boundary".equalsIgnoreCase(writer.getTagValue(relation.getTags(), "type"))) {
String boundaryCategory = writer.getTagValue(relation.getTags(), "boundary");
if ("administrative".equalsIgnoreCase(boundaryCategory)) {
String adminLevelValue = writer.getTagValue(relation.getTags(), "admin_level");
if (adminLevelValue == null) return;
switch (adminLevelValue.trim()) {
//TODO Specify cultural/regional diffs for admin_levels,
// which should be the lowest level of administrative boundary, tagged with is_in
case "7":
administrativeBoundaries.get(6).add(relation);
return;
case "8":
administrativeBoundaries.get(7).add(relation);
return;
case "9":
administrativeBoundaries.get(8).add(relation);
return;
case "10":
administrativeBoundaries.get(9).add(relation);
return;
default:
}
} else if ("postal_code".equalsIgnoreCase(boundaryCategory)) {
postalBoundaries.add(relation);
}
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
public void process(RelationContainer relationContainer) {
Relation relation;
int memberSequenceId;
relation = relationContainer.getEntity();
relationWriter.writeField(relation.getId());
relationWriter.writeField(relation.getVersion());
relationWriter.writeField(relation.getUser().getId());
relationWriter.writeField(relation.getTimestamp());
relationWriter.writeField(relation.getChangesetId());
relationWriter.writeField(buildTags(relation));
relationWriter.endRecord();
memberSequenceId = 0;
for (RelationMember member : relation.getMembers()) {
relationMemberWriter.writeField(relation.getId());
relationMemberWriter.writeField(member.getMemberId());
relationMemberWriter.writeField(memberTypeValueMapper.getMemberType(member.getMemberType()));
relationMemberWriter.writeField(member.getMemberRole());
relationMemberWriter.writeField(memberSequenceId++);
relationMemberWriter.endRecord();
}
}
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-xml
private Relation readRelation() throws Exception {
long id;
int version;
TimestampContainer timestamp;
OsmUser user;
long changesetId;
Relation relation;
id = Long.parseLong(reader.getAttributeValue(null, ATTRIBUTE_NAME_ID));
version = Integer.parseInt(reader.getAttributeValue(null, ATTRIBUTE_NAME_VERSION));
timestamp = parseTimestamp(reader.getAttributeValue(null, ATTRIBUTE_NAME_TIMESTAMP));
user = readUser();
changesetId = readChangesetId();
relation = new Relation(new CommonEntityData(id, version, timestamp, user, changesetId));
reader.nextTag();
while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
if (reader.getLocalName().equals(ELEMENT_NAME_TAG)) {
relation.getTags().add(readTag());
} else if (reader.getLocalName().equals(ELEMENT_NAME_MEMBER)) {
relation.getMembers().add(readRelationMember());
} else {
readUnknownElement();
}
}
reader.nextTag();
return relation;
}
内容来源于网络,如有侵权,请联系作者删除!