fix small issues
git-svn-id: https://osmand.googlecode.com/svn/trunk@622 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
c395d37cb2
commit
0c7fb15594
2 changed files with 20 additions and 16 deletions
|
@ -3,6 +3,7 @@ package net.osmand.binary;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -12,7 +13,6 @@ import net.osmand.Algoritms;
|
|||
import net.osmand.binary.OsmandOdb.CityIndex;
|
||||
import net.osmand.binary.OsmandOdb.PostcodeIndex;
|
||||
import net.osmand.binary.OsmandOdb.StreetIndex;
|
||||
import net.osmand.binary.OsmandOdb.CityIndex.Builder;
|
||||
import net.osmand.data.Building;
|
||||
import net.osmand.data.City;
|
||||
import net.osmand.data.MapObject;
|
||||
|
@ -390,7 +390,8 @@ public class BinaryMapIndexWriter {
|
|||
|
||||
public void endCityIndexes(boolean villages) throws IOException {
|
||||
popState(villages ? VILLAGES_INDEX_INIT : CITY_INDEX_INIT);
|
||||
writeInt32Size();
|
||||
int length = writeInt32Size();
|
||||
System.out.println("CITIES size " + length + " " + villages);
|
||||
}
|
||||
|
||||
|
||||
|
@ -402,19 +403,23 @@ public class BinaryMapIndexWriter {
|
|||
|
||||
public void endPostcodes() throws IOException {
|
||||
popState(POSTCODES_INDEX_INIT);
|
||||
writeInt32Size();
|
||||
int postcodes = writeInt32Size();
|
||||
System.out.println("POSTCODES size " + postcodes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void writePostcode(String postcode, List<Street> streets) throws IOException {
|
||||
public void writePostcode(String postcode, Collection<Street> streets) throws IOException {
|
||||
checkPeekState(POSTCODES_INDEX_INIT);
|
||||
LatLon loc = streets.get(0).getLocation();
|
||||
LatLon loc = null;
|
||||
PostcodeIndex.Builder post = OsmandOdb.PostcodeIndex.newBuilder();
|
||||
post.setPostcode(postcode);
|
||||
|
||||
|
||||
for(Street s : streets){
|
||||
if(loc == null){
|
||||
loc = s.getLocation();
|
||||
}
|
||||
StreetIndex streetInd = createStreetAndBuildings(s, loc, postcode);
|
||||
post.addStreets(streetInd);
|
||||
}
|
||||
|
|
|
@ -1504,33 +1504,33 @@ public class IndexCreator {
|
|||
@Override
|
||||
public int compare(City o1, City o2) {
|
||||
if (o1.getType() != o2.getType()) {
|
||||
return -(o1.getType().ordinal() - o2.getType().ordinal());
|
||||
return (o1.getType().ordinal() - o2.getType().ordinal());
|
||||
}
|
||||
return Collator.getInstance().compare(o1.getName(), o2.getName());
|
||||
}
|
||||
});
|
||||
PreparedStatement streetstat = reader.getStreetsBuildingPreparedStatement(addressConnection);
|
||||
|
||||
Map<String, List<Street>> postcodes = new TreeMap<String, List<Street>>();
|
||||
Map<String, Set<Street>> postcodes = new TreeMap<String, Set<Street>>();
|
||||
boolean writeCities = true;
|
||||
// write cities and after villages
|
||||
writer.startCityIndexes(false);
|
||||
for(int i =0; i< cities.size(); i++ ) {
|
||||
for (int i = 0; i < cities.size(); i++) {
|
||||
City c = cities.get(i);
|
||||
if(writeCities && c.getType() != CityType.CITY && c.getType() != CityType.TOWN){
|
||||
if (writeCities && c.getType() != CityType.CITY && c.getType() != CityType.TOWN) {
|
||||
writer.endCityIndexes(false);
|
||||
writer.startCityIndexes(true);
|
||||
writeCities = false;
|
||||
}
|
||||
|
||||
|
||||
streets.clear();
|
||||
reader.readStreetsBuildings(streetstat, c, streets);
|
||||
writer.writeCityIndex(c, streets);
|
||||
for(Street s : streets){
|
||||
for(Building b : s.getBuildings()){
|
||||
if(b.getPostcode() != null){
|
||||
if(!postcodes.containsKey(b.getPostcode())){
|
||||
postcodes.put(b.getPostcode(), new ArrayList<Street>(3));
|
||||
for (Street s : streets) {
|
||||
for (Building b : s.getBuildings()) {
|
||||
if (b.getPostcode() != null) {
|
||||
if (!postcodes.containsKey(b.getPostcode())) {
|
||||
postcodes.put(b.getPostcode(), new LinkedHashSet<Street>(3));
|
||||
}
|
||||
postcodes.get(b.getPostcode()).add(s);
|
||||
}
|
||||
|
@ -2136,7 +2136,6 @@ public class IndexCreator {
|
|||
|
||||
// creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null);
|
||||
|
||||
new DataIndexReader().testIndex(new File("e:\\Information\\OSM maps\\osmand\\Address\\Belarus.addr.odb"));
|
||||
System.out.println(System.currentTimeMillis() - time);
|
||||
System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE + " count " + BinaryMapIndexWriter.COORDINATES_COUNT);
|
||||
System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE);
|
||||
|
|
Loading…
Reference in a new issue