Fix basemap rendering

This commit is contained in:
Victor Shcherb 2012-04-10 22:52:26 +02:00
parent 4367dda5a4
commit 5f10f74b6a
8 changed files with 28 additions and 51 deletions

View file

@ -14,6 +14,7 @@ public class ToDoConstants {
// Routing index !! // Routing index !!
// Identify coastline areas and pure ocean areas !!! Show high zoom level for coatline if coastline is broken // Identify coastline areas and pure ocean areas !!! Show high zoom level for coatline if coastline is broken
// TODO native support!
// TODO Delete/Extract the code with multipolygons ! (coastline)) // TODO Delete/Extract the code with multipolygons ! (coastline))
// Render : different texts support render.xml // Render : different texts support render.xml

View file

@ -46,7 +46,7 @@ public class BinaryInspector {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
inspector(args); inspector(args);
// test cases show info // test cases show info
inspector(new String[]{"-vmap", "-zoom=3","/home/victor/projects/OsmAnd/data/osm-gen/basemap_all.obf"}); inspector(new String[]{"/home/victor/projects/OsmAnd/data/osm-gen/basemap_n.obf"});
// test case extract parts // test case extract parts

View file

@ -368,6 +368,7 @@ public class MapAlgorithms {
if (outx == rightX || outx == leftX || outy == topY || outy == bottomY) { if (outx == rightX || outx == leftX || outy == topY || outy == bottomY) {
bx = outx; bx = outx;
by = outy; by = outy;
//return (((long) bx) << 32) | ((long) by);
} }
return -1l; return -1l;
} }

View file

@ -724,31 +724,17 @@ public class IndexCreator {
// zooms = MapZooms.parseZooms("1-3;4-6;7-9;10-"); // zooms = MapZooms.parseZooms("1-3;4-6;7-9;10-");
// creator.setMapFileName("basemap_coastlines.obf"); // creator.setMapFileName("basemap_coastlines.obf");
zooms = MapZooms.parseZooms("1-3;4-5;6-7;8-9;10-"); zooms = MapZooms.parseZooms("1-2;3;4-5;6-7;8-9;10-");
creator.setMapFileName("basemap_a.obf"); creator.setMapFileName("basemap_2.obf");
File basemapParent = new File("/home/victor/projects/OsmAnd/data/basemap"); File basemapParent = new File("/home/victor/projects/OsmAnd/data/basemap/ready/");
creator.generateBasemapIndex(new ConsoleProgressImplementation(1), null, zooms, rt, log, "basemap", creator.generateBasemapIndex(new ConsoleProgressImplementation(1), null, zooms, rt, log, "basemap",
new File(basemapParent, "10m_coastline_out.osm"), new File(basemapParent, "10m_coastline_out.osm"),
new File(basemapParent, "10m_admin_level_out.osm"), new File(basemapParent, "10m_admin_level.osm"),
new File(basemapParent, "10m_rivers.osm"), new File(basemapParent, "10m_rivers.osm"),
new File(basemapParent, "10m_lakes_out.osm"), new File(basemapParent, "10m_lakes.osm"),
new File(basemapParent, "10m_populated_places_out.osm") new File(basemapParent, "10m_populated_places.osm")
); );
// world generation
// MapZooms mapZooms = new MapZooms();
// MapZoomPair pair1 = new MapZooms.MapZoomPair(1, 3);
// MapZoomPair pair2 = new MapZooms.MapZoomPair(4, 5);
// MapZoomPair pair3 = new MapZooms.MapZoomPair(6, 7);
//
// mapZooms.setLevels(Arrays.asList(pair1, pair2, pair3));
// // for coastline
// creator.setZoomWaySmothness(2);
// creator.generateIndexes(new File(
// "/home/victor/projects/OsmAnd/download/basemap/basemap_1.osm"
// ),
// new ConsoleProgressImplementation(1), null, mapZooms, log);
log.info("WHOLE GENERATION TIME : " + (System.currentTimeMillis() - time)); //$NON-NLS-1$ log.info("WHOLE GENERATION TIME : " + (System.currentTimeMillis() - time)); //$NON-NLS-1$

View file

@ -219,6 +219,9 @@ public class MapUtils {
*/ */
public static double getTileNumberX(float zoom, double longitude){ public static double getTileNumberX(float zoom, double longitude){
if(longitude == 180d) {
return getPowZoom(zoom) - 1;
}
longitude = checkLongitude(longitude); longitude = checkLongitude(longitude);
return (longitude + 180d)/360d * getPowZoom(zoom); return (longitude + 180d)/360d * getPowZoom(zoom);
} }

View file

@ -106,8 +106,8 @@
<filter appMode="bicycle" tag="admin_level" value="" order="34"/> <filter appMode="bicycle" tag="admin_level" value="" order="34"/>
<filter appMode="car" tag="admin_level" value="" order="34"/> <filter appMode="car" tag="admin_level" value="" order="34"/>
<!-- Below sea level --> <!-- Below sea level -->
<filter tag="admin_level" value="0" order="0"/> <filter tag="admin_level" value="0" order="3"/>
<filter tag="admin_level" value="1" order="0"/> <filter tag="admin_level" value="1" order="3"/>
<filter tag="admin_level" value="" order="62"/> <filter tag="admin_level" value="" order="62"/>
<filter tag="administrative" value="" order="62"/> <filter tag="administrative" value="" order="62"/>

View file

@ -59,7 +59,7 @@ public class MapRenderRepositories {
private final static Log log = LogUtil.getLog(MapRenderRepositories.class); private final static Log log = LogUtil.getLog(MapRenderRepositories.class);
private final Context context; private final Context context;
private final static int BASEMAP_ZOOM = 7; private final static int BASEMAP_ZOOM = 11;
private Handler handler; private Handler handler;
private Map<String, BinaryMapIndexReader> files = new LinkedHashMap<String, BinaryMapIndexReader>(); private Map<String, BinaryMapIndexReader> files = new LinkedHashMap<String, BinaryMapIndexReader>();
private Set<String> nativeFiles = new HashSet<String>(); private Set<String> nativeFiles = new HashSet<String>();
@ -384,18 +384,21 @@ public class MapRenderRepositories {
addBasemapCoastlines = pcoastlines.isEmpty() || zoom <= BASEMAP_ZOOM; addBasemapCoastlines = pcoastlines.isEmpty() || zoom <= BASEMAP_ZOOM;
tempResult.addAll(pcoastlines); tempResult.addAll(pcoastlines);
coastlineTime = "(coastline " + (System.currentTimeMillis() - ms) + " ms )"; coastlineTime = "(coastline " + (System.currentTimeMillis() - ms) + " ms )";
} else if(basemapCoastLines.isEmpty() && mi != null){ }
if(addBasemapCoastlines){
addBasemapCoastlines = false;
long ms = System.currentTimeMillis();
List<BinaryMapDataObject> pcoastlines = processCoastlines(basemapCoastLines, leftX, rightX, bottomY, topY, zoom, true);
addBasemapCoastlines = pcoastlines.isEmpty();
tempResult.addAll(pcoastlines);
coastlineTime = "(coastline " + (System.currentTimeMillis() - ms) + " ms )";
}
if(addBasemapCoastlines && mi != null){
BinaryMapDataObject o = new BinaryMapDataObject(new int[] { leftX, topY, rightX, topY, rightX, bottomY, leftX, bottomY, leftX, BinaryMapDataObject o = new BinaryMapDataObject(new int[] { leftX, topY, rightX, topY, rightX, bottomY, leftX, bottomY, leftX,
topY }, new int[] { ocean ? mi.coastlineEncodingType : (mi.landEncodingType) }, null, -1); topY }, new int[] { ocean ? mi.coastlineEncodingType : (mi.landEncodingType) }, null, -1);
o.setMapIndex(mi); o.setMapIndex(mi);
tempResult.add(o); tempResult.add(o);
} }
if(addBasemapCoastlines){
long ms = System.currentTimeMillis();
List<BinaryMapDataObject> pcoastlines = processCoastlines(basemapCoastLines, leftX, rightX, bottomY, topY, zoom, true);
tempResult.addAll(pcoastlines);
coastlineTime = "(coastline " + (System.currentTimeMillis() - ms) + " ms )";
}
if(emptyData && tempResult.size() > 0){ if(emptyData && tempResult.size() > 0){
// message // message
BinaryMapDataObject p = tempResult.get(0); BinaryMapDataObject p = tempResult.get(0);

View file

@ -58,27 +58,10 @@ Creates 10m_lakes.osm
3. Open in Josm and simply save 3. Open in Josm and simply save
// 4. Run IndexCreator // 4. Run IndexCreator
-------------------------
roads
1. perl shp2osm.pl 10m-roads/10m_roads.shp | sed 's/Type/highway/g;s/"Major Highway"/primary/g;s/"Secondary Highway"/secondary/g' > 10m_roads_out.osm
--------------------------------------------------------------------------------
II Merging
BASH :
echo "<?xml version='1.0' encoding='UTF-8'?>" > basemap_1.osm;
echo "<osm version='0.6' generator='JOSM'>" >> basemap_1.osm;
cat 10m_coastline_out.osm | sed -r "s/'-([0-9]*)'/'-\11'/" | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
cat 10m_admin_level_out.osm | sed -r "s/'-([0-9]*)'/'-\12'/" | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
cat 10m_populated_places_out.osm | xmllint --format - | sed -r 's/"-([0-9]*)"/"-\13"/' | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
cat 10m_rivers.osm | sed -r "s/'-([0-9]*)'/'-\14'/" | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
cat 10m_lakes_out.osm | sed -r "s/'-([0-9]*)'/'-\15'/" | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
echo '</osm>' >> basemap_1.osm;
TEST :
echo "<?xml version='1.0' encoding='UTF-8'?>" > basemap_1.osm;
echo "<osm version='0.6' generator='JOSM'>" >> basemap_1.osm;
echo '</osm>' >> basemap_1.osm;
cat 10m_rivers.osm | sed -r "s/'-([0-9]*)'/'-\14'/" | tail -n+3 | sed 's/<\/osm>//' >> basemap_1.osm;
READY : basemap_1.osm [1-3, 4-5,6-7]. READY : basemap_1.osm [1-3, 4-5,6-7].