diff --git a/vtm/src/org/oscim/theme/XmlMapsforgeThemeBuilder.java b/vtm/src/org/oscim/theme/XmlMapsforgeThemeBuilder.java index 36217770..b1099ea6 100644 --- a/vtm/src/org/oscim/theme/XmlMapsforgeThemeBuilder.java +++ b/vtm/src/org/oscim/theme/XmlMapsforgeThemeBuilder.java @@ -50,6 +50,7 @@ import org.oscim.theme.styles.SymbolStyle; import org.oscim.theme.styles.SymbolStyle.SymbolBuilder; import org.oscim.theme.styles.TextStyle; import org.oscim.theme.styles.TextStyle.TextBuilder; +import org.oscim.utils.FastMath; import org.oscim.utils.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,6 +88,8 @@ public class XmlMapsforgeThemeBuilder extends DefaultHandler { private static final String OUTLINE_STYLE = "O"; private static final String AREA_STYLE = "A"; + private static final int DEFAULT_PRIORITY = Integer.MAX_VALUE / 2; + /** * @param theme an input theme containing valid render theme XML data. * @return a new RenderTheme which is created by parsing the XML data from the input theme. @@ -940,6 +943,9 @@ public class XmlMapsforgeThemeBuilder extends DefaultHandler { b.themeCallback(mThemeCallback); String symbol = null; + // Reset default priority + b.priority = DEFAULT_PRIORITY; + for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); String value = attributes.getValue(i); @@ -974,10 +980,14 @@ public class XmlMapsforgeThemeBuilder extends DefaultHandler { else if ("caption".equals(name)) b.caption = Boolean.parseBoolean(value); - else if ("priority".equals(name)) + else if ("priority".equals(name)) { b.priority = Integer.parseInt(value); - else if ("area-size".equals(name)) + // Mapsforge: higher priorities are drawn first (0 = default priority) + // VTM: lower priorities are drawn first (0 = highest priority) + b.priority = FastMath.clamp(DEFAULT_PRIORITY - b.priority, 0, Integer.MAX_VALUE); + + } else if ("area-size".equals(name)) b.areaSize = Float.parseFloat(value); else if ("dy".equals(name))