private HDTileBasedDataProcessor(MapWriterConfiguration configuration) { super(configuration); this.indexedNodeStore = new IndexedObjectStore<>(new SingleClassObjectSerializationFactory(Node.class), "idxNodes"); this.indexedWayStore = new IndexedObjectStore<>(new SingleClassObjectSerializationFactory(Way.class), "idxWays"); // indexedRelationStore = new IndexedObjectStore<Relation>( // new SingleClassObjectSerializationFactory( // Relation.class), "idxWays"); this.wayStore = new SimpleObjectStore<>(new SingleClassObjectSerializationFactory(Way.class), "heapWays", true); this.relationStore = new SimpleObjectStore<>(new SingleClassObjectSerializationFactory(Relation.class), "heapRelations", true); this.tileData = new HDTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][]; for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { this.tileData[i] = new HDTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i] .getAmountTilesVertical()]; } this.virtualWays = new TLongObjectHashMap<>(); this.additionalRelationTags = new TLongObjectHashMap<>(); }
@Override public void addRelation(Relation relation) { super.addRelation(relation); this.relationStore.add(relation); }
/** * {@inheritDoc} */ public void store(StoreWriter sw, StoreClassRegister scr) { new GenericObjectWriter(sw, scr).writeObject(entity); sw.writeBoolean(visible); }
@Override public void complete() { this.indexedNodeStore.complete(); this.nodeIndexReader = this.indexedNodeStore.createReader(); this.indexedWayStore.complete(); this.wayIndexReader = this.indexedWayStore.createReader(); ReleasableIterator<Way> wayReader = this.wayStore.iterate(); while (wayReader.hasNext()) { if (this.progressLogs) { ReleasableIterator<Relation> relationReader = this.relationStore.iterate(); RelationHandler relationHandler = new RelationHandler(); while (relationReader.hasNext()) { wayReader = this.wayStore.iterate(); WayHandler wayHandler = new WayHandler(); while (wayReader.hasNext()) {
/** * {@inheritDoc} */ public void store(StoreWriter sw, StoreClassRegister scr) { new GenericObjectWriter(sw, scr).writeObject(feature); sw.writeInteger(version); }
@Override public TDWay getWay(long id) { if (this.wayIndexReader == null) { throw new IllegalStateException("way store not accessible, call complete() first"); } try { return TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguages); } catch (NoSuchIndexElementException e) { LOGGER.finer("way cannot be found in index: " + id); return null; } }
/** * Iterates over the entire stream of data. * * @param offset * The location in the storage file to begin reading. * @return An iterator for reading objects from the data store. This * iterator must be released after use. */ public Iterator<T> iterate(long offset) { seek(offset); return new ObjectDataInputIterator<T>(objectReader); }
/** * {@inheritDoc} */ @Override public void complete() { // Any outstanding chunks must be closed before we can complete. closeChunk(); indexStore.complete(); }
@Override public void addNode(Node node) { super.addNode(node); this.indexedNodeStore.add(node.getId(), node); TDNode tdNode = TDNode.fromNode(node, this.preferredLanguages); addPOI(tdNode); }
@Override public TDNode getNode(long id) { if (this.nodeIndexReader == null) { throw new IllegalStateException("node store not accessible, call complete() first"); } try { return TDNode.fromNode(this.nodeIndexReader.get(id), this.preferredLanguages); } catch (NoSuchIndexElementException e) { LOGGER.finer("node cannot be found in index: " + id); return null; } }
private List<TDWay> getInnerWaysOfMultipolygon(long[] innerWayIDs) { if (innerWayIDs == null) { return Collections.emptyList(); } List<TDWay> res = new ArrayList<>(); for (long id : innerWayIDs) { TDWay current = null; try { current = TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguages); } catch (NoSuchIndexElementException e) { current = this.virtualWays.get(id); if (current == null) { LOGGER.fine("multipolygon with outer way id " + id + " references non-existing inner way " + id); continue; } } res.add(current); } return res; } }
@Override public Set<TDWay> getCoastLines(TileCoordinate tc) { if (tc.getZoomlevel() <= TileInfo.TILE_INFO_ZOOMLEVEL) { return Collections.emptySet(); } TileCoordinate correspondingOceanTile = tc.translateToZoomLevel(TileInfo.TILE_INFO_ZOOMLEVEL).get(0); if (this.wayIndexReader == null) { throw new IllegalStateException("way store not accessible, call complete() first"); } TLongHashSet coastlines = this.tilesToCoastlines.get(correspondingOceanTile); if (coastlines == null) { return Collections.emptySet(); } TLongIterator it = coastlines.iterator(); HashSet<TDWay> coastlinesAsTDWay = new HashSet<>(coastlines.size()); while (it.hasNext()) { long id = it.next(); TDWay tdWay = null; try { tdWay = TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguages); } catch (NoSuchIndexElementException e) { LOGGER.finer("coastline way non-existing" + id); } if (tdWay != null) { coastlinesAsTDWay.add(tdWay); } } return coastlinesAsTDWay; }
TLongIterator it = hdt.getPois().iterator(); while (it.hasNext()) { td.addPOI(TDNode.fromNode(this.nodeIndexReader.get(it.next()), this.preferredLanguages)); long id = it.next(); try { way = TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguages); td.addWay(way); } catch (NoSuchIndexElementException e) {