本文整理汇总了Java中org.openstreetmap.osmosis.osmbinary.Osmformat.DenseInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Osmformat.DenseInfo方法的具体用法?Java Osmformat.DenseInfo怎么用?Java Osmformat.DenseInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstreetmap.osmosis.osmbinary.Osmformat
的用法示例。
在下文中一共展示了Osmformat.DenseInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDense
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
protected void parseDense(Osmformat.DenseNodes nodes) {
long lastId=0;
long lastLat=0;
long lastLon=0;
long lastTimestamp=0;
long lastChangeset=0;
int lastUid=0;
int lastSid=0;
int tagLocation =0;
for (int i=0 ; i< nodes.getIdCount() ; i++) {
Node n = new Node();
Primitive p = new Primitive();
lastId += nodes.getId(i);
lastLat += nodes.getLat(i);
lastLon += nodes.getLon(i);
p.setId(lastId);
n.setLatitude(parseLat(lastLat));
n.setLongitude(parseLon(lastLon));
//Weird spec - keys and values are mashed sequentially, and end of data for a particular node is denoted by a value of 0
if (nodes.getKeysValsCount() > 0) {
Map<CharSequence, CharSequence> tags = new HashMap<>(nodes.getKeysValsCount());
while (nodes.getKeysVals(tagLocation) > 0){
String k = getStringById(nodes.getKeysVals(tagLocation));
tagLocation++;
String v = getStringById(nodes.getKeysVals(tagLocation));
tagLocation++;
tags.put(k,v);
}
p.setTags(tags);
}
if (nodes.hasDenseinfo()){
Osmformat.DenseInfo di = nodes.getDenseinfo();
lastTimestamp += di.getTimestamp(i);
lastChangeset += di.getChangeset(i);
lastUid += di.getUid(i);
lastSid += di.getUserSid(i);
p.setTimestamp(lastTimestamp);
p.setChangesetId(lastChangeset);
p.setUserId((long)lastUid);
p.setUserName(getStringById(lastSid));
if (di.getVisibleCount() > 0){
p.setVisible(di.getVisible(i));
}
}
n.setCommon(p);
try {
nodeWriter.append(n);
}
catch (IOException e) {
LOGGER.error("Unable to write dense node", e);
}
}
}
示例2: parseDense
import org.openstreetmap.osmosis.osmbinary.Osmformat; //导入方法依赖的package包/类
@Override
protected void parseDense(
Osmformat.DenseNodes nodes ) {
long lastId = 0;
long lastLat = 0;
long lastLon = 0;
long lastTimestamp = 0;
long lastChangeset = 0;
int lastUid = 0;
int lastSid = 0;
int tagLocation = 0;
for (int i = 0; i < nodes.getIdCount(); i++) {
Node n = new Node();
Primitive p = new Primitive();
lastId += nodes.getId(i);
lastLat += nodes.getLat(i);
lastLon += nodes.getLon(i);
p.setId(lastId);
n.setLatitude(parseLat(lastLat));
n.setLongitude(parseLon(lastLon));
// Weird spec - keys and values are mashed sequentially, and end
// of data for a particular node is denoted by a value of 0
if (nodes.getKeysValsCount() > 0) {
Map<String, String> tags = new HashMap<>(
nodes.getKeysValsCount());
while (nodes.getKeysVals(tagLocation) > 0) {
String k = getStringById(nodes.getKeysVals(tagLocation));
tagLocation++;
String v = getStringById(nodes.getKeysVals(tagLocation));
tagLocation++;
tags.put(
k,
v);
}
p.setTags(tags);
}
if (nodes.hasDenseinfo()) {
Osmformat.DenseInfo di = nodes.getDenseinfo();
lastTimestamp += di.getTimestamp(i);
lastChangeset += di.getChangeset(i);
lastUid += di.getUid(i);
lastSid += di.getUserSid(i);
p.setTimestamp(lastTimestamp);
p.setChangesetId(lastChangeset);
p.setUserId((long) lastUid);
p.setUserName(getStringById(lastSid));
if (di.getVisibleCount() > 0) {
p.setVisible(di.getVisible(i));
}
}
n.setCommon(p);
try {
nodeWriter.append(n);
}
catch (IOException e) {
LOGGER.error(
"Unable to write dense node",
e);
}
}
}