/** * Creates a new instance. */ public PersistentNodeLocationStore() { stage = StorageStage.NotStarted; lastNodeId = Long.MIN_VALUE; zeroBuffer = new byte[ZERO_BUFFER_SIZE]; Arrays.fill(zeroBuffer, (byte) 0); invalidNodeLocation = new NodeLocation(); }
/** * {@inheritDoc} */ @Override public void store(StoreWriter writer, StoreClassRegister storeClassRegister) { writer.writeDouble(nodeLocation.getLongitude()); writer.writeDouble(nodeLocation.getLatitude()); }
store.addLocation(i * 2, new NodeLocation(longitude, latitude)); Assert.assertTrue("The node location should be valid.", location.isValid()); Assert.assertEquals("The longitude is incorrect.", longitude, location.getLongitude(), 0); Assert.assertEquals("The latitude is incorrect.", latitude, location.getLatitude(), 0); Assert.assertFalse("The node location should be invalid.", location.isValid());
/** * Builds a linestring geometry object from the node references in the * specified way. Unknown nodes will be ignored. * * @param way * The way to create the linestring for. * @return The linestring representing the way. */ public LineString createWayLinestring(Way way) { List<Point> linePoints; linePoints = new ArrayList<Point>(); for (WayNode wayNode : way.getWayNodes()) { NodeLocation nodeLocation; nodeLocation = locationStore.getNodeLocation(wayNode.getNodeId()); if (nodeLocation.isValid()) { linePoints.add(new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude())); } else { return null; } } return createLinestring(linePoints); }
longitude = nodeLocation.getLongitude(); latitude = nodeLocation.getLatitude(); if (nodeLocation.isValid()) { if (nodesFound) { if (longitude < left) {
/** * @param nodeId * Id of the node. * @return Point object */ public Point createPoint(long nodeId) { NodeLocation nodeLocation = locationStore.getNodeLocation(nodeId); Point point = new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude()); point.srid = 4326; return point; }
/** * Creates a new instance. */ public InMemoryNodeLocationStore() { buffers = new ArrayList<byte[]>(); invalidNodeLocation = new NodeLocation(); }
FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLongitude()), buffer, bufferOffset); bufferOffset += 4; writeIntToBuffer( FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLatitude()), buffer, bufferOffset); bufferOffset += 4;
/** * 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 CompactPersistentNodeLocation(StoreReader sr, StoreClassRegister scr) { nodeLocation = new NodeLocation(sr.readDouble(), sr.readDouble()); }
dataOutStream.writeInt(FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLongitude())); dataOutStream.writeInt(FixedPrecisionCoordinateConvertor.convertToFixed(nodeLocation.getLatitude())); currentFileOffset += NODE_DATA_SIZE;
/** * Adds the location of the node to the internal store. * * @param node * The node to add. */ public void addNodeLocation(Node node) { locationStore.addLocation(node.getId(), new NodeLocation(node.getLongitude(), node.getLatitude())); }
bufferOffset += 4; nodeLocation = new NodeLocation( FixedPrecisionCoordinateConvertor.convertToDouble(longitude), FixedPrecisionCoordinateConvertor.convertToDouble(latitude)
nodeLocation = new NodeLocation( FixedPrecisionCoordinateConvertor.convertToDouble(dataInStream.readInt()), FixedPrecisionCoordinateConvertor.convertToDouble(dataInStream.readInt())
/** * {@inheritDoc} */ @Override public NodeLocation getNodeLocation(long nodeId) { if (nodeLocationsReader == null) { nodeLocations.complete(); nodeLocationsReader = nodeLocations.createReader(); } try { return nodeLocationsReader.get(nodeId).getNodeLocation(); } catch (NoSuchIndexElementException e) { return new NodeLocation(); } }