Skip to content

Commit a2db562

Browse files
committed
Switch Commons categories to the end of the query to prevent cases with >1 cat from messing up wikipedia and commons articles
1 parent b600f51 commit a2db562

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,16 @@ private List<Place> getFromWikidataQuery(LatLng cur,
100100
continue;
101101
}
102102

103-
104-
// Fields: ["Point(153.073 -27.6111)"^^<http://www.opengis.net/ont/geosparql#wktLiteral>, <http://www.wikidata.org/entity/Q7271010>, "Queensland State Archives"@en, <http://www.wikidata.org/entity/Q327333>, "government agency"@en, , , Images from the Queensland State Archives, <https://en.wikipedia.org/wiki/Queensland_State_Archives>, <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
105-
// Produces: 02-11 21:32:45.015: V/NearbyPlaces(9300): Name: Queensland State Archives, type: government agency, category: Images from the Queensland State Archives, wikipediaSitelink: <https://en.wikipedia.org/wiki/Queensland_State_Archives>, commonsSitelink: <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
106-
107-
//TODO: What about items with more than 1 Commons category??? Might need to rearrange categories to the end of the string
108-
109103
String[] fields = line.split("\t");
110104
Timber.v("Fields: " + Arrays.toString(fields));
111105
String point = fields[0];
112106
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
113107
String name = Utils.stripLocalizedString(fields[2]);
114108
String type = Utils.stripLocalizedString(fields[4]);
115109
String icon = fields[5];
116-
String category = Utils.stripLocalizedString(fields[7]);
117-
String wikipediaSitelink = Utils.stripLocalizedString(fields[8]);
118-
String commonsSitelink = Utils.stripLocalizedString(fields[9]);
110+
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
111+
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
112+
String category = Utils.stripLocalizedString(fields[9]);
119113

120114
Timber.v("Name: " + name + ", type: " + type + ", category: " + category + ", wikipediaSitelink: " + wikipediaSitelink + ", commonsSitelink: " + commonsSitelink);
121115

app/src/main/resources/queries/nearby_query.rq

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ SELECT
66
(SAMPLE(COALESCE(?class_label_preferred_language, ?class_label_any_language, "?")) as ?class_label)
77
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
88
(SAMPLE(COALESCE(?emoji0, ?emoji1)) as ?emoji)
9-
(SAMPLE(?Commons_category) as ?Commons_category)
109
?wikipediaArticle
1110
?commonsArticle
11+
(SAMPLE(?Commons_category) as ?Commons_category)
1212
WHERE {
1313
# Around given location...
1414
SERVICE wikibase:around {

0 commit comments

Comments
 (0)