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


Java Node类代码示例

本文整理汇总了Java中com.conveyal.osmlib.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于com.conveyal.osmlib包,在下文中一共展示了Node类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLineStringForWay

import com.conveyal.osmlib.Node; //导入依赖的package包/类
static public LineString getLineStringForWay(Way way, OSM osm) {
	Coordinate[] coords = new Coordinate[way.nodes.length];
	for (int i = 0; i < coords.length; i++) {
		Long nd = way.nodes[i];
		Node node = osm.nodes.get(nd);

		if (node == null) {
			throw new RuntimeException("Way contains unknown node " + nd);
		}

		coords[i] = new Coordinate(node.getLon(), node.getLat());
	}

	return new GeometryFactory().createLineString(coords);
}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:16,代码来源:OSMUtils.java

示例2: deserialize

import com.conveyal.osmlib.Node; //导入依赖的package包/类
@Override
public Node deserialize(DataInput in, int available) throws IOException {
    Node node = new Node();
    node.fixedLat = in.readInt();
    node.fixedLon = in.readInt();
    VarInt.readTags(in, node);
    return node;
}
 
开发者ID:conveyal,项目名称:osm-lib,代码行数:9,代码来源:NodeSerializer.java

示例3: writeNode

import com.conveyal.osmlib.Node; //导入依赖的package包/类
@Override
public void writeNode(long id, Node node) throws IOException {
    Shape line = new Line2D.Double(node.getLon(), node.getLat(), node.getLon(), node.getLat());
    g2d.draw(line);
}
 
开发者ID:conveyal,项目名称:osm-lib,代码行数:6,代码来源:GraphicsSink.java

示例4: serialize

import com.conveyal.osmlib.Node; //导入依赖的package包/类
@Override
public void serialize(DataOutput out, Node node) throws IOException {
    out.writeInt(node.fixedLat);
    out.writeInt(node.fixedLon);
    VarInt.writeTags(out, node);
}
 
开发者ID:conveyal,项目名称:osm-lib,代码行数:7,代码来源:NodeSerializer.java

示例5: addOsm

import com.conveyal.osmlib.Node; //导入依赖的package包/类
private OSMArea addOsm(Fun.Tuple2<Integer, Integer> tile, Envelope env, OSM osm, Boolean keepCompleteGeometries) {


		String placeName = null;
		Long placePop = null;

		for( Entry<Long, Node> entry : osm.nodes.entrySet() ) {

			Long id = entry.getKey();
			Node node = entry.getValue();
			if (id ==259009337) {
				try {
					long pop = Long.parseLong(node.getTag("population"));
					if (placePop == null || placePop < pop) {
						placePop = pop;
						placeName = node.getTag("name");
					}
				} catch (Exception e) {

				}
			}
		}



		List<StreetSegment> segments = getStreetSegments(osm);


		List<SpatialDataItem> segmentItems = new ArrayList<>();
		List<SpatialDataItem> triplineItems = new ArrayList<>();

		for(StreetSegment segment : segments) {

			if(streetSegments.contains(segment.getSegmentId()))
				continue;

			if(segment.length > MIN_SEGMENT_LEN) {

				LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(segment.getGeometry());

				double scale = (lengthIndexedLine.getEndIndex() - lengthIndexedLine.getStartIndex()) / segment.length;

				List<TripLine> tripLines = new ArrayList<TripLine>();

				tripLines.add(createTripLine(segment, 1, lengthIndexedLine, (OSMDataStore.INTERSECTION_MARGIN_METERS) * scale, OSMDataStore.INTERSECTION_MARGIN_METERS));
				tripLines.add(createTripLine(segment, 2, lengthIndexedLine, ((segment.length - OSMDataStore.INTERSECTION_MARGIN_METERS) * scale), segment.length - OSMDataStore.INTERSECTION_MARGIN_METERS));

				for(TripLine tripLine : tripLines) {
					triplineItems.add(tripLine);
				}
			}
			else {
				jumperDataStore.addJumper(new Jumper(segment));
			}
			
			if(!keepCompleteGeometries)
				segment.truncateGeometry();

			segmentItems.add(segment);

		}

		streetSegments.save(segmentItems);
		jumperDataStore.save();

		triplines.save(triplineItems);

		long zoneOffset =  timeZoneConverter.getOffsetForCoord(env.centre());

		OSMArea osmArea = new OSMArea(osmAreaIds.getNextId(), tile.a, tile.b, Z_INDEX, placeName, placePop, zoneOffset, env);

		osmAreas.put(tile, osmArea);
		db.commit();

		System.out.println("Loaded OSM " + tile.a + ", " + tile.b);
		if(placeName != null)
			System.out.println("\t" + placeName + ", " + placePop);

		return osmArea;
	}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:81,代码来源:OSMDataStore.java


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