Skip to content

Commit

Permalink
Improve documentation and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lucernae committed Aug 6, 2018
1 parent 24413f2 commit 7ab82a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* PROJECT, compulsory, path where the project will be written on the file system.
* SOURCES, compulsory, it's a list of layer sources. It can be tile url or QGIS DataSource URI or files on the filesystem, separated by a semicolon.
Especially for QGIS DataSource URI, it must be url quoted twice (first the url, second the whole datasource string).
* FILES, optional, legacy parameter, it's a list of files on the filesystem, separated by a semicolon. It is overriden by SOURCES.
Previously FILES.
* NAMES, compulsory, it's a list of names, separated by a semicolon. It will be used for the legend. Items in this list should match layers in the FILES list.
* OVERWRITE, optional, false by default. Boolean if we can overwrite the existing PROJECT above. Values can be '1', 'YES', 'TRUE', 'yes', 'true'.
* REMOVEQML, optional, false by default. Boolean if we can remove the QML. The style is already in the QGS file. Values can be '1', 'YES', 'TRUE', 'yes', 'true'.
Expand Down Expand Up @@ -52,9 +52,9 @@ NAMES=Basemap;My layer 1;MyLayer 2;Layer 3&
OVERWRITE=true
```

In the sample request above, note that the datasource: ```type%253Dxyz%2526url%253Dhttp%25253A%2F%2Fa.tile.osm.org%2F%25257Bz%25257D%2F%25257Bx%25257D%2F%25257By%25257D.png``` were urlquoted twice.
The actual datasource is: ```type=xyz&url=http%3A//a.tile.osm.org/%7Bz%7D/%7Bx%7D/%7By%7D.png```
Note that the actual url is: ```http://a.tile.osm.org/{z}/{x}/{y}.png```
In the sample request above, note that the datasource: `type%253Dxyz%2526url%253Dhttp%25253A%2F%2Fa.tile.osm.org%2F%25257Bz%25257D%2F%25257Bx%25257D%2F%25257By%25257D.png` were urlquoted twice.
The actual datasource is: `type=xyz&url=http%3A//a.tile.osm.org/%7Bz%7D/%7Bx%7D/%7By%7D.png`
Note that the actual url is: `http://a.tile.osm.org/{z}/{x}/{y}.png`

Thus in order to send the request, the url needs to be quoted first before it was inserted into datasource uri (to quote & symbol and = from url).
Then, the datasource needs to be quoted again, because it was sent via GET requests url (to quote & symbol and = from datasource query params).
Expand Down
8 changes: 6 additions & 2 deletions filters/map_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def responseComplete(self):
SOURCES=type=xyz&url=http://tile.osm.org/{z}/{x}/{y}.png?layers=osm;
/path/1.shp;/path/2.shp;/path/3.asc&
FILES={Legacy Name for Sources Parameter}
NAMES=Layer 1;Layer 2;Layer 3&
NAMES=basemap;Layer 1;Layer 2;Layer 3&
REMOVEQML=true&
OVERWRITE=true&
"""
Expand Down Expand Up @@ -90,11 +90,15 @@ def responseComplete(self):
# Overwrite means create from scratch again
remove(project_path)

# Take datasource from SOURCES params
sources_parameters = params.get('SOURCES')
# support legacy params: FILES

# In case SOURCES empty, maybe they are still using FILES.
# Support legacy params: FILES.
if not sources_parameters:
sources_parameters = params.get('FILES')

# In case FILES also empty, raise error and exit.
if not sources_parameters:
request.appendBody('SOURCES parameter is missing.\n')
return
Expand Down

0 comments on commit 7ab82a4

Please sign in to comment.