ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIESlippyMapProvider
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
221 Posts

Posted - Jul 28 2018 :  08:51:46  Show Profile  Reply
Hi

I'm trying to add a new provider to slippy maps for thunderforest outdoors.
I have an API key but I keep getting tiles back with 'Requires API Key' watermark.
I thought it would be a simple case of hacking the providers the source but I can't get the syntax correct.


constructor TIESlippyMap.Create(provider: TIESlippyMapProvider; const cachePath: string);
const
  providers: array [TIESlippyMapProvider] of string = ('http://[abc].tile.openstreetmap.org',
                                                       'http://[abc].tile.opencyclemap.org/cycle',
                                                       'http://[abc].tile2.opencyclemap.org/transport',
                                                       'http://tile.thunderforest.com/outdoors/$0',
                                                       'http://[abc].tile.cloudmade.com/$0/1/256',
                                                       'http://[abc].tile.cloudmade.com/$0/2/256',
                                                       'http://[abc].tile.cloudmade.com/$0/3/256',
                                                       'http://otile[1234].mqcdn.com/tiles/1.0.0/osm',
                                                       'http://oatile[1234].mqcdn.com/naip',
                                                       'http://tile.stamen.com/terrain-background');

This is what thunderforest require as a URL:-

https://tile.thunderforest.com/outdoors/0/0/0.png?apikey=xxxxxx


I'm not altogether clear what the [abc] or [1234] references are for in the provider array, but I believe $0 is where the API key is substituted.
I've tried various permutations without any success can anyone help.

Bruce.

PS The cloudmade providers are no more I'm afraid.

xequte

38214 Posts

Posted - Jul 29 2018 :  16:01:38  Show Profile  Reply
Hi Bruce

Did you try:

https://[abc].tile.thunderforest.com/outdoors/0/0/0.png?apikey=123456

Also, test the URL (with a relevant [abc]substitution) by pasting it into a web browser.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

bmesser

United Kingdom
221 Posts

Posted - Jul 30 2018 :  12:19:10  Show Profile  Reply
Hi Nigel

You might have got the wrong end of the stick here. The URL

https://tile.thunderforest.com/outdoors/0/0/0.png?apikey=xxxxxx

works as does this one

https://tile.thunderforest.com/outdoors/0/0/0.png?

but has the "API key required" watermark as you would imagine.

What I want to do is modify the array string in the ImageEN component code so I can use the outdoor maps from thunder forest. So what I need is a url string - I've tried 'http://tile.thunderforest.com/outdoors/$0' but that's missing the folder structure. A I said I have no idea what gets substituted for [abc] or [1234], but I do know that $0 is for the api key but I'm not sure if I need to include 'apikey=' immediately before that or not.

Bruce.




Go to Top of Page

bmesser

United Kingdom
221 Posts

Posted - Jul 30 2018 :  12:53:23  Show Profile  Reply
I can now see that the [abc] refer to the tile server subdomain:-


Go to Top of Page

xequte

38214 Posts

Posted - Jul 30 2018 :  20:21:57  Show Profile  Reply
Hi Bruce

Sorry, I may not be following, but are you using the TIESlippyMap.Create override that allows you to specify your own URL to use?

e.g.

map := TIESlippyMap.Create( 'https://tile.thunderforest.com/outdoors/0/0/0.png?apikey=123456', 'Cache' );

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

bmesser

United Kingdom
221 Posts

Posted - Jul 31 2018 :  05:27:05  Show Profile  Reply
Hi Nigel

Yes that's right but I thought I had to modify source code to do it, I never realised that you could dynamically create one on the fly like you have, I should have read the help more fully.

Anyway I've tried to do it that way :-

Map := TIESlippyMap.Create('https://[abc].tile.thunderforest.com/?apikey=$0','Cache');
Map.UserKey := 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

and the GetProviderURL() produces a URL like this

'https://a.tile.thunderforest.com/?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/14/4823/6166.png'

This doesn't work because the 'apikey=' precedes the zoom levels and the lat long folder structure, this is how it should look with the API key at the very end:-

'https://tile.thunderforest.com/outdoors/14/4823/6166.png?apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

To get around this I modified the GetFileURL function to put the API key at the end.
This generates a URL that works perfectly in a browser but not in code, so I must have screwed something up further downline.

Map:=TIESlippyMap.Create('https://tile.thunderforest.com/outdoors','D:\Maps\OpenCycleMapOutdoors');

function TIESlippyMap.GetFileURL(tileX: integer; tileY: integer): string;
var
  fpath: string;
begin
  if Pos('thunderforest', m_providerURL)>0 then
    result := Format('%s/%d/%d/%d.png?apikey=%s', [m_providerURL, m_zoom, tileX, tileY, m_userKey])
  else
    result := Format('%s/%d/%d/%d.png', [GetProviderURL(), m_zoom, tileX, tileY]);

  if m_cachePath <> '' then
  begin
    fpath := GetCachedFileName(tileX, tileY);
    if IEFileExists(fpath) then
      result := fpath;
  end;
end;



Bruce.
Go to Top of Page

xequte

38214 Posts

Posted - Aug 01 2018 :  18:30:31  Show Profile  Reply
Hi Bruce

Can you email me the details so I can test here.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

bmesser

United Kingdom
221 Posts

Posted - Aug 06 2018 :  04:44:55  Show Profile  Reply
I've sent you further details as requested via email.
Go to Top of Page

xequte

38214 Posts

Posted - Aug 09 2018 :  03:08:21  Show Profile  Reply
Hi

I have an updated version of the source and demo. Do you want me to email it?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

bmesser

United Kingdom
221 Posts

Posted - Aug 09 2018 :  03:48:12  Show Profile  Reply
Yes please, that would be great.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: