Fix handling of apikey keyword for services with variants#12
Fix handling of apikey keyword for services with variants#12rafaqz merged 4 commits intoJuliaGeo:mainfrom
Conversation
| keyword = _access(first(values(v))) | ||
| keyword_docs = _keyword_docs(keyword, name) | ||
| variants = keys(v) | ||
| keyword_expr = isnothing(keyword) ? nothing : :(options[$(QuoteNode(keyword))] = $(Symbol(lowercase(string(keyword))))) |
There was a problem hiding this comment.
In options, it modifies the keyword corresponding value of the variant, instead of adding a new variant named keyword
If I add the two pieces of code below in both main and the CR:
...
contents = quote
provider_name = $name
options = copy($v)
variant in keys(options) || throw(ArgumentError("$provider_name variant must be from $(keys(options)), got $variant"))
$keyword_expr
# Showing variants and selected variant value
@show keys(options)
println("\noptions = ")
JSON3.pretty(options[variant])
println("\n")
#####
Provider(options[variant][:url], options[variant])
end
...
else
clean_keyword = Symbol(lowercase(string(keyword)))
# Showing keyword_expr
name == :GeoportailFrance && (@show keyword_expr; println())
#####
@eval begin
@doc $docstring
function $name(variant::Symbol; $clean_keyword)
$contents
end
end
@eval $name(; $clean_keyword) = $name($(QuoteNode(first(variants))); $clean_keyword=$clean_keyword)
end
...In main, you get a new variant :apikey, and the "apikey" is not modified and stays set to a default unusable value "choisirgeoportail":
julia> geturl(TileProviders.GeoportailFrance(:plan; apikey="cartes"), 1, 2, 3)
keyword_expr = :(options[:apikey] = apikey)
keys(options) = [:parcels, :plan, :apikey, :orthos]
options =
{
"url": "https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER={variant}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}",
"html_attribution": "<a target=\"_blank\" href=\"https://www.geoportail.gouv.fr/\">Geoportail France</a>",
"attribution": "Geoportail France",
"bounds": [
[
-75,
-180
],
[
81,
180
]
],
"min_zoom": 2,
"max_zoom": 18,
"apikey": "choisirgeoportail",
"format": "image/png",
"style": "normal",
"variant": "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
"name": "GeoportailFrance.plan"
}
"https://wxs.ign.fr/choisirgeoportail/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX=3&TILEROW=2&TILECOL=1"And with the CR, you get no new variant, and the "apikey" is set to the apikey arg:
ulia> geturl(TileProviders.GeoportailFrance(:plan; apikey="cartes"), 1, 2, 3)
keyword_expr = :((options[variant])[:apikey] = apikey)
keys(options) = [:parcels, :plan, :orthos]
options =
{
"min_zoom": 2,
"html_attribution": "<a target=\"_blank\" href=\"https://www.geoportail.gouv.fr/\">Geoportail France</a>",
"attribution": "Geoportail France",
"variant": "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
"max_zoom": 18,
"url": "https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER={variant}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}",
"name": "GeoportailFrance.plan",
"format": "image/png",
"apikey": "cartes",
"bounds": [
[
-75,
-180
],
[
81,
180
]
],
"style": "normal"
}
"https://wxs.ign.fr/cartes/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX=3&TILEROW=2&TILECOL=1"There was a problem hiding this comment.
Ahh ok seems I messes up where the key is set.
I dont think there are many people using the providers that need api keys, I didn't test most of them because I dont have access
.gitignore
Outdated
| *.jl.mem | ||
| /Manifest.toml | ||
| /docs/build/ | ||
| .vscode/settings.json |
There was a problem hiding this comment.
Haha sorry I didnt mean to be so blunt
|
Ok the question now is what to do about those Juilia 1.6 test failures. |
I do not have Linux, but macOS on Intel. I will run the tests locally with Julia 1.6 to see if I can reproduce the error |
|
Maybe we used new syntax for |
|
Thanks, I’m following this lead. I have reviewed Julia 1.6.7 replace code, but have not found the root cause yet. |
Well, no need to review the code, it was in docs. |
|
I guess I still have to raise the coverage a bit |
Well, I can't see an easy way to enhance the coverage. |
|
Perfect! no worries sbout coverage Thanks for fixing the tests |
I had an issue with
GeoPortailFrancenot taking in account theapikeykeyword.Now it works. I had to convert the
optionsJSON3.objecttoDictviacopyI added a test on the URL returned by
geturl