Skip to content

Commit c8a8e5b

Browse files
Rulinodomdomegg
authored andcommitted
Nearby places icons localization bug fix (commons-app#1947)
* Changed the places icon selection from english text to QID
1 parent 7b7d17a commit c8a8e5b

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyPlaces.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,19 @@ private List<Place> getFromWikidataQuery(LatLng cur,
103103
String point = fields[0];
104104
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
105105
String name = Utils.stripLocalizedString(fields[2]);
106+
107+
//getting icon link here
108+
String identifier = Utils.stripLocalizedString(fields[3]);
109+
//getting the ID which is at the end of link
110+
identifier = identifier.split("/")[Utils.stripLocalizedString(fields[3]).split("/").length-1];
111+
//replaced the extra > char from fields
112+
identifier = identifier.replace(">","");
113+
106114
String type = Utils.stripLocalizedString(fields[4]);
107115
String icon = fields[5];
108116
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
109117
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
110118
String category = Utils.stripLocalizedString(fields[9]);
111-
112119
Timber.v("Name: " + name + ", type: " + type + ", category: " + category + ", wikipediaSitelink: " + wikipediaSitelink + ", commonsSitelink: " + commonsSitelink);
113120

114121
double latitude;
@@ -127,7 +134,7 @@ private List<Place> getFromWikidataQuery(LatLng cur,
127134

128135
places.add(new Place(
129136
name,
130-
Place.Label.fromText(type), // list
137+
Place.Label.fromText(identifier), // list
131138
type, // details
132139
Uri.parse(icon),
133140
new LatLng(latitude, longitude, 0),

app/src/main/java/fr/free/nrw/commons/nearby/Place.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,30 @@ public String toString() {
121121
*/
122122
public enum Label {
123123

124-
BUILDING("building", R.drawable.round_icon_generic_building),
125-
HOUSE("house", R.drawable.round_icon_house),
126-
COTTAGE("cottage", R.drawable.round_icon_house),
127-
FARMHOUSE("farmhouse", R.drawable.round_icon_house),
128-
CHURCH("church", R.drawable.round_icon_church),
129-
RAILWAY_STATION("railway station", R.drawable.round_icon_railway_station),
130-
GATEHOUSE("gatehouse", R.drawable.round_icon_gatehouse),
131-
MILESTONE("milestone", R.drawable.round_icon_milestone),
132-
INN("inn", R.drawable.round_icon_house),
133-
CITY("city", R.drawable.round_icon_city),
134-
SECONDARY_SCHOOL("secondary school", R.drawable.round_icon_school),
135-
EDU("edu", R.drawable.round_icon_school),
136-
ISLE("isle", R.drawable.round_icon_island),
137-
MOUNTAIN("mountain", R.drawable.round_icon_mountain),
138-
AIRPORT("airport", R.drawable.round_icon_airport),
139-
BRIDGE("bridge", R.drawable.round_icon_bridge),
140-
ROAD("road", R.drawable.round_icon_road),
141-
FOREST("forest", R.drawable.round_icon_forest),
142-
PARK("park", R.drawable.round_icon_park),
143-
RIVER("river", R.drawable.round_icon_river),
144-
WATERFALL("waterfall", R.drawable.round_icon_waterfall),
124+
BUILDING("Q41176", R.drawable.round_icon_generic_building),
125+
HOUSE("Q3947", R.drawable.round_icon_house),
126+
COTTAGE("Q5783996", R.drawable.round_icon_house),
127+
FARMHOUSE("Q489357", R.drawable.round_icon_house),
128+
CHURCH("Q16970", R.drawable.round_icon_church), //changed from church to church building
129+
RAILWAY_STATION("Q55488", R.drawable.round_icon_railway_station),
130+
GATEHOUSE("Q277760", R.drawable.round_icon_gatehouse),
131+
MILESTONE("Q10145", R.drawable.round_icon_milestone),
132+
INN("Q256020", R.drawable.round_icon_house), //Q27686
133+
HOTEL("Q27686", R.drawable.round_icon_house),
134+
CITY("Q515", R.drawable.round_icon_city),
135+
UNIVERSITY("Q3918",R.drawable.round_icon_school), //added university
136+
SCHOOL("Q3914", R.drawable.round_icon_school), //changed from "secondary school" to school
137+
EDUCATION("Q8434", R.drawable.round_icon_school), //changed from edu to education, there is no id for "edu"
138+
ISLE("Q23442", R.drawable.round_icon_island),
139+
MOUNTAIN("Q8502", R.drawable.round_icon_mountain),
140+
AIRPORT("Q1248784", R.drawable.round_icon_airport),
141+
BRIDGE("Q12280", R.drawable.round_icon_bridge),
142+
ROAD("Q34442", R.drawable.round_icon_road),
143+
FOREST("Q4421", R.drawable.round_icon_forest),
144+
PARK("Q22698", R.drawable.round_icon_park),
145+
RIVER("Q4022", R.drawable.round_icon_river),
146+
WATERFALL("Q34038", R.drawable.round_icon_waterfall),
147+
TEMPLE("Q44539",R.drawable.round_icon_church),
145148
UNKNOWN("?", R.drawable.round_icon_unknown);
146149

147150
private static final Map<String, Label> TEXT_TO_DESCRIPTION

0 commit comments

Comments
 (0)