當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。