本文整理了Java中org.openstreetmap.osmosis.core.domain.v0_6.Tag.<init>()
方法的一些代码示例,展示了Tag.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.<init>()
方法的具体详情如下:
包路径:org.openstreetmap.osmosis.core.domain.v0_6.Tag
类名称:Tag
方法名:<init>
[英]Creates a new instance.
[中]创建一个新实例。
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
public void begin(Attributes attributes) {
String key;
String value;
key = attributes.getValue(ATTRIBUTE_NAME_KEY);
value = attributes.getValue(ATTRIBUTE_NAME_VALUE);
tag = new Tag(key, value);
}
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-xml
/**
* {@inheritDoc}
*/
public void begin(Attributes attributes) {
String key;
String value;
key = attributes.getValue(ATTRIBUTE_NAME_KEY);
value = attributes.getValue(ATTRIBUTE_NAME_VALUE);
tag = new Tag(key, value);
}
代码示例来源:origin: osmlab/atlas
@Override
public Collection<Tag> convert(final Map<String, String> object)
{
final List<Tag> result = new ArrayList<>();
object.forEach((key, value) -> result.add(new Tag(key, value)));
return result;
}
}
代码示例来源:origin: openstreetmap/osmosis
private Tag readTag() throws Exception {
Tag tag = new Tag(reader.getAttributeValue(null, ATTRIBUTE_NAME_KEY),
reader.getAttributeValue(null, ATTRIBUTE_NAME_VALUE));
reader.nextTag();
reader.nextTag();
return tag;
}
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-xml
private Tag readTag() throws Exception {
Tag tag = new Tag(reader.getAttributeValue(null, ATTRIBUTE_NAME_KEY),
reader.getAttributeValue(null, ATTRIBUTE_NAME_VALUE));
reader.nextTag();
reader.nextTag();
return tag;
}
代码示例来源:origin: org.locationtech.geogig/geogig-osm
public static Collection<Tag> buildTagsCollection(@Nullable Map<String, String> map) {
Collection<Tag> tags = Lists.newArrayList();
if (map != null) {
for (Entry<String, String> e : map.entrySet()) {
String k = e.getKey();
String v = e.getValue();
Tag tag = new Tag(k, v);
tags.add(tag);
}
}
return tags;
}
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
@Override
public void processRow(ResultSet resultSet) throws SQLException {
String key;
String value;
Tag tag;
key = resultSet.getString("k");
value = resultSet.getString("v");
tag = new Tag(key, value);
listener.process(tag, resultSet);
}
}
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-apidb
/**
* {@inheritDoc}
*/
@Override
public void processRow(ResultSet resultSet) throws SQLException {
String key;
String value;
Tag tag;
key = resultSet.getString("k");
value = resultSet.getString("v");
tag = new Tag(key, value);
listener.process(tag, resultSet);
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* {@inheritDoc}
*/
@Override
public DbFeature<Tag> buildEntity(ResultSet resultSet) {
try {
return new DbFeature<Tag>(
resultSet.getLong("entity_id"),
new Tag(
resultSet.getString("k"),
resultSet.getString("v")
)
);
} catch (SQLException e) {
throw new OsmosisRuntimeException("Unable to build a tag from the current recordset row.", e);
}
}
代码示例来源:origin: openstreetmap/osmosis
private void buildTags(CommonEntityData entityData, List<Integer> keys, List<Integer> values,
PbfFieldDecoder fieldDecoder) {
Collection<Tag> tags = entityData.getTags();
// Ensure parallel lists are of equal size.
if (keys.size() != values.size()) {
throw new OsmosisRuntimeException("Number of tag keys (" + keys.size() + ") and tag values ("
+ values.size() + ") don't match");
}
Iterator<Integer> keyIterator = keys.iterator();
Iterator<Integer> valueIterator = values.iterator();
while (keyIterator.hasNext()) {
String key = fieldDecoder.decodeString(keyIterator.next());
String value = fieldDecoder.decodeString(valueIterator.next());
Tag tag = new Tag(key, value);
tags.add(tag);
}
}
代码示例来源: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 TagCollectionImpl(StoreReader sr, StoreClassRegister scr) {
super(new ArrayList<Tag>());
int tagCount;
tagCount = sr.readCharacter();
for (int i = 0; i < tagCount; i++) {
add(new Tag(sr, scr));
}
}
代码示例来源:origin: org.openstreetmap.osmosis/osmosis-core
/**
* 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 TagCollectionImpl(StoreReader sr, StoreClassRegister scr) {
super(new ArrayList<Tag>());
int tagCount;
tagCount = sr.readCharacter();
for (int i = 0; i < tagCount; i++) {
add(new Tag(sr, scr));
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Way cloning test.
*/
@Test
public void testWayClone() {
// Build the original entity.
List<Tag> tags = new ArrayList<Tag>();
tags.add(new Tag("myKey", "myValue"));
List<WayNode> wayNodes = new ArrayList<WayNode>();
wayNodes.add(new WayNode(1));
Way entity = new Way(new CommonEntityData(1, 2, new Date(0), OsmUser.NONE, 3, tags), wayNodes);
// Cloning a writeable object should return the original object.
Assert.assertSame("Entity was cloned", entity, entity.getWriteableInstance());
// Get a cloned entity.
entity.makeReadOnly();
Way clonedEntity = entity.getWriteableInstance();
// Make sure we weren't assigned the original entity.
Assert.assertNotSame("Entity was not cloned", entity, clonedEntity);
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Node cloning test.
*/
@Test
public void testNodeClone() {
// Build the original entity.
List<Tag> tags = new ArrayList<Tag>();
tags.add(new Tag("myKey", "myValue"));
Node entity = new Node(new CommonEntityData(1, 2, new Date(0), OsmUser.NONE, 3, tags), 4, 5);
// Cloning a writeable object should return the original object.
Assert.assertSame("Entity was cloned", entity, entity.getWriteableInstance());
// Get a cloned entity.
entity.makeReadOnly();
Node clonedEntity = entity.getWriteableInstance();
// Make sure we weren't assigned the original entity.
Assert.assertNotSame("Entity was not cloned", entity, clonedEntity);
}
代码示例来源: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: openstreetmap/osmosis
/**
* Test processing a Relation.
*/
@Test
public final void testProcess8() {
Relation testRelation;
testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
testRelation.getTags().add(new Tag("test_key1", "test_value1"));
testOsmWriter.process(new RelationContainer(testRelation));
// Nothing to assert; just expect no exception
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Test processing a Way.
*/
@Test
public final void testProcess6() {
Way testWay;
testWay = new Way(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
testWay.getWayNodes().add(new WayNode(1234));
testWay.getWayNodes().add(new WayNode(1235));
testWay.getTags().add(new Tag("test_key1", "test_value1"));
testOsmWriter.process(new WayContainer(testWay));
// Nothing to assert; just expect no exception
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Test writing out a normal Node element.
*/
@Test
public final void testProcessNormalNode() {
Node node =
new Node(
new CommonEntityData(1234, 2, timestamp, new OsmUser(23, "someuser"), 0),
20.12345678, -21.98765432);
node.getTags().add(new Tag("nodekey", "nodevalue"));
testNodeWriter.process(node);
try {
testBufferedWriter.flush();
} catch (IOException e) {
e.printStackTrace();
fail("IOException");
}
String[] strArray = testWriter.toString().split("\\n", 3);
assertTrue("Node opening element does not match.", strArray[0].matches(nodeOpeningMatch));
assertTrue("Node tag does not match.", strArray[1].matches(nodeTagMatch));
assertTrue("Node closing element does not match.", strArray[2].matches(nodeClosingMatch));
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Test processing a Bound after a Relation.
*/
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess9() {
Relation testRelation;
testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
testRelation.getTags().add(new Tag("test_key1", "test_value1"));
testOsmWriter.process(new RelationContainer(testRelation));
testOsmWriter.process(new BoundContainer(new Bound("source")));
}
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Test processing a Bound after a Way.
*/
@Test(expected = OsmosisRuntimeException.class)
public final void testProcess7() {
Way testWay;
testWay = new Way(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
testWay.getWayNodes().add(new WayNode(1234));
testWay.getWayNodes().add(new WayNode(1235));
testWay.getTags().add(new Tag("test_key1", "test_value1"));
testOsmWriter.process(new WayContainer(testWay));
testOsmWriter.process(new BoundContainer(new Bound("source")));
}
内容来源于网络,如有侵权,请联系作者删除!