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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIESlippyMapProvider

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bmesser Posted - Jul 28 2018 : 08:51:46
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.
9   L A T E S T    R E P L I E S    (Newest First)
bmesser Posted - Aug 09 2018 : 03:48:12
Yes please, that would be great.
xequte Posted - Aug 09 2018 : 03:08:21
Hi

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



Nigel
Xequte Software
www.imageen.com
bmesser Posted - Aug 06 2018 : 04:44:55
I've sent you further details as requested via email.
xequte Posted - Aug 01 2018 : 18:30:31
Hi Bruce

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

Nigel
Xequte Software
www.imageen.com
bmesser Posted - Jul 31 2018 : 05:27:05
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.
xequte Posted - Jul 30 2018 : 20:21:57
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
bmesser Posted - Jul 30 2018 : 12:53:23
I can now see that the [abc] refer to the tile server subdomain:-


bmesser Posted - Jul 30 2018 : 12:19:10
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.




xequte Posted - Jul 29 2018 : 16:01:38
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