Fix renderers for base map

This commit is contained in:
Victor Shcherb 2011-06-20 01:32:38 +02:00
parent 2c5e932467
commit 932e0dc96b
8 changed files with 90 additions and 37 deletions

View file

@ -623,7 +623,9 @@ public class IndexCreator {
creator.setZoomWaySmothness(2);
creator.generateIndexes(new File(
// "/home/victor/projects/OsmAnd/download/basemap/10m_admin_level_out.osm"
"/home/victor/projects/OsmAnd/download/basemap/10m_populated_places_out.osm"
// "/home/victor/projects/OsmAnd/download/basemap/10m_populated_places_out.osm"
// "/home/victor/projects/OsmAnd/download/basemap/10m_lakes_out.osm"
"/home/victor/projects/OsmAnd/download/basemap/10m_rivers.osm"
),
new ConsoleProgressImplementation(1), null, mapZooms, null);

View file

@ -128,6 +128,37 @@ public class MapUtils {
return new LatLon(latitude/count, longitude/count);
}
public static LatLon getMathWeightCenterForNodes(Collection<Node> nodes){
if (nodes.isEmpty()) {
return null;
}
double longitude = 0;
double latitude = 0;
double sumDist = 0;
Node prev = null;
for (Node n : nodes) {
if (n != null) {
if(prev == null){
prev = n;
} else {
double dist = MapUtils.getDistance(prev, n);
sumDist += dist;
longitude += (prev.getLongitude() + n.getLongitude()) * dist / 2;
latitude += (n.getLatitude() + n.getLatitude()) * dist / 2;
prev = n;
}
}
}
if (sumDist == 0) {
if(prev == null){
return null;
}
return prev.getLatLon();
}
return new LatLon(latitude/sumDist, longitude/sumDist);
}
public static double checkLongitude(double longitude) {
while (longitude < -180 || longitude > 180) {
if (longitude < 0) {

View file

@ -96,7 +96,7 @@
<type id="3" name="waterway">
<subtype id="1" polyline="true" tag="waterway" value="stream" minzoom="13" />
<subtype id="3" polygon="true" tag="waterway" value="riverbank" minzoom="9" />
<subtype id="2" polyline="true" tag="waterway" value="river" minzoom="9" />
<subtype id="2" polyline="true" tag="waterway" value="river" minzoom="5" />
<subtype id="4" polyline="true" tag="waterway" value="canal" minzoom="10" />
<subtype id="5" polyline="true" tag="waterway" value="ditch" minzoom="15" />
<subtype id="6" polyline="true" tag="waterway" value="drain" minzoom="15" />
@ -428,8 +428,8 @@
<subtype id="18" point="true" tag="natural" value="stone" minzoom="15" />
<subtype id="19" point="true" tag="natural" value="tree" minzoom="15" />
<subtype id="20" point="true" tag="natural" value="volcano" minzoom="11" />
<subtype id="21" point="true" polygon="true" tag="natural" value="water" minzoom="8" />
<subtype id="21" point="true" polygon="true" tag="natural" value="lake" minzoom="8" />
<subtype id="21" point="true" polygon="true" tag="natural" value="water" minzoom="4" />
<subtype id="21" point="true" polygon="true" tag="natural" value="lake" minzoom="4" />
<subtype id="22" point="true" polygon="true" tag="natural" value="wetland" minzoom="13" />
<subtype id="23" point="true" polygon="true" tag="natural" value="wood" minzoom="8" />
<subtype id="23" point="true" polygon="true" tag="landuse" value="wood" minzoom="8" />
@ -542,12 +542,11 @@
<type id="25" name="administrative">
<subtype id="41" point="true" tag="place" value="continent" minzoom="5" />
<subtype id="42" point="true" tag="place" value="country" minzoom="5" />
<subtype id="43" point="true" tag="place" value="state" minzoom="5" />
<subtype id="44" point="true" tag="place" value="region" minzoom="5" />
<subtype id="45" point="true" tag="place" value="county" minzoom="5" />
<subtype id="41" point="true" tag="place" value="continent" minzoom="1" />
<subtype id="42" point="true" tag="place" value="country" minzoom="2" />
<subtype id="43" point="true" tag="place" value="state" minzoom="3" />
<subtype id="44" point="true" tag="place" value="region" minzoom="4" />
<subtype id="45" point="true" tag="place" value="county" minzoom="4" />
<subtype id="6" point="true" polygon_center="true" tag="place" value="city" minzoom="4" />
<subtype id="7" point="true" polygon_center="true" tag="place" value="town" minzoom="6" />
<subtype id="8" point="true" polygon_center="true" tag="place" value="village" minzoom="10" />

View file

@ -15,6 +15,7 @@ import javax.xml.stream.XMLStreamException;
import net.osmand.impl.ConsoleProgressImplementation;
import net.osmand.osm.Entity;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.osm.Node;
import net.osmand.osm.Way;
import net.osmand.osm.Entity.EntityId;
@ -68,7 +69,8 @@ public class FixAdminLevel0 {
for(String country : countryNames.keySet()){
List<Way> list = countryNames.get(country);
for(Way w : list){
LatLon latLon = w.getLatLon();
LatLon latLon = MapUtils.getMathWeightCenterForNodes(w.getNodes());
// LatLon latLon = w.getLatLon();
Node node = new Node(latLon.getLatitude(), latLon.getLongitude(), id--);
node.putTag("name", country);
node.putTag("place", "country");
@ -96,14 +98,21 @@ public class FixAdminLevel0 {
countryNames.put(name, list);
} else {
List<Way> r = countryNames.get(name);
boolean skip = false;
for (int i = 0; i < r.size();) {
if (way.getNodes().size() > 4 * r.get(i).getNodes().size()) {
if (way.getNodes().size() > 2 * r.get(i).getNodes().size()) {
r.remove(i);
} else {
if (2 * way.getNodes().size() < r.get(i).getNodes().size()) {
skip = true;
break;
}
i++;
}
}
r.add(way);
if(!skip){
r.add(way);
}
}
}

View file

@ -33,7 +33,8 @@ public class FixLinkedCoastline {
public static void main(String[] args) throws IOException, SAXException, XMLStreamException {
String fileToRead = args != null && args.length > 0 ? args[0] : null;
if(fileToRead == null) {
fileToRead = "/home/victor/projects/OsmAnd/download/basemap/10m_coastline.osm";
// fileToRead = "/home/victor/projects/OsmAnd/download/basemap/10m_coastline.osm";
fileToRead = "/home/victor/projects/OsmAnd/download/basemap/10m_lakes.osm";
}
File read = new File(fileToRead);
File write ;

View file

@ -116,20 +116,14 @@
<filter minzoom="15" textSize="9" textColor="#888870" textHaloRadius="2" textWrapWidth="15" tag="leisure" />
<filter minzoom="15" textSize="9" textColor="#0000C0" textHaloRadius="1" textWrapWidth="30" tag="leisure" value="marina" />
<filter minzoom="6" maxzoom="8" textColor="#eae9e9" textSize="8" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="9" maxzoom="10" textColor="#eae9e9" textSize="11" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="10" maxzoom="14" textColor="#eae9e9" textSize="13" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="14" maxzoom="16" textColor="#eae9e9" textSize="14" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="6" maxzoom="8" textSize="8" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="9" maxzoom="10" textSize="11" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="11" textSize="14" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="4" maxzoom="6" textColor="#eae9e9" textSize="10" textDy="-8" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="7" maxzoom="8" textColor="#eae9e9" textSize="11" textDy="-8" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="9" maxzoom="10" textColor="#eae9e9" textSize="12" textDy="-8" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="11" textSize="14" textColor="#eae9e9" textHaloRadius="1" textWrapWidth="20" tag="place" value="city" />
<filter minzoom="6" maxzoom="10" textColor="#eae9e9" textSize="10" textDy="-8" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="11" maxzoom="13" textColor="#eae9e9" textSize="12" textDy="-8" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="14" textSize="14" textColor="#eae9e9" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="9" maxzoom="10" textColor="#eae9e9" textSize="8" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="11" maxzoom="13" textColor="#eae9e9" textSize="11" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="14" textSize="13" textColor="#eae9e9" textHaloRadius="1" textWrapWidth="20" tag="place" value="town" />
<filter minzoom="12" maxzoom="14" textColor="#eae9e9" textSize="9" textHaloRadius="1" tag="place" value="village" />
<filter minzoom="15" textSize="12" textColor="#eae9e9" textHaloRadius="1" tag="place" value="village" />
<filter minzoom="12" maxzoom="14" textColor="#a2a2a2" textSize="9" textHaloRadius="1" tag="place" value="hamlet" />
<filter minzoom="15" textSize="12" textColor="#bfbfbf" textHaloRadius="1" tag="place" value="hamlet" />

View file

@ -187,8 +187,8 @@
<filter minzoom="15" textSize="10" textColor="#654321" textHaloRadius="1" textDy="9" textWrapWidth="20" tag="natural" value="cave_entrance" />
<filter minzoom="14" textSize="9" textColor="#654321" textHaloRadius="1" textDy="5" tag="natural" value="peak" />
<filter minzoom="16" textSize="8" textColor="#6699cc" textHaloRadius="1" textDy="10" textWrapWidth="20" tag="natural" value="spring" />
<filter minzoom="12" textSize="10" textColor="#6699cc" textHaloRadius="1" textWrapWidth="20" tag="natural" value="water" />
<filter minzoom="12" textSize="10" textColor="#6699cc" textHaloRadius="1" textWrapWidth="20" tag="natural" value="lake" />
<filter minzoom="6" textSize="10" textColor="#6699cc" textHaloRadius="1" textWrapWidth="20" tag="natural" value="water" />
<filter minzoom="6" textSize="10" textColor="#6699cc" textHaloRadius="1" textWrapWidth="20" tag="natural" value="lake" />
<filter minzoom="12" textSize="10" textColor="#ff000000" textHaloRadius="2" textWrapWidth="10" tag="natural" value="wood" />
<filter minzoom="15" textSize="8" textColor="#6699cc" textHaloRadius="1" textOnPath="true" tag="waterway" value="stream" />
@ -309,7 +309,7 @@
<filter minzoom="12" textSize="9" textBold="true" textColor="#ffc0cb" textHaloRadius="1" textWrapWidth="10" tag="military" value="danger_area" />
<filter minzoom="4" textSize="10" textColor="#9d6c9d" textHaloRadius="1" textWrapWidth="20" tag="place" value="country" />
<filter minzoom="3" textSize="10" textColor="#9d6c9d" textHaloRadius="1" textWrapWidth="20" tag="place" value="country" />
<filter minzoom="4" maxzoom="7" textSize="9" textColor="#9d6c9d" textHaloRadius="1" textWrapWidth="20" tag="place" value="state" />
<filter minzoom="8" textSize="11" textColor="#9d6c9d" textHaloRadius="1" textWrapWidth="20" tag="place" value="state" />
<filter minzoom="4" maxzoom="7" textSize="9" textColor="#9d6c9d" textHaloRadius="1" textWrapWidth="20" tag="place" value="region" />
@ -508,8 +508,8 @@
<filter color="#b5d0d0">
<filter minzoom="1" tag="natural" value="coastline" />
<filter minzoom="7" tag="natural" value="water" />
<filter minzoom="7" tag="natural" value="lake" />
<filter minzoom="4" tag="natural" value="water" />
<filter minzoom="4" tag="natural" value="lake" />
</filter>
<filter minzoom="8" shader="beach" tag="natural" value="beach" />
@ -829,7 +829,7 @@
<case tag="waterway" value="river" />
<case tag="waterway" value="canal" />
<filter color="#b5d0d0" pathEffect_2="4_2" color_2="#ffffff">
<filter minzoom="9" maxzoom="9" strokeWidth="1" />
<filter minzoom="5" maxzoom="9" strokeWidth="1" />
<filter minzoom="10" maxzoom="12" strokeWidth="2" />
<filter minzoom="13" maxzoom="13" strokeWidth="3" />
@ -974,9 +974,9 @@
<case tag="admin_level" value="3" />
<filter color="#800080">
<filter minzoom="2" maxzoom="3" strokeWidth="0.5" />
<filter minzoom="4" maxzoom="5" strokeWidth="1" />
<filter minzoom="6" maxzoom="9" strokeWidth="3" />
<filter minzoom="10" strokeWidth="6" />
<filter minzoom="4" maxzoom="6" strokeWidth="1" />
<filter minzoom="7" maxzoom="9" strokeWidth="2.5" />
<filter minzoom="10" strokeWidth="4" />
</filter>
</switch>

View file

@ -31,6 +31,23 @@ cities/towns
Example (replacing tags):
1. python ogr2osm/ogr2osm.py 10m-populated-places/10m_populated_places.shp
Creates 10m_populated_places.osm
2. less 10m_populated_places.osm | sed 's/MEGACITY/place/g;s/value="1"/value="city"/g;s/v="0"/v="town"/g;s/NAME/name/g' > 10m_populated_places_out.osm
2. less 10m_populated_places.osm | sed 's/MEGACITY/place/g;s/v="1"/v="city"/g;s/v="0"/v="town"/g;s/NAME/name/g' > 10m_populated_places_out.osm
3. Run IndexCreator
-------------------------
lakes
Example (replacing tags):
1. perl ./shp2osm.pl 10m-lakes/10m_lakes.shp | sed 's/FeatureCla/natural/g;s/Lake/lake/g;s/Reservoir/water/g;s/Name1/name/g' > 10m_lakes.osm
Creates 10m_lakes.osm
2. Run net.osmand.osm.util.FixLinkedCoastline from DataExtractionosm.jar with arg0=filename.
3. Open in Josm and simply save
4. Run IndexCreator
-------------------------
rivers
Example (replacing tags):
1. perl ./shp2osm.pl 10m-rivers-lake-centerlines/10m_rivers_lake_centerlines.shp | sed 's/FeatureCla/waterway/g;s/River/river/g;s/Name/name/g' > 10m_rivers.osm
Creates 10m_lakes.osm
2. Run net.osmand.osm.util.FixLinkedCoastline from DataExtractionosm.jar with arg0=filename.
3. Open in Josm and simply save
4. Run IndexCreator