fix issue 184
git-svn-id: https://osmand.googlecode.com/svn/trunk@730 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
01a584e43a
commit
62b34f70a2
4 changed files with 49 additions and 5 deletions
|
@ -4,6 +4,7 @@ import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import net.osmand.Algoritms;
|
import net.osmand.Algoritms;
|
||||||
|
@ -48,16 +49,23 @@ public class City extends MapObject {
|
||||||
private CityType type = null;
|
private CityType type = null;
|
||||||
// Be attentive ! Working with street names ignoring case
|
// Be attentive ! Working with street names ignoring case
|
||||||
private Map<String, Street> streets = new TreeMap<String, Street>(Collator.getInstance());
|
private Map<String, Street> streets = new TreeMap<String, Street>(Collator.getInstance());
|
||||||
|
private String isin = null;
|
||||||
|
|
||||||
public City(Node el){
|
public City(Node el){
|
||||||
super(el);
|
super(el);
|
||||||
type = CityType.valueFromString(el.getTag(OSMTagKey.PLACE));
|
type = CityType.valueFromString(el.getTag(OSMTagKey.PLACE));
|
||||||
|
isin = el.getTag(OSMTagKey.IS_IN);
|
||||||
|
isin = isin != null ? isin.toLowerCase() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public City(CityType type){
|
public City(CityType type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIsInValue() {
|
||||||
|
return isin;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEmptyWithStreets(){
|
public boolean isEmptyWithStreets(){
|
||||||
return streets.isEmpty();
|
return streets.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class DataIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Street> readStreetsBuildings(PreparedStatement streetBuildingsStat, City city, List<Street> streets) throws SQLException {
|
public List<Street> readStreetsBuildings(PreparedStatement streetBuildingsStat, City city, List<Street> streets) throws SQLException {
|
||||||
return readStreetsBuildings(streetBuildingsStat, city, streets, null, null);
|
return readStreetsBuildings(streetBuildingsStat, city, streets, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreparedStatement getStreetsWayNodesPreparedStatement(Connection c) throws SQLException{
|
public PreparedStatement getStreetsWayNodesPreparedStatement(Connection c) throws SQLException{
|
||||||
|
@ -74,8 +74,26 @@ public class DataIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Street> readStreetsBuildings(PreparedStatement streetBuildingsStat, City city, List<Street> streets,
|
public List<Street> readStreetsBuildings(PreparedStatement streetBuildingsStat, City city, List<Street> streets,
|
||||||
PreparedStatement waynodesStat, Map<Street, List<Node>> streetNodes) throws SQLException {
|
PreparedStatement waynodesStat, Map<Street, List<Node>> streetNodes, List<City> citySuburbs) throws SQLException {
|
||||||
Map<Long, Street> visitedStreets = new LinkedHashMap<Long, Street>();
|
Map<Long, Street> visitedStreets = new LinkedHashMap<Long, Street>();
|
||||||
|
//read streets for city
|
||||||
|
readStreatsByBuildingsForCity(streetBuildingsStat, city, streets,
|
||||||
|
waynodesStat, streetNodes, visitedStreets);
|
||||||
|
//read streets for suburbs of the city
|
||||||
|
if (citySuburbs != null) {
|
||||||
|
for (City suburb : citySuburbs) {
|
||||||
|
readStreatsByBuildingsForCity(streetBuildingsStat, suburb, streets, waynodesStat, streetNodes, visitedStreets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return streets;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void readStreatsByBuildingsForCity(
|
||||||
|
PreparedStatement streetBuildingsStat, City city,
|
||||||
|
List<Street> streets, PreparedStatement waynodesStat,
|
||||||
|
Map<Street, List<Node>> streetNodes,
|
||||||
|
Map<Long, Street> visitedStreets) throws SQLException {
|
||||||
streetBuildingsStat.setLong(1, city.getId());
|
streetBuildingsStat.setLong(1, city.getId());
|
||||||
ResultSet set = streetBuildingsStat.executeQuery();
|
ResultSet set = streetBuildingsStat.executeQuery();
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
|
@ -112,7 +130,6 @@ public class DataIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
set.close();
|
set.close();
|
||||||
return streets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreparedStatement getStreetsPreparedStatement(Connection c) throws SQLException{
|
public PreparedStatement getStreetsPreparedStatement(Connection c) throws SQLException{
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.data.preparation;
|
||||||
|
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -1907,11 +1908,28 @@ public class IndexCreator {
|
||||||
|
|
||||||
Map<String, Set<Street>> postcodes = new TreeMap<String, Set<Street>>();
|
Map<String, Set<Street>> postcodes = new TreeMap<String, Set<Street>>();
|
||||||
boolean writeCities = true;
|
boolean writeCities = true;
|
||||||
|
|
||||||
|
// collect suburbs with is in value
|
||||||
|
List<City> suburbs = new ArrayList<City>();
|
||||||
|
for(City s : cities){
|
||||||
|
if(s.getType() == CityType.SUBURB && s.getIsInValue() != null){
|
||||||
|
suburbs.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write cities and after villages
|
// write cities and after villages
|
||||||
writer.startCityIndexes(false);
|
writer.startCityIndexes(false);
|
||||||
for (int i = 0; i < cities.size(); i++) {
|
for (int i = 0; i < cities.size(); i++) {
|
||||||
City c = cities.get(i);
|
City c = cities.get(i);
|
||||||
|
List<City> listSuburbs = null;
|
||||||
|
for (City suburb : suburbs) {
|
||||||
|
if (suburb.getIsInValue().contains(c.getName().toLowerCase())) {
|
||||||
|
if(listSuburbs == null){
|
||||||
|
listSuburbs = new ArrayList<City>();
|
||||||
|
}
|
||||||
|
listSuburbs.add(suburb);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (writeCities) {
|
if (writeCities) {
|
||||||
progress.progress(1);
|
progress.progress(1);
|
||||||
} else if ((cities.size() - i) % 100 == 0) {
|
} else if ((cities.size() - i) % 100 == 0) {
|
||||||
|
@ -1929,7 +1947,7 @@ public class IndexCreator {
|
||||||
streetNodes = new LinkedHashMap<Street, List<Node>>();
|
streetNodes = new LinkedHashMap<Street, List<Node>>();
|
||||||
}
|
}
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
reader.readStreetsBuildings(streetstat, c, streets, waynodesStat, streetNodes);
|
reader.readStreetsBuildings(streetstat, c, streets, waynodesStat, streetNodes, listSuburbs);
|
||||||
long f = System.currentTimeMillis() - time;
|
long f = System.currentTimeMillis() - time;
|
||||||
writer.writeCityIndex(c, streets, streetNodes);
|
writer.writeCityIndex(c, streets, streetNodes);
|
||||||
int bCount = 0;
|
int bCount = 0;
|
||||||
|
@ -2605,7 +2623,7 @@ public class IndexCreator {
|
||||||
private NewDataExtractionOsmFilter extractOsmToNodesDB(File readFile, IProgress progress, IOsmStorageFilter addFilter) throws FileNotFoundException,
|
private NewDataExtractionOsmFilter extractOsmToNodesDB(File readFile, IProgress progress, IOsmStorageFilter addFilter) throws FileNotFoundException,
|
||||||
IOException, SQLException, SAXException {
|
IOException, SQLException, SAXException {
|
||||||
boolean pbfFile = false;
|
boolean pbfFile = false;
|
||||||
InputStream stream = new FileInputStream(readFile);
|
InputStream stream = new BufferedInputStream(new FileInputStream(readFile), 8192*4);;
|
||||||
InputStream streamFile = stream;
|
InputStream streamFile = stream;
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
if (readFile.getName().endsWith(".bz2")) { //$NON-NLS-1$
|
if (readFile.getName().endsWith(".bz2")) { //$NON-NLS-1$
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class OSMSettings {
|
||||||
ADDRESS_TYPE("address:type"), //$NON-NLS-1$
|
ADDRESS_TYPE("address:type"), //$NON-NLS-1$
|
||||||
ADDRESS_HOUSE("address:house"), //$NON-NLS-1$
|
ADDRESS_HOUSE("address:house"), //$NON-NLS-1$
|
||||||
TYPE("type"), //$NON-NLS-1$
|
TYPE("type"), //$NON-NLS-1$
|
||||||
|
IS_IN("is_in"), //$NON-NLS-1$
|
||||||
|
|
||||||
// POI
|
// POI
|
||||||
AMENITY("amenity"), //$NON-NLS-1$
|
AMENITY("amenity"), //$NON-NLS-1$
|
||||||
|
|
Loading…
Reference in a new issue