From cf3ca008c09c66c33b547473694a502f550e7161 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Wed, 17 Jun 2020 15:46:34 +0300 Subject: [PATCH] Remove BinaryMapIndexTestReader --- .../binary/BinaryMapIndexTestReader.java | 219 ------------------ 1 file changed, 219 deletions(-) delete mode 100644 OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexTestReader.java diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexTestReader.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexTestReader.java deleted file mode 100644 index ce76f14e1d..0000000000 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapIndexTestReader.java +++ /dev/null @@ -1,219 +0,0 @@ -package net.osmand.binary; - -import net.osmand.binary.BinaryMapPoiReaderAdapter.PoiRegion; -import net.osmand.data.Amenity; -import net.osmand.data.Building; -import net.osmand.data.City; -import net.osmand.data.MapObject; -import net.osmand.data.Street; -import net.osmand.util.Algorithms; - -import org.json.JSONArray; -import org.json.JSONObject; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static net.osmand.binary.BinaryMapAddressReaderAdapter.AddressRegion; - -public class BinaryMapIndexTestReader extends BinaryMapIndexReader { - - private List amenities = Collections.emptyList(); - private List cities = Collections.emptyList(); - private List initCities = Collections.emptyList(); - private List matchedCities = Collections.emptyList(); - private List streetCities = Collections.emptyList(); - - private BinaryMapIndexTestReader() throws IOException { - super(null, null, false); - version = 2; - dateCreated = System.currentTimeMillis(); - } - - public static BinaryMapIndexReader buildTestReader(File jsonFile) throws IOException { - String sourceJsonText = Algorithms.getFileAsString(jsonFile); - JSONObject sourceJson = null; - if (!Algorithms.isEmpty(sourceJsonText)) { - sourceJson = new JSONObject(sourceJsonText); - } - if (sourceJson == null) { - return null; - } - BinaryMapIndexTestReader reader = new BinaryMapIndexTestReader(); - if (sourceJson.has("amenities")) { - JSONArray amenitiesArr = sourceJson.getJSONArray("amenities"); - List amenities = new ArrayList<>(); - for (int i = 0; i < amenitiesArr.length(); i++) { - JSONObject amenityObj = amenitiesArr.getJSONObject(i); - amenities.add(Amenity.parseJSON(amenityObj)); - } - reader.amenities = amenities; - PoiRegion region = new PoiRegion(); - region.name = Algorithms.getFileNameWithoutExtension(jsonFile); - region.left31 = 0; - region.top31 = 0; - region.right31 = Integer.MAX_VALUE; - region.bottom31 = Integer.MAX_VALUE; - reader.poiIndexes.add(region); - reader.indexes.add(region); - } - if (sourceJson.has("cities")) { - JSONArray citiesArr = sourceJson.getJSONArray("cities"); - Set attributeTagsTable = new HashSet<>(); - List cities = new ArrayList<>(); - List initCities = new ArrayList<>(); - List matchedCities = new ArrayList<>(); - List streetCities = new ArrayList<>(); - for (int i = 0; i < citiesArr.length(); i++) { - JSONObject cityObj = citiesArr.getJSONObject(i); - final City city = City.parseJSON(cityObj); - cities.add(city); - if (cityObj.has("init")) { - initCities.add(city); - } - if (cityObj.has("matchCity")) { - matchedCities.add(city); - } - if (cityObj.has("matchStreet")) { - streetCities.add(city); - } - Set names = city.getNamesMap(false).keySet(); - for (String name : names) { - attributeTagsTable.add("name:" + name); - } - for (Street street : city.getStreets()) { - names = street.getNamesMap(false).keySet(); - for (String name : names) { - attributeTagsTable.add("name:" + name); - } - } -// attributeTagsTable.add("name"); -// attributeTagsTable.add("name:en"); - } - reader.cities = cities; - reader.initCities = initCities; - reader.matchedCities = matchedCities; - reader.streetCities = streetCities; - - AddressRegion region = new AddressRegion(); - region.name = Algorithms.getFileNameWithoutExtension(jsonFile); - region.left31 = 0; - region.top31 = 0; - region.right31 = Integer.MAX_VALUE; - region.bottom31 = Integer.MAX_VALUE; - region.attributeTagsTable = new ArrayList<>(attributeTagsTable); - reader.addressIndexes.add(region); - reader.indexes.add(region); - } - return reader; - } - - @Override - public List searchPoiByName(SearchRequest req) throws IOException { - for (Amenity amenity : amenities) { - req.publish(amenity); - } - return req.getSearchResults(); - } - - @Override - public List searchPoi(SearchRequest req) throws IOException { - for (Amenity amenity : amenities) { - req.publish(amenity); - } - return req.getSearchResults(); - } - - @Override - public List getCities(AddressRegion region, SearchRequest resultMatcher, int cityType) throws IOException { - return getCities(resultMatcher, cityType); - } - - @Override - public List getCities(SearchRequest resultMatcher, int cityType) throws IOException { - for (City city : cities) { - if (resultMatcher != null) { - resultMatcher.publish(city); - } - } - return cities; - } - - @Override - public int preloadStreets(City c, SearchRequest resultMatcher) throws IOException { - return 0; - } - - @Override - public void preloadBuildings(Street s, SearchRequest resultMatcher) throws IOException { - // cities must be filled with streets and buildings - } - - @Override - public List searchAddressDataByName(SearchRequest req) throws IOException { - for (City city : streetCities) { - for (Street street : city.getStreets()) { - req.publish(street); - } - } - for (City city : matchedCities) { - req.publish(city); - } - return req.getSearchResults(); - } - - @Override - public String getRegionName() { - return "Test region"; - } - - @Override - public boolean containsPoiData(int left31x, int top31y, int right31x, int bottom31y) { - return true; - } - - @Override - public boolean containsMapData() { - return true; - } - - @Override - public boolean containsPoiData() { - return true; - } - - @Override - public boolean containsRouteData() { - return true; - } - - @Override - public boolean containsRouteData(int left31x, int top31y, int right31x, int bottom31y, int zoom) { - return true; - } - - @Override - public boolean containsAddressData(int left31x, int top31y, int right31x, int bottom31y) { - return true; - } - - @Override - public boolean containsMapData(int tile31x, int tile31y, int zoom) { - return true; - } - - @Override - public boolean containsMapData(int left31x, int top31y, int right31x, int bottom31y, int zoom) { - return true; - } - - @Override - public boolean containsAddressData() { - return true; - } -}