当前位置: 首页>>代码示例>>Java>>正文


Java Osmformat.DenseInfo方法代码示例

本文整理汇总了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);
		}

	}
}
 
开发者ID:ngageoint,项目名称:geowave-osm,代码行数:69,代码来源:OsmPbfParser.java

示例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);
		}

	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:74,代码来源:OsmPbfParser.java


注:本文中的org.openstreetmap.osmosis.osmbinary.Osmformat.DenseInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。