Page MenuHomePhabricator

Configuring Kartographer for external tileserver wrongly inserts "osm-intl" into URL
Closed, ResolvedPublic

Description

Hello,

I'm having trouble of configuring Kartographer with an external tile server. I would like the openstreetmap one:

https://tile.openstreetmap.org/${z}/${x}/${y}.png

So my idea was to configure Kartographer like:

wfLoadExtension( 'Kartographer' );
$wgKartographerMapServer = 'https://tile.openstreetmap.org';
$wgKartographerStyles = [''];

But this does not work. Kartographer makes the following requests:

https://tile.openstreetmap.org/osm-intl/13/4277/2934@2x.png?lang=fr

(which is not working HTTP 404) while I want him to make this request:

https://tile.openstreetmap.org/13/4277/2934.png?lang=fr

Is this possible with the current configuration options?

Thank you for your help
D063520

PS: I think this is not a bug report, it is either a feature improvement (if it is not possible to make this configuration currently) or a demand for more detailed documentation. Hope this it the right place to report!

Event Timeline

In addition, what is the setting for wgKartographerDfltStyle?

Aklapper renamed this task from Configuring Kartographer for external tileserver to Configuring Kartographer for external tileserver wrongly inserts "osm-intl" into URL.Jan 9 2021, 12:18 PM
Aklapper added a project: Documentation.

Hi!

thank you for the quick replay! This is not set. I didn't know it was existing. I was aware only of the configurations detailed here:

https://www.mediawiki.org/wiki/Extension:Kartographer

I tried to set it like:

$wgKartographerDfltStyle = '';

But this also does not work.

Oh, I think I found a related issue:

https://phabricator.wikimedia.org/T259868

this might be redundant then! I leave it up to you!

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

: ), it's a bit a hack .... I installed Kartographer as it is, then you have to replace the server that gives you back the tiles with a public one and not the wikimedia one. I changed some lines in the plugin, but I do not remember. So you can try to do the same. In any case you can support this ticket:
https://phabricator.wikimedia.org/T259868

@DD063520, can you share your Kartographer folder at GitHub? I imagine it would be helpful for many maintainers of third-party Wikibase instances.

@DD063520, I see that you have added Kartographer and JsonConfig extensions at https://github.com/ec-doris/EuKnowledgeGraph. Thanks for that.

I've tried to use them in my Wikibase instance with the following parameters in LocalSettings.php:

wfLoadExtension( 'JsonConfig' );
wfLoadExtension( 'Kartographer' );
$wgWBRepoSettings['useKartographerGlobeCoordinateFormatter'] = true;

But the maps are still not rendered. Could you please point out what else should I change to render the maps?

@RShigapov: have you cloned the extension in the extension folder? Did you follow the installation here:
https://www.mediawiki.org/wiki/Extension:Kartographer
?

Sure I've mounted the extensions to proper folder in wikibase-volume. Yes, I run composer install --no-dev as in the instructions. No, I have not configured anything extra, I've added only those three lines into LocalSettings.php shown in my previous comment.
So basically I use the same setup as you shared at https://github.com/ec-doris/EuKnowledgeGraph.
What am I missing?

I do not know .... it's long time I did it, in my mind there is not more than that .....

Have you specified $wgKartographerMapServer and other parameters in your setup? I don't see them at https://github.com/ec-doris/EuKnowledgeGraph.

Wait, I read to full thread now and maybe I start understanding ... so the extension is installed but you do not see the map rendered, is this the problem? Also the code https://github.com/ec-doris/EuKnowledgeGraph. is not the one in production. I think it does not include the changes to the Kartographer plugin. Does this explain the situation?

Yes, that's the problem. Could you share please how did you manage to show the maps in production? It seems currently that you are the only person who managed to do that with a third-party Wikibase instance.

I checked again ... I think the only changes that are made are:

#JsonConfig for Kartographer
wfLoadExtension( 'JsonConfig' );
wfLoadExtension( 'Kartographer' );

$wgKartographerMapServer = 'https://a.tile.openstreetmap.org/';
$wgKartographerDfltStyle = '';
$wgKartographerStyles = [];

and

diff Kartographer/modules/box/Map.js Kartographer_mod/modules/box/Map.js
41c41
< 	urlFormat = '/{z}/{x}/{y}' + scale + '.png';
---
> 	urlFormat = '{z}/{x}/{y}.png';
233c233
< 			this.layerUrl = mapServer + '/' + style + urlFormat;
---
> 			this.layerUrl = mapServer + urlFormat;

(but this is a hack)

This was for version

cat version 
Kartographer: REL1_34
2020-05-25T18:17:23

3728a91

You found a different solution! I'm surprised. I'm using the openstreetmap tile server. You are using again the wikimedia one, or? does this mean that it is possible again to use the wikimedia tile server for projects outside wikimedia? Can it be that you tested this only on localhost? I remember the wikimedia tile server not accepting the requests ....

Yes, I tested it on localhost. It does not work with a different tile server, indeed. However, with your hack it works with openstreetmap tile server on localhost.

It seems T259868 is stalled and according to T289101#7291157 there are no any Maps-developers for a while already. So... may be we can add your hack to Kartographer?

In fact the hack needs to be refined a bit .... it is not perfect ....

Screenshot 2021-12-06 at 11.34.07.png (598×1 px, 166 KB)

(tile missing) one request still is not fine:

Screenshot 2021-12-06 at 11.34.19.png (358×1 px, 128 KB)

I have no time to make the pull request, but if you can sure! I would be happy : ) !

I was reading this..

$wgKartographerDfltStyle = '';
$wgKartographerStyles = [];

I think that should be:

$wgKartographerDfltStyle = '';
$wgKartographerStyles = [ '' ];

As wgKartographerDfltStyle needs to be a style that is one of wgKartographerStyles. But also the code does

style = options.style || mw.config.get( 'wgKartographerDfltStyle' ) || 'osm-intl',

and '' is falsey, so... that's probably where it goes wrong.

And if you set wgKartographerSrcsetScales = [] you probably won't need that 'scale' hack in your changes.

Regarding the problem with a marker: I looked at the codes, the marker is set at https://github.com/wikimedia/mediawiki-extensions-Kartographer/blob/master/lib/external/mapbox/mapbox-lib.js#L18072-L18075:

iconUrl: format_url('/v4/marker/' +
'pin-' + size.charAt(0) + symbol + '+' + color +
// detect and use retina markers, which are x2 resolution
(L.Browser.retina ? '@2x' : '') + '.png', options && options.accessToken),`

So if I change that to

iconUrl: "https://maps.wikimedia.org/v4/marker/pin-l-marker+0050d0.png",

then the marker is shown, of course.

Hi @TheDJ, I've just tested your suggestion to add

$wgKartographerDfltStyle = '';
$wgKartographerStyles = [ '' ];
wgKartographerSrcsetScales = []

and to not use the hacks by @DD063520. It does not work because 'osm-intl' is always added to URLs.

Then I replaced

style = options.style || mw.config.get( 'wgKartographerDfltStyle' ) || 'osm-intl',

by

style = options.style || mw.config.get( 'wgKartographerDfltStyle' ),

then it works without hacks, indeed. Well, with only this hack instead of two. The two problems mentioned in T271617#7549132 are still there though. The marker problem is resolved via T271617#7553171, but I don't know yet how to solve another problem.

P.S. By another problem I meant yet another unsuccessful GET request to "https://a.tile.openstreetmap.de/img/,13,49.759444444445,9.710555555556,310x180.png?lang=en&domain=localhost&title=Special:BlankPage&groups=_2eec200b26abeb2266e4eca3e456feefcb3c82a6".

P.P.S. I see the same problem at EUKnowledgeGraph. For example, check network at https://linkedopendata.eu/wiki/Item:Q10: https://a.tile.openstreetmap.org//img/,13,60.303611111111,19.135277777778,310x180.png?lang=en&domain=linkedopendata.eu&title=Special%3ABlankPage&groups=_eb9e6784b8c531b7d17d382aa7a91084cfe17ff8

I'll have a patch for this tomorrow. But there are some more problems with leaflet when dynamically loading the map, that I kept running into. its kinda weird, as these problems don't show on WMF servers.

Thanks a lot! What do you think about T297062? Would that be realistic with your patch? Personally I dream that all datatypes in Wikibase work out of the box, so no need to install something extra.

DD063520 changed the task status from Duplicate to Resolved.Apr 28 2022, 6:56 PM