Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardwired suppression of icons on buildings, building:parts etc. #2676

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions documentation/docs/tutorials/data_styling.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Vespucci Data Styling
_Documentation for Vespucci 16.0 Style file format version 0.3.1_
_Documentation for Vespucci 20.2 Style file format version 0.3.1_

The data styling configuration is not a work of art, it was created ad hoc (in other words it is an awful hack) to allow slightly more flexible configuration of the rendering.

Expand All @@ -18,7 +18,7 @@ Node styling is limited to the __labelKey__ and __iconPath__ attributes.
|---------------------------|----------------|---------|------------------------------------------------------
|__<profile>__ | | | Top level enclosing element
| | name | | Style name
| | format | | Format version, currently 0.3.0
| | format | | Format version, currently 0.3.1
|__<!-- comment -->__ | | | A comment
|__<config>__ | | | Configuration element
| | type | | One of "large_drag_area", "marker_scale", "min_handle_len", "icon_zoom_limit"
Expand Down Expand Up @@ -57,7 +57,7 @@ Node styling is limited to the __labelKey__ and __iconPath__ attributes.
|__<interval>__ | | | dash sub-element used to define the length of the dash/no-dash phases
| | length | | Length of the dash as a float

Using _"preset"_ as the value for iconPath will match the objects tags with the presets, just as this is done throughout the application, however "building", "building:part" and "indoor=room" tags are ignored. If you need to render icons specifically for such objects, reference an icon directly.
Using _"preset"_ as the value for _iconPath_ will match the objects tags with the presets, just as this is done throughout the application. An _""_ (empty string) value for _iconPath_ will suppress rendering any icon.

### Internal features

Expand Down
6 changes: 3 additions & 3 deletions src/main/assets/styles/Color-round-no-mp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<feature type="way" tags="man_made=embankment" color="ff996633" pathPattern="triangle_right" />
<feature type="way" tags="man_made=bridge" widthFactor="2.0" color="aa585c63" closed="true" area="true" offset="0.50" />
</feature>
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<feature type="way" tags="building|shop" closed="true" iconPath="preset" labelKey="name" />
<feature type="way" tags="building|amenity" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|tourism" closed="true" iconPath="preset" labelKey="name"/>
Expand All @@ -146,7 +146,7 @@
<feature type="way" tags="building|railway" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|addr:housenumber" closed="true" labelKey="addr:housenumber"/>
</feature>
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<dash phase="1.0">
<interval length="2.0" />
<interval length="2.0" />
Expand Down Expand Up @@ -436,7 +436,7 @@
<!-- Indoor features -->
<feature type="way" tags="indoor" updateWidth="true" widthFactor="0.7" color="99f4a442" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="indoor=level" updateWidth="true" widthFactor="0.7" color="99f2c791" style="STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" iconPath="" />
<feature type="way" tags="indoor=corridor" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
</feature>

Expand Down
6 changes: 3 additions & 3 deletions src/main/assets/styles/Color-round.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<feature type="way" tags="man_made=embankment" color="ff996633" pathPattern="triangle_right" />
<feature type="way" tags="man_made=bridge" widthFactor="2.0" color="aa585c63" closed="true" area="true" offset="0.50" />
</feature>
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<feature type="way" tags="building|shop" closed="true" iconPath="preset" labelKey="name" />
<feature type="way" tags="building|amenity" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|tourism" closed="true" iconPath="preset" labelKey="name"/>
Expand All @@ -146,7 +146,7 @@
<feature type="way" tags="building|railway" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|addr:housenumber" closed="true" labelKey="addr:housenumber"/>
</feature>
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<dash phase="1.0">
<interval length="2.0" />
<interval length="2.0" />
Expand Down Expand Up @@ -436,7 +436,7 @@
<!-- Indoor features -->
<feature type="way" tags="indoor" updateWidth="true" widthFactor="0.7" color="99f4a442" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="indoor=level" updateWidth="true" widthFactor="0.7" color="99f2c791" style="STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" iconPath="" />
<feature type="way" tags="indoor=corridor" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
</feature>

Expand Down
6 changes: 3 additions & 3 deletions src/main/assets/styles/No-path-patterns.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<feature type="way" tags="man_made=embankment" color="ff996633" />
<feature type="way" tags="man_made=bridge" widthFactor="2.0" color="aa585c63" closed="true" area="true" offset="0.50" />
</feature>
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<feature type="way" tags="building|shop" closed="true" iconPath="preset" labelKey="name" />
<feature type="way" tags="building|amenity" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|tourism" closed="true" iconPath="preset" labelKey="name"/>
Expand All @@ -146,7 +146,7 @@
<feature type="way" tags="building|railway" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|addr:housenumber" closed="true" labelKey="addr:housenumber"/>
</feature>
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<dash phase="1.0">
<interval length="2.0" />
<interval length="2.0" />
Expand Down Expand Up @@ -436,7 +436,7 @@
<!-- Indoor features -->
<feature type="way" tags="indoor" updateWidth="true" widthFactor="0.7" color="99f4a442" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="indoor=level" updateWidth="true" widthFactor="0.7" color="99f2c791" style="STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" iconPath="" />
<feature type="way" tags="indoor=corridor" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
</feature>

Expand Down
6 changes: 3 additions & 3 deletions src/main/assets/styles/Pen-round.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<feature type="way" tags="man_made=embankment" color="ff996633" pathPattern="triangle_right" />
<feature type="way" tags="man_made=bridge" widthFactor="2.0" color="aa585c63" closed="true" area="true" offset="0.50" />
</feature>
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building" updateWidth="true" widthFactor="1.0" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<feature type="way" tags="building|shop" closed="true" iconPath="preset" labelKey="name" />
<feature type="way" tags="building|amenity" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|tourism" closed="true" iconPath="preset" labelKey="name"/>
Expand All @@ -146,7 +146,7 @@
<feature type="way" tags="building|railway" closed="true" iconPath="preset" labelKey="name"/>
<feature type="way" tags="building|addr:housenumber" closed="true" labelKey="addr:housenumber"/>
</feature>
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="building:part" updateWidth="true" widthFactor="0.8" color="ffcc9999" style="STROKE" cap="BUTT" join="MITER" iconPath="">
<dash phase="1.0">
<interval length="2.0" />
<interval length="2.0" />
Expand Down Expand Up @@ -436,7 +436,7 @@
<!-- Indoor features -->
<feature type="way" tags="indoor" updateWidth="true" widthFactor="0.7" color="99f4a442" style="STROKE" cap="BUTT" join="MITER" >
<feature type="way" tags="indoor=level" updateWidth="true" widthFactor="0.7" color="99f2c791" style="STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
<feature type="way" tags="indoor=room" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" iconPath="" />
<feature type="way" tags="indoor=corridor" updateWidth="true" widthFactor="0.7" color="99f2c791" style="FILL_AND_STROKE" cap="BUTT" join="MITER" />
</feature>

Expand Down
20 changes: 5 additions & 15 deletions src/main/java/de/blau/android/layer/data/MapOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.SortedMap;
import java.util.WeakHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
Expand Down Expand Up @@ -1263,23 +1262,16 @@ private void retrieveIcon(@NonNull OsmElement element, boolean isWay, @NonNull W
boolean usePresetIcon = style.usePresetIcon();

if (iconPath != null && !usePresetIcon) {
iconDrawable = retrieveCustomIcon(iconPath);
} else if (tmpPresets != null) {
SortedMap<String, String> tags = element.getTags();
PresetItem match = null;
if (isWay) {
if (usePresetIcon) {
// don't show building and similar icons, only icons for those with POI tags
match = Preset.findBestMatch(tmpPresets, tags, null, Tags.IGNORE_FOR_MAP_ICONS);
}
} else {
match = Preset.findBestMatch(tmpPresets, tags, null, null);
if (!"".equals(iconPath)) { // empty icon path suppresses icons
iconDrawable = retrieveCustomIcon(iconPath);
}
} else if (tmpPresets != null) {
PresetItem match = !isWay || usePresetIcon ? Preset.findBestMatch(tmpPresets, element.getTags(), null, null) : null;
if (match != null) {
iconDrawable = match.getMapIcon(context);
}
}
Bitmap icon;
Bitmap icon = NOICON;
if (iconDrawable != null) {
icon = Bitmap.createBitmap(iconRadius * 2, iconRadius * 2, Bitmap.Config.ARGB_8888);
iconDrawable.draw(new Canvas(icon));
Expand All @@ -1288,8 +1280,6 @@ private void retrieveIcon(@NonNull OsmElement element, boolean isWay, @NonNull W
icon = temp.copy(Bitmap.Config.HARDWARE, false);
temp.recycle();
}
} else {
icon = NOICON;
}
synchronized (MapOverlay.this) {
element.addToCache(cache, icon);
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/de/blau/android/osm/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,6 @@ public static boolean isWayMetric(@Nullable final String key) {
// S3DB
public static final String KEY_BUILDING_PART = "building:part";

private static final Map<String, String> IGNORE_FOR_MAP_ICONS_TEMP = new HashMap<>();
static {
IGNORE_FOR_MAP_ICONS_TEMP.put(KEY_BUILDING, "");
IGNORE_FOR_MAP_ICONS_TEMP.put(KEY_BUILDING_PART, "");
IGNORE_FOR_MAP_ICONS_TEMP.put(KEY_INDOOR, VALUE_ROOM);
}
public static final Map<String, String> IGNORE_FOR_MAP_ICONS = Collections.unmodifiableMap(IGNORE_FOR_MAP_ICONS_TEMP);

//
public static final String KEY_LAYER = "layer";

Expand Down
4 changes: 3 additions & 1 deletion src/test/java/de/blau/android/presets/PresetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ public void matching4() {
PresetItem match = Preset.findBestMatch(presets, tags, null, null);
assertNotNull(match);
assertTrue(match.hasKeyValue(Tags.KEY_INDOOR, Tags.VALUE_ROOM));
match = Preset.findBestMatch(presets, tags, null, Tags.IGNORE_FOR_MAP_ICONS);
Map<String, String> ignore = new HashMap<>();
ignore.put(Tags.KEY_INDOOR, Tags.VALUE_ROOM);
match = Preset.findBestMatch(presets, tags, null, ignore);
assertNotNull(match);
assertTrue(match.hasKeyValue(Tags.KEY_SHOP, "supermarket"));
}
Expand Down
Loading