private void _setNode(int id, double lat, double lon, double ele) { long tmp = (long) id * rowSizeInBytes; da.incCapacity(tmp + rowSizeInBytes); da.setInt(tmp + LAT, Helper.degreeToInt(lat)); da.setInt(tmp + LON, Helper.degreeToInt(lon)); if (is3D()) da.setInt(tmp + ELE, Helper.eleToInt(ele)); }
@Override public boolean addNode(long osmId, double lat, double lon) { int nodeType = osmIdToIndexMap.get(osmId); if (nodeType == EMPTY) return false; if (nodeType == TOWER_NODE) { addTowerNode(osmId, lat, lon); } else if (nodeType == PILLAR_NODE) { int tmp = (pillarId + 1) * 4; pillarLats.ensureCapacity(tmp); pillarLats.setInt(pillarId, Helper.degreeToInt(lat)); pillarLons.ensureCapacity(tmp); pillarLons.setInt(pillarId, Helper.degreeToInt(lon)); osmIdToIndexMap.put(osmId, pillarId + 3); pillarId++; } return true; }
@Test public void testHeader() { DataAccess da = createDataAccess(name); da.create(300); da.setHeader(7 * 4, 123); assertEquals(123, da.getHeader(7 * 4)); da.setHeader(10 * 4, Integer.MAX_VALUE / 3); assertEquals(Integer.MAX_VALUE / 3, da.getHeader(10 * 4)); da.setHeader(11 * 4, Helper.degreeToInt(123.321)); assertEquals(123.321, Helper.intToDegree(da.getHeader(11 * 4)), 1e-4); da.flush(); da.close(); da = createDataAccess(name); assertTrue(da.loadExisting()); assertEquals(123, da.getHeader(7 * 4)); da.close(); }