public void initCategories(PoiRegion region) throws IOException { if (region.categories.isEmpty()) { codedIS.seek(region.filePointer); int oldLimit = codedIS.pushLimit(region.length); readPoiIndex(region, true); codedIS.popLimit(oldLimit); } }
public void initRouteRegion(RouteRegion routeReg) throws IOException, InvalidProtocolBufferException { if (routeReg.routeEncodingRules.isEmpty()) { codedIS.seek(routeReg.filePointer); int oldLimit = codedIS.pushLimit(routeReg.length); readRouteIndex(routeReg); codedIS.popLimit(oldLimit); } }
public List<City> getCities(AddressRegion region, SearchRequest<City> resultMatcher, StringMatcher matcher, int cityType) throws IOException { List<City> cities = new ArrayList<City>(); for (CitiesBlock block : region.cities) { if (block.type == cityType) { codedIS.seek(block.filePointer); int old = codedIS.pushLimit(block.length); addressAdapter.readCities(cities, resultMatcher, matcher, region.attributeTagsTable); codedIS.popLimit(old); } } return cities; }
public List<City> getCities(SearchRequest<City> resultMatcher, StringMatcher matcher, String lang, int cityType) throws IOException { List<City> cities = new ArrayList<City>(); for (AddressRegion r : addressIndexes) { for (CitiesBlock block : r.cities) { if (block.type == cityType) { codedIS.seek(block.filePointer); int old = codedIS.pushLimit(block.length); addressAdapter.readCities(cities, resultMatcher, matcher, r.attributeTagsTable); codedIS.popLimit(old); } } } return cities; }
public List<Amenity> searchPoiByName(SearchRequest<Amenity> req) throws IOException { if (req.nameQuery == null || req.nameQuery.length() == 0) { throw new IllegalArgumentException(); } for (PoiRegion poiIndex : poiIndexes) { poiAdapter.initCategories(poiIndex); codedIS.seek(poiIndex.filePointer); int old = codedIS.pushLimit(poiIndex.length); poiAdapter.searchPoiByName(poiIndex, req); codedIS.popLimit(old); } return req.getSearchResults(); }
public List<Amenity> searchPoi(PoiRegion poiIndex, SearchRequest<Amenity> req) throws IOException { req.numberOfVisitedObjects = 0; req.numberOfAcceptedObjects = 0; req.numberOfAcceptedSubtrees = 0; req.numberOfReadSubtrees = 0; poiAdapter.initCategories(poiIndex); codedIS.seek(poiIndex.filePointer); int old = codedIS.pushLimit(poiIndex.length); poiAdapter.searchPoiIndex(req.left, req.right, req.top, req.bottom, req, poiIndex); codedIS.popLimit(old); log.info("Search poi is done. Visit " + req.numberOfVisitedObjects + " objects. Read " + req.numberOfAcceptedObjects + " objects."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ log.info("Read " + req.numberOfReadSubtrees + " subtrees. Go through " + req.numberOfAcceptedSubtrees + " subtrees."); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ return req.getSearchResults(); }
public List<Amenity> searchPoi(SearchRequest<Amenity> req) throws IOException { req.numberOfVisitedObjects = 0; req.numberOfAcceptedObjects = 0; req.numberOfAcceptedSubtrees = 0; req.numberOfReadSubtrees = 0; for (PoiRegion poiIndex : poiIndexes) { poiAdapter.initCategories(poiIndex); codedIS.seek(poiIndex.filePointer); int old = codedIS.pushLimit(poiIndex.length); poiAdapter.searchPoiIndex(req.left, req.right, req.top, req.bottom, req, poiIndex); codedIS.popLimit(old); } log.info("Read " + req.numberOfReadSubtrees + " subtrees. Go through " + req.numberOfAcceptedSubtrees + " subtrees."); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ log.info("Search poi is done. Visit " + req.numberOfVisitedObjects + " objects. Read " + req.numberOfAcceptedObjects + " objects."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return req.getSearchResults(); }
public List<MapObject> searchAddressDataByName(SearchRequest<MapObject> req, List<Integer> typeFilter) throws IOException { for (AddressRegion reg : addressIndexes) { if (reg.indexNameOffset != -1) { codedIS.seek(reg.indexNameOffset); int len = readInt(); int old = codedIS.pushLimit(len); addressAdapter.searchAddressDataByName(reg, req, typeFilter); codedIS.popLimit(old); } } return req.getSearchResults(); }
public List<RouteDataObject> loadRouteRegionData(RouteSubregion rs) throws IOException { TLongArrayList idMap = new TLongArrayList(); TLongObjectHashMap<RestrictionInfo> restrictionMap = new TLongObjectHashMap<RestrictionInfo>(); if (rs.dataObjects == null) { codedIS.seek(rs.filePointer + rs.shiftToData); int limit = codedIS.readRawVarint32(); int oldLimit = codedIS.pushLimit(limit); readRouteTreeData(rs, idMap, restrictionMap); codedIS.popLimit(oldLimit); } List<RouteDataObject> res = rs.dataObjects; rs.dataObjects = null; return res; }
public int preloadStreets(City c, SearchRequest<Street> resultMatcher) throws IOException { AddressRegion reg; try { reg = checkAddressIndex(c.getFileOffset()); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage() + " while reading " + c + " (id: " + c.getId() + ")"); } codedIS.seek(c.getFileOffset()); int size = codedIS.readRawVarint32(); int old = codedIS.pushLimit(size); addressAdapter.readCityStreets(resultMatcher, c, reg.attributeTagsTable); codedIS.popLimit(old); return size; }
public List<RouteSubregion> searchRouteRegionTree(SearchRequest<?> req, List<RouteSubregion> list, List<RouteSubregion> toLoad) throws IOException { for (RouteSubregion rs : list) { if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) { if (rs.subregions == null) { codedIS.seek(rs.filePointer); int old = codedIS.pushLimit(rs.length); readRouteTree(rs, null, req.contains(rs.left, rs.top, rs.right, rs.bottom) ? -1 : 1, false); codedIS.popLimit(old); } searchRouteRegionTree(req, rs.subregions, toLoad); if (rs.shiftToData != 0) { toLoad.add(rs); } } } return toLoad; }
public List<RouteSubregion> loadInteresectedPoints(SearchRequest<RouteDataObject> req, List<RouteSubregion> list, List<RouteSubregion> toLoad) throws IOException { for (RouteSubregion rs : list) { if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) { if (rs.subregions == null) { codedIS.seek(rs.filePointer); int old = codedIS.pushLimit(rs.length); readRouteTree(rs, null, req.contains(rs.left, rs.top, rs.right, rs.bottom) ? -1 : 1, false); codedIS.popLimit(old); } searchRouteRegionTree(req, rs.subregions, toLoad); if (rs.shiftToData != 0) { toLoad.add(rs); } } } return toLoad; }
public void loadRouteRegionData(List<RouteSubregion> toLoad, ResultMatcher<RouteDataObject> matcher) throws IOException { Collections.sort(toLoad, new Comparator<RouteSubregion>() { @Override public int compare(RouteSubregion o1, RouteSubregion o2) { int p1 = o1.filePointer + o1.shiftToData; int p2 = o2.filePointer + o2.shiftToData; return p1 == p2 ? 0 : (p1 < p2 ? -1 : 1); } }); TLongArrayList idMap = new TLongArrayList(); TLongObjectHashMap<RestrictionInfo> restrictionMap = new TLongObjectHashMap<RestrictionInfo>(); for (RouteSubregion rs : toLoad) { if (rs.dataObjects == null) { codedIS.seek(rs.filePointer + rs.shiftToData); int limit = codedIS.readRawVarint32(); int oldLimit = codedIS.pushLimit(limit); readRouteTreeData(rs, idMap, restrictionMap); codedIS.popLimit(oldLimit); } for (RouteDataObject ro : rs.dataObjects) { if (ro != null) { matcher.publish(ro); } } // free objects rs.dataObjects = null; } }
public List<TransportStop> searchTransportIndex(SearchRequest<TransportStop> req) throws IOException { for (TransportIndex index : transportIndexes) { if (index.stopsFileLength == 0 || index.right < req.left || index.left > req.right || index.top > req.bottom || index.bottom < req.top) { continue; } if (req.stringTable != null) { req.stringTable.clear(); } codedIS.seek(index.stopsFileOffset); int oldLimit = codedIS.pushLimit(index.stopsFileLength); int offset = req.searchResults.size(); transportAdapter.searchTransportTreeBounds(0, 0, 0, 0, req); codedIS.popLimit(oldLimit); if (req.stringTable != null) { transportAdapter.initializeStringTable(index, req.stringTable); for (int i = offset; i < req.searchResults.size(); i++) { TransportStop st = req.searchResults.get(i); transportAdapter.initializeNames(req.stringTable, st); } } } if (req.numberOfVisitedObjects > 0) { log.debug("Search is done. Visit " + req.numberOfVisitedObjects + " objects. Read " + req.numberOfAcceptedObjects + " objects."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ log.debug("Read " + req.numberOfReadSubtrees + " subtrees. Go through " + req.numberOfAcceptedSubtrees + " subtrees."); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } return req.getSearchResults(); }
public void preloadBuildings(Street s, SearchRequest<Building> resultMatcher) throws IOException { AddressRegion reg = checkAddressIndex(s.getFileOffset()); codedIS.seek(s.getFileOffset()); int size = codedIS.readRawVarint32(); int old = codedIS.pushLimit(size); City city = s.getCity(); addressAdapter.readStreet(s, resultMatcher, true, 0, 0, city != null && city.isPostcode() ? city.getName() : null, reg.attributeTagsTable); codedIS.popLimit(old); }
codedIS.popLimit(oldLimit); codedIS.seek(filePointer + length); break; case MapRootLevel.BLOCKS_FIELD_NUMBER :
protected void initializeStringTable(TransportIndex ind, TIntObjectHashMap<String> stringTable) throws IOException { int[] values = stringTable.keys(); Arrays.sort(values); codedIS.seek(ind.stringTable.fileOffset); int oldLimit = codedIS.pushLimit(ind.stringTable.length); int current = 0; int i = 0; while (i < values.length && codedIS.getBytesUntilLimit() > 0) { int t = codedIS.readTag(); int tag = WireFormat.getTagFieldNumber(t); switch (tag) { case 0: return; case OsmandOdb.StringTable.S_FIELD_NUMBER: if (current == values[i]) { String value = codedIS.readString(); stringTable.put(values[i], value); i++; } else { skipUnknownField(t); } current ++; break; default: skipUnknownField(t); break; } } codedIS.popLimit(oldLimit); }
codedIS.seek(st.length + st.fileOffset); break; default:
codedIS.seek(dataOffsets.get(i) + offset); int len = codedIS.readRawVarint32(); int oldLim = codedIS.pushLimit(len);
codedIS.popLimit(oldLimit); codedIS.seek(filePointer + length); break; default: