PHP Tile Server with User (and keys) Management
PHP Tile Server with User (and keys) Management
Important Notes:
The project is in a working state right now. However, it is still to be considered alpha, because I have still to come to a decision on the API signature (so not to change it later on). Moreover, extensive tests are lacking, security issues are not even considered, etc, etc…
However, the server is fully functional. In a very modified way(*) it is at the core of SentinelMap and SentinelMap Services.
Enjoy!
The script gts.sh has been provided in order to set up a docker environment to play with the tile server. The script itself is a thin wrapper around docker-compose, but it has grouped some niceties, including a wrapper for docker ps and stats, shells of containers and ‘hot shells’, i.e. shell for a running container, plus direct connection with the mysql interface of the running mysql container.
In order to use it,
./gts.sh build
./gts.sh start
#stop with
#./gts.sh stop
Now point your browser to http://localhost:8000 to be welcomed with the the two testing pages (for leaflet and openlayers respectively).
Database configuration can be done using the scripts provided under the DB-Config directory, adapted to your needs.
If you don’t want to have the hustle to change everything in the DB, do the following. We’ll use the docker environment, however, mutatis mutandis the procedure can be adapted to a non-containerized install as well.
Build the continers
./gts.sh build
Now, there are two undeclared commands inside gts.sh, namely test-install and test-uninstall
./gts.sh test-install
# test-uninstall to remove the installation
For user management we can do the following
./gts.sh mysql
# we should be now inside the mysql shell
mysql> INSERT INTO Users(username) VALUES('myusername');
# in oder to assign an apikey to the user:
mysql> INSERT INTO pkeys(pkey, userid) VALUES('apikey', (SELECT Users.userid FROM Users WHERE username = 'myusername'));
mysql> exit;
Alternatively you can use the poor man’s UI provided inside the same gts.sh:
./gts.sh adduserp <username> <pkey>
(alias for ./gts.sh aup <username> <pkey>
)
./gts.sh adduser <username>
(alias for ./gts.sh au <username>
)
./gts.sh showuser <username>
Shows info on user identified by <username>
.
./gts.sh showpkey <pkey>
(alias for ./gts.sh shk <pkey>
)
./gts.sh addpkey <username> <pkey>
Add a pkey (<pkey>
) to a user identified by <username>
.
./gts.sh delpkey <pkey>
(alias for ./gts.sh dk <pkey>
)
./gts.sh deluser <username>
Delete user identified by <username>
.
./gts.sh au <username>
Add a user to the system identified by <username>
.
./gts.sh aup <username> <pkey>
Add a user (<username>
), and a pkey (<pkey>
), at the same time.
./gts.sh shu <userid>
Show info on a user identified by <userid>
.
./gts.sh shk <pkey>
Show user connected to the <pkey>
./gts.sh ak <userid> <pkey>
Add a pkey (<pkey>
) to a user identified by <userid>
.
./gts.sh dk <pkey>
Delete the <pkey>
record.
./gts.sh du <userid>
Delete user identified by <userid>
.
The gts_config.ini configures the tileserver and the access to the mysql instance.
[tiles]
./tiles/
image/json
[mysql]
localhost
3306
gts
gtsuser
test123
March 17, 2017 (St. Pat’s)
mime
to gts_config.ini in order to pass whichever image type as tile to the server.() very modified way*: It has been enhanced with an eye on high volumes, multiple map management, and tailored to support our own user database. Plus it as a UI connected to it, for key management and for visualizing the tile count.