summaryrefslogtreecommitdiff
path: root/python-tilecloud.spec
blob: 0d8d496689801888299c0b33057b48ad7eee92b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
%global _empty_manifest_terminate_build 0
Name:		python-tilecloud
Version:	1.9.3
Release:	1
Summary:	Tools for managing tiles
License:	BSD
URL:		https://github.com/camptocamp/tilecloud
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/4d/21/5da521956029834cd0bf6ad0a6bb648f29a7857ff297f4be9e13ad6c6061/tilecloud-1.9.3.tar.gz
BuildArch:	noarch

Requires:	python3-Pillow
Requires:	python3-azure-identity
Requires:	python3-azure-storage-blob
Requires:	python3-boto3
Requires:	python3-bottle
Requires:	python3-c2cwsgiutils[broadcast]
Requires:	python3-pyproj
Requires:	python3-pyramid
Requires:	python3-redis
Requires:	python3-requests

%description
# TileCloud

A powerful utility for generating, managing, transforming, and visualizing map tiles in multiple formats.

## Introduction

TileCloud is a powerful utility for generating, managing, transforming, visualizing and map tiles in multiple
formats. It can create, read update, delete tiles in multiple back ends, called TileStores. Existing
TileStores include:

- HTTP/REST in any layout
- WMTS
- Amazon [S3](http://aws.amazon.com/s3/) and [SQS](http://aws.amazon.com/sqs/)
- [MBTiles](https://github.com/mapbox/mbtiles-spec)
- [TileJSON](https://github.com/mapbox/TileJSON)
- [Mapnik](http://mapnik.org/) (via [mapnik2](http://pypi.python.org/pypi/mapnik2))
- [Memcached](http://memcached.org/)
- Local file system
- Log files in any format

TileCloud is not limited to image tiles, it can also handle other tile data such as
[UTFGrid](https://github.com/mapbox/utfgrid-spec), or elevation data in JSON format.

TileCloud uses Python's generators and iterators to efficiently stream tens of millions of tiles, and can
handle multiple tiles in parallel using Python's
[multiprocessing](http://docs.python.org/library/multiprocessing.html) library.

Example tasks that TileCloud makes easy include:

- Visualize tiles stored in any TileStore with [OpenLayers](http://www.openlayers.org/), [Google
  Maps](http://maps.google.com/), [jQuery Geo](http://www.jquerygeo.com/),
  [Leaflet](http://leaflet.cloudmade.com/), [Polymaps](http://polymaps.org/), [Modest
  Maps](http://www.modestmaps.com/), and [OpenWebGlobe](http://www.openwebglobe.org/).
- Convert sixty million PNG tiles stored in S3 to JPEG format with different quality settings at different
  zoom levels.
- Transform image formats and perform arbitrary image transformations on the fly, including PNG
  optimization.
- Generate semi-transparent tiles with embedded tile coordinates for debugging.
- Pack multiple tile layers into a single tile on the server.
- Efficiently calculate bounding boxes and detect missing tiles in existing tile datasets.
- Simulate fast and slow tile servers.
- Efficiently delete millions of tiles in S3.
- Read JSON tiles from a tarball, compress them, and upload them.

## Getting started

TileCloud depends on some Python modules. It's easiest to install them with `pip` in a `virtualenv`:

    $ python3 -m venv .venv
    $ . .venv/bin/activate
    $ pip install -r requirements.txt

For a quick demo, run

    $ ./tc-viewer --root=3/4/2 'http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_GB&z=%(z)d&x=%(x)d&y=%(y)d&v=9'

and point your browser at <http://localhost:8080/>. Type `Ctrl-C` to terminate `tc-viewer`.

Next, download an example MBTiles file from [MapBox](http://mapbox.com/), such as [Geography
Class](http://tiles.mapbox.com/mapbox/map/geography-class). We can quickly find out more about this tile set
with the `tc-info` command. For example, to count the number of tiles:

    $ ./tc-info -t count geography-class.mbtiles
    87381

To calculate the bounding pyramid:

    $ ./tc-info -t bounding-pyramid -r geography-class.mbtiles
    0/0/0:+1/+1
    1/0/0:+2/+2
    2/0/0:+4/+4
    3/0/0:+8/+8
    4/0/0:+16/+16
    5/0/0:+32/+32
    6/0/0:+64/+64
    7/0/0:+128/+128
    8/0/0:+256/+256

To check for missing tiles against a bounding pyramid:

    $ ./tc-info -b 0/0/0:8/*/* -t completion geography-class.mbtiles
    0 1/1 (100%)
    1 4/4 (100%)
    2 16/16 (100%)
    3 64/64 (100%)
    4 256/256 (100%)
    5 1024/1024 (100%)
    6 4096/4096 (100%)
    7 16384/16384 (100%)
    8 65536/65536 (100%)

This shows, for each zoom level, the number of tiles at that zoom level, the total number of tiles expected at
that zoom level for the specified bounding pyramid (`0/0/0:8/*/*` means all tiles from level 0 to level 8),
and a percentage completion. This can be useful for checking that a tile set is complete.

Now, display this MBTiles tile set on top of the [OpenStreetMap](http://www.openstreetmap.org/) tiles and a
debug tile layer:

    $ ./tc-viewer tiles.openstreetmap_org geography-class.mbtiles tiles.debug.black

You'll need to point your browser at <http://localhost:8080/> and choose your favorite library.

`tc-info` and `tc-viewer` are utility programs. Normally you use TileCloud by writing short Python programs
that connect the TileCloud's modules to perform the action that you want.

As a first example, run the following:

    $ PYTHONPATH=. examples/download.py

This will download a few tiles from [OpenStreetMap](http://www.openstreetmap.org/) and save them in a local
MBTiles file called `local.mbtiles`. Look at the source code to `examples/download.py` to see how it works. If
there are problems with the download, just interrupt it with `Ctrl-C` and re-run it: the program will
automatically resume where it left off.

Once you have downloaded a few tiles, you can view them directly with `tc-viewer`:

    $ ./tc-viewer --root=4/8/5 local.mbtiles tiles.debug.black

Point your browser at <http://localhost:8080> as usual. The `--root` option to `tc-viewer` instructs the
viewer to start at a defined tile, rather than at 0/0/0, so you don't have to zoom in to find the tiles that
you downloaded.

## Changelog

### 1.9.0

- Add the following extra dependencies `azure`, `aws`, `wsgi`, `redis`, `all`.

## Tile coordinates, tile layouts, tile grids and bounding pyramids

TileCloud always represents tile coordinates as strings like `z/x/y`. TileCloud primarily works in tile
coordinates, although geographic coordinates can be used in some places.

Tile layouts convert tile coordinates to and from strings for use in paths, URLs, keys, etc.

Tile grids are used to convert tile coordinates to and from geographic coordinates, and to relate tiles with
different z values.

Bounding pyramids represent a range of tiles in the x, y and z directions. The format is basically
`minz/minx/miny:maxz/maxx/maxy` but `maxz` is optional and `maxz`, `maxx` and `maxy` can be prefixed with an
`+` sign to indicate that they are relative to the corresponding `min` value. This is probably best
demonstrated by a few examples:

`4/10/20:15/25`

: This corresponds to a range of tiles with z=4, x=10..15 and y=20..25

`4/10/20:+5/+5`

: This is the same range (z=4, x=10..15, y=20..25) but expressed using relative sizes.

`4/10/20:5/15/20`

: This is the same range of tiles above, but also includes all the tiles at level z=5 which overlap the
above range. TileCloud uses the tile grid to calculate which tiles from level z=5 to include.

`4/10/20:+1/+5/+5`

: This represents the range same as the previous example using a relative `maxz`.

## Quick tile generation

The `tc-copy` command can be used to copy tiles between different TileStores. If a TileStore has the side
effect of generating tiles, then it functions as a quick tile generation utility. First, some quick examples.

To convert from one tile format to another, just copy from source to destination. For example, to convert an
MBTiles file in to a ZIP file, just run:

    $ ./tc-copy geography-class.mbtiles geography-class.zip

You can check this worked with `unzip`:

    $ unzip -t geography-class.zip

Equally, `tc-copy` can be used to download multiple tiles:

    $ ./tc-copy --bounding-pyramid 4/0/0:0/16/16 tiles.openstreetmap_org osm-up-to-z4.mbtiles

Here we downloaded zoom levels 0 to 4 of the OpenStreetMap tiles into a local MBTiles file. The
`--bounding-pyramid` option is required because otherwise we would download _all_ OpenStreetMap tiles -- which
might take some time (and also contravene OpenStreetMap's tile usage policy). Note that, by default, `tc-copy`
won't overwrite tiles if they already exist in the destination. This means that you can interrupt the above
command and restart it, and it will resume where it was interrupted. If you want to overwrite tiles in the
destination then pass the `--overwrite` option to `tc-copy`.

In the same way, `tc-copy` can also be used to upload tiles. For example, to upload an MBTiles file to S3,
just use:

    $ ./tc-copy osm-up-to-z4.mbtiles s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

`bucket` is the name of your S3 bucket. You'll need to have set the `AWS_ACCESS_KEY_ID` and
`AWS_SECRET_ACCESS_KEY` environment variables to have permission to upload to S3. The rest of the destination
(`prefix/%(z)d/%(x)d/%(y)d.jpg`) is a template describing the layout of the tiles in S3. It's a normal Python
format string: `%(x)d` means substitute the tile's `x` coordinate as a decimal integer.

You can pass the same `s3://` URL to `tc-viewer`. This allows you to visualize your tiles stored in S3 with
your favorite mapping library. For example:

    $ ./tc-viewer s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

Here, `tc-viewer` is acting as a proxy, serving tiles stored in S3 over HTTP, bypassing any caches or access
controls (assuming you have the correct credentials, of course). This allows you to visualize the exact tiles
that you've stored.

## Rendering the World

At [FOSS4G-NA](http://foss4g-na.org/), [MapBox](http://mapbox.com/) presented an excellent strategy for
[rendering the world](http://mapbox.com/blog/rendering-the-world/). TileCloud supports the subdivision
strategy. To run the demo, execute:

    $ python examples/renderingtheworld.py

This will generate tiles from a WMTS tile server and save them in a local MBTiles tiles. When the above
command is complete, you can see the bounding pyramid of the generated tiles:

    $ ./tc-info -t bounding-pyramid -r medford_buildings.mbtiles
    0/0/0:+1/+1
    1/0/0:+1/+1
    2/0/1:+1/+1
    3/1/2:+1/+1
    4/2/5:+1/+1
    5/5/11:+1/+1
    6/10/23:+1/+1
    7/20/47:+1/+1
    8/40/94:+2/+2
    9/80/189:+2/+1
    10/162/378:+1/+2
    11/324/757:+2/+2
    12/649/1514:+3/+3
    13/1299/3028:+4/+5
    14/2598/6057:+7/+8
    15/5196/12114:+13/+15

You can look at these tiles (which show buildings in Medford, OR) with the command:

    ./tc-viewer --root=7/20/47 tiles.openstreetmap_org medford_buildings.mbtiles

## A cheap-and-cheerful tile server

`tc-viewer` can be used as a lightweight tile server, which can be useful for development, debugging and
off-line demos. The TileStores passed as arguments to `tc-viewer` are available at the URL:

    http://localhost:8080/tiles/{index}/tiles/{z}/{x}/{y}

where `{index}` is the index of the TileStore on the command line (starting from 0 for the first tile store),
and `{z}`, `{x}` and `{y}` are the components of the tile coordinate. The second `tiles` in the URL is present
to work around assumptions made by OpenWebGlobe. This layout is directly usable by most mapping libraries, see
the code in `views/*.tpl` for examples. The host and port can be set with the `--host` and `--port` command
line options, respectively.

Note that there is no file extension. `tc-viewer` will automatically set the correct content type and content
encoding headers if it can determine them, and, failing this, most browsers will figure it out for themselves.

For convenience, `tc-viewer` serves everything in the `static` directory under the URL `/static`. This can be
used to serve your favorite mapping library and/or application code directly for testing purposes.

By default, `tc-viewer` will use [Tornado](http://www.tornadoweb.org/) as a web server, if it is available,
otherwise it will fall back to [WSGIRef](http://docs.python.org/library/wsgiref.html). Tornado has reasonably
good performance, and is adequate for local development and off-line demos, especially when used with a
MBTiles TileStore. WSGIRef has very poor performance (it handles only one request at a time) and as such can
be used as a "slow" tile server, ideal for debugging tile loading code or testing how your web application
performs over a slow network connection. `tc-viewer` is particularly slow when used to proxy tiles being
served by a remote server. You can set the server explicitly with the `--server` option.

`tc-viewer` sets the `Access-Control-Allow-Origin` header to `*` for all the tiles it serves, this allows the
tiles to be used as textures for WebGL applications running on different hosts/ports. For more information,
see [Cross-Domain Textures](https://developer.mozilla.org/en/WebGL/Cross-Domain_Textures).

`tc-viewer` is designed as a development tool, and the power that it offers comes at the expense of fragility.
It makes many assumptions - including the benevolence of the user - that make it entirely unsuitable as a
generic tile server. It should only be used in development or demonstration environments.

## Comparing mapping libraries

`tc-viewer` supports most popular web mapping libraries out-of-the box. This can be very useful for quick,
practical comparisons. If your favorite mapping library is missing, please submit an
[issue](https://github.com/camptocamp/tilecloud/issues), or, even better, a [pull
request](https://github.com/camptocamp/tilecloud/pulls).

## Contributing

Please report bugs and feature requests using the [GitHub issue
tracker](https://github.com/camptocamp/tilecloud/issues).

If you'd like to contribute to TileCloud, please install the development requirements:

    $ pip install -r dev-requirements.txt

TileCloud comes with unit tests in the `tilecloud/tests` directory. You can run these with the command:

    $ make test

This is equivalent to:

    $ python setup.py nosetests

For pull requests, it is very much appreciated if your code passes `prospector` without warnings. You can run
prospector on the codebase with the command:

    $ make prospector

## License

Copyright (c) 2012, Tom Payne <twpayne@gmail.com> All rights reserved.
Copyright (c) 2012, Camptocamp All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the
  following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

vim: set filetype=rst spell spelllang=en textwidth=0:



%package -n python3-tilecloud
Summary:	Tools for managing tiles
Provides:	python-tilecloud
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-tilecloud
# TileCloud

A powerful utility for generating, managing, transforming, and visualizing map tiles in multiple formats.

## Introduction

TileCloud is a powerful utility for generating, managing, transforming, visualizing and map tiles in multiple
formats. It can create, read update, delete tiles in multiple back ends, called TileStores. Existing
TileStores include:

- HTTP/REST in any layout
- WMTS
- Amazon [S3](http://aws.amazon.com/s3/) and [SQS](http://aws.amazon.com/sqs/)
- [MBTiles](https://github.com/mapbox/mbtiles-spec)
- [TileJSON](https://github.com/mapbox/TileJSON)
- [Mapnik](http://mapnik.org/) (via [mapnik2](http://pypi.python.org/pypi/mapnik2))
- [Memcached](http://memcached.org/)
- Local file system
- Log files in any format

TileCloud is not limited to image tiles, it can also handle other tile data such as
[UTFGrid](https://github.com/mapbox/utfgrid-spec), or elevation data in JSON format.

TileCloud uses Python's generators and iterators to efficiently stream tens of millions of tiles, and can
handle multiple tiles in parallel using Python's
[multiprocessing](http://docs.python.org/library/multiprocessing.html) library.

Example tasks that TileCloud makes easy include:

- Visualize tiles stored in any TileStore with [OpenLayers](http://www.openlayers.org/), [Google
  Maps](http://maps.google.com/), [jQuery Geo](http://www.jquerygeo.com/),
  [Leaflet](http://leaflet.cloudmade.com/), [Polymaps](http://polymaps.org/), [Modest
  Maps](http://www.modestmaps.com/), and [OpenWebGlobe](http://www.openwebglobe.org/).
- Convert sixty million PNG tiles stored in S3 to JPEG format with different quality settings at different
  zoom levels.
- Transform image formats and perform arbitrary image transformations on the fly, including PNG
  optimization.
- Generate semi-transparent tiles with embedded tile coordinates for debugging.
- Pack multiple tile layers into a single tile on the server.
- Efficiently calculate bounding boxes and detect missing tiles in existing tile datasets.
- Simulate fast and slow tile servers.
- Efficiently delete millions of tiles in S3.
- Read JSON tiles from a tarball, compress them, and upload them.

## Getting started

TileCloud depends on some Python modules. It's easiest to install them with `pip` in a `virtualenv`:

    $ python3 -m venv .venv
    $ . .venv/bin/activate
    $ pip install -r requirements.txt

For a quick demo, run

    $ ./tc-viewer --root=3/4/2 'http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_GB&z=%(z)d&x=%(x)d&y=%(y)d&v=9'

and point your browser at <http://localhost:8080/>. Type `Ctrl-C` to terminate `tc-viewer`.

Next, download an example MBTiles file from [MapBox](http://mapbox.com/), such as [Geography
Class](http://tiles.mapbox.com/mapbox/map/geography-class). We can quickly find out more about this tile set
with the `tc-info` command. For example, to count the number of tiles:

    $ ./tc-info -t count geography-class.mbtiles
    87381

To calculate the bounding pyramid:

    $ ./tc-info -t bounding-pyramid -r geography-class.mbtiles
    0/0/0:+1/+1
    1/0/0:+2/+2
    2/0/0:+4/+4
    3/0/0:+8/+8
    4/0/0:+16/+16
    5/0/0:+32/+32
    6/0/0:+64/+64
    7/0/0:+128/+128
    8/0/0:+256/+256

To check for missing tiles against a bounding pyramid:

    $ ./tc-info -b 0/0/0:8/*/* -t completion geography-class.mbtiles
    0 1/1 (100%)
    1 4/4 (100%)
    2 16/16 (100%)
    3 64/64 (100%)
    4 256/256 (100%)
    5 1024/1024 (100%)
    6 4096/4096 (100%)
    7 16384/16384 (100%)
    8 65536/65536 (100%)

This shows, for each zoom level, the number of tiles at that zoom level, the total number of tiles expected at
that zoom level for the specified bounding pyramid (`0/0/0:8/*/*` means all tiles from level 0 to level 8),
and a percentage completion. This can be useful for checking that a tile set is complete.

Now, display this MBTiles tile set on top of the [OpenStreetMap](http://www.openstreetmap.org/) tiles and a
debug tile layer:

    $ ./tc-viewer tiles.openstreetmap_org geography-class.mbtiles tiles.debug.black

You'll need to point your browser at <http://localhost:8080/> and choose your favorite library.

`tc-info` and `tc-viewer` are utility programs. Normally you use TileCloud by writing short Python programs
that connect the TileCloud's modules to perform the action that you want.

As a first example, run the following:

    $ PYTHONPATH=. examples/download.py

This will download a few tiles from [OpenStreetMap](http://www.openstreetmap.org/) and save them in a local
MBTiles file called `local.mbtiles`. Look at the source code to `examples/download.py` to see how it works. If
there are problems with the download, just interrupt it with `Ctrl-C` and re-run it: the program will
automatically resume where it left off.

Once you have downloaded a few tiles, you can view them directly with `tc-viewer`:

    $ ./tc-viewer --root=4/8/5 local.mbtiles tiles.debug.black

Point your browser at <http://localhost:8080> as usual. The `--root` option to `tc-viewer` instructs the
viewer to start at a defined tile, rather than at 0/0/0, so you don't have to zoom in to find the tiles that
you downloaded.

## Changelog

### 1.9.0

- Add the following extra dependencies `azure`, `aws`, `wsgi`, `redis`, `all`.

## Tile coordinates, tile layouts, tile grids and bounding pyramids

TileCloud always represents tile coordinates as strings like `z/x/y`. TileCloud primarily works in tile
coordinates, although geographic coordinates can be used in some places.

Tile layouts convert tile coordinates to and from strings for use in paths, URLs, keys, etc.

Tile grids are used to convert tile coordinates to and from geographic coordinates, and to relate tiles with
different z values.

Bounding pyramids represent a range of tiles in the x, y and z directions. The format is basically
`minz/minx/miny:maxz/maxx/maxy` but `maxz` is optional and `maxz`, `maxx` and `maxy` can be prefixed with an
`+` sign to indicate that they are relative to the corresponding `min` value. This is probably best
demonstrated by a few examples:

`4/10/20:15/25`

: This corresponds to a range of tiles with z=4, x=10..15 and y=20..25

`4/10/20:+5/+5`

: This is the same range (z=4, x=10..15, y=20..25) but expressed using relative sizes.

`4/10/20:5/15/20`

: This is the same range of tiles above, but also includes all the tiles at level z=5 which overlap the
above range. TileCloud uses the tile grid to calculate which tiles from level z=5 to include.

`4/10/20:+1/+5/+5`

: This represents the range same as the previous example using a relative `maxz`.

## Quick tile generation

The `tc-copy` command can be used to copy tiles between different TileStores. If a TileStore has the side
effect of generating tiles, then it functions as a quick tile generation utility. First, some quick examples.

To convert from one tile format to another, just copy from source to destination. For example, to convert an
MBTiles file in to a ZIP file, just run:

    $ ./tc-copy geography-class.mbtiles geography-class.zip

You can check this worked with `unzip`:

    $ unzip -t geography-class.zip

Equally, `tc-copy` can be used to download multiple tiles:

    $ ./tc-copy --bounding-pyramid 4/0/0:0/16/16 tiles.openstreetmap_org osm-up-to-z4.mbtiles

Here we downloaded zoom levels 0 to 4 of the OpenStreetMap tiles into a local MBTiles file. The
`--bounding-pyramid` option is required because otherwise we would download _all_ OpenStreetMap tiles -- which
might take some time (and also contravene OpenStreetMap's tile usage policy). Note that, by default, `tc-copy`
won't overwrite tiles if they already exist in the destination. This means that you can interrupt the above
command and restart it, and it will resume where it was interrupted. If you want to overwrite tiles in the
destination then pass the `--overwrite` option to `tc-copy`.

In the same way, `tc-copy` can also be used to upload tiles. For example, to upload an MBTiles file to S3,
just use:

    $ ./tc-copy osm-up-to-z4.mbtiles s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

`bucket` is the name of your S3 bucket. You'll need to have set the `AWS_ACCESS_KEY_ID` and
`AWS_SECRET_ACCESS_KEY` environment variables to have permission to upload to S3. The rest of the destination
(`prefix/%(z)d/%(x)d/%(y)d.jpg`) is a template describing the layout of the tiles in S3. It's a normal Python
format string: `%(x)d` means substitute the tile's `x` coordinate as a decimal integer.

You can pass the same `s3://` URL to `tc-viewer`. This allows you to visualize your tiles stored in S3 with
your favorite mapping library. For example:

    $ ./tc-viewer s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

Here, `tc-viewer` is acting as a proxy, serving tiles stored in S3 over HTTP, bypassing any caches or access
controls (assuming you have the correct credentials, of course). This allows you to visualize the exact tiles
that you've stored.

## Rendering the World

At [FOSS4G-NA](http://foss4g-na.org/), [MapBox](http://mapbox.com/) presented an excellent strategy for
[rendering the world](http://mapbox.com/blog/rendering-the-world/). TileCloud supports the subdivision
strategy. To run the demo, execute:

    $ python examples/renderingtheworld.py

This will generate tiles from a WMTS tile server and save them in a local MBTiles tiles. When the above
command is complete, you can see the bounding pyramid of the generated tiles:

    $ ./tc-info -t bounding-pyramid -r medford_buildings.mbtiles
    0/0/0:+1/+1
    1/0/0:+1/+1
    2/0/1:+1/+1
    3/1/2:+1/+1
    4/2/5:+1/+1
    5/5/11:+1/+1
    6/10/23:+1/+1
    7/20/47:+1/+1
    8/40/94:+2/+2
    9/80/189:+2/+1
    10/162/378:+1/+2
    11/324/757:+2/+2
    12/649/1514:+3/+3
    13/1299/3028:+4/+5
    14/2598/6057:+7/+8
    15/5196/12114:+13/+15

You can look at these tiles (which show buildings in Medford, OR) with the command:

    ./tc-viewer --root=7/20/47 tiles.openstreetmap_org medford_buildings.mbtiles

## A cheap-and-cheerful tile server

`tc-viewer` can be used as a lightweight tile server, which can be useful for development, debugging and
off-line demos. The TileStores passed as arguments to `tc-viewer` are available at the URL:

    http://localhost:8080/tiles/{index}/tiles/{z}/{x}/{y}

where `{index}` is the index of the TileStore on the command line (starting from 0 for the first tile store),
and `{z}`, `{x}` and `{y}` are the components of the tile coordinate. The second `tiles` in the URL is present
to work around assumptions made by OpenWebGlobe. This layout is directly usable by most mapping libraries, see
the code in `views/*.tpl` for examples. The host and port can be set with the `--host` and `--port` command
line options, respectively.

Note that there is no file extension. `tc-viewer` will automatically set the correct content type and content
encoding headers if it can determine them, and, failing this, most browsers will figure it out for themselves.

For convenience, `tc-viewer` serves everything in the `static` directory under the URL `/static`. This can be
used to serve your favorite mapping library and/or application code directly for testing purposes.

By default, `tc-viewer` will use [Tornado](http://www.tornadoweb.org/) as a web server, if it is available,
otherwise it will fall back to [WSGIRef](http://docs.python.org/library/wsgiref.html). Tornado has reasonably
good performance, and is adequate for local development and off-line demos, especially when used with a
MBTiles TileStore. WSGIRef has very poor performance (it handles only one request at a time) and as such can
be used as a "slow" tile server, ideal for debugging tile loading code or testing how your web application
performs over a slow network connection. `tc-viewer` is particularly slow when used to proxy tiles being
served by a remote server. You can set the server explicitly with the `--server` option.

`tc-viewer` sets the `Access-Control-Allow-Origin` header to `*` for all the tiles it serves, this allows the
tiles to be used as textures for WebGL applications running on different hosts/ports. For more information,
see [Cross-Domain Textures](https://developer.mozilla.org/en/WebGL/Cross-Domain_Textures).

`tc-viewer` is designed as a development tool, and the power that it offers comes at the expense of fragility.
It makes many assumptions - including the benevolence of the user - that make it entirely unsuitable as a
generic tile server. It should only be used in development or demonstration environments.

## Comparing mapping libraries

`tc-viewer` supports most popular web mapping libraries out-of-the box. This can be very useful for quick,
practical comparisons. If your favorite mapping library is missing, please submit an
[issue](https://github.com/camptocamp/tilecloud/issues), or, even better, a [pull
request](https://github.com/camptocamp/tilecloud/pulls).

## Contributing

Please report bugs and feature requests using the [GitHub issue
tracker](https://github.com/camptocamp/tilecloud/issues).

If you'd like to contribute to TileCloud, please install the development requirements:

    $ pip install -r dev-requirements.txt

TileCloud comes with unit tests in the `tilecloud/tests` directory. You can run these with the command:

    $ make test

This is equivalent to:

    $ python setup.py nosetests

For pull requests, it is very much appreciated if your code passes `prospector` without warnings. You can run
prospector on the codebase with the command:

    $ make prospector

## License

Copyright (c) 2012, Tom Payne <twpayne@gmail.com> All rights reserved.
Copyright (c) 2012, Camptocamp All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the
  following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

vim: set filetype=rst spell spelllang=en textwidth=0:



%package help
Summary:	Development documents and examples for tilecloud
Provides:	python3-tilecloud-doc
%description help
# TileCloud

A powerful utility for generating, managing, transforming, and visualizing map tiles in multiple formats.

## Introduction

TileCloud is a powerful utility for generating, managing, transforming, visualizing and map tiles in multiple
formats. It can create, read update, delete tiles in multiple back ends, called TileStores. Existing
TileStores include:

- HTTP/REST in any layout
- WMTS
- Amazon [S3](http://aws.amazon.com/s3/) and [SQS](http://aws.amazon.com/sqs/)
- [MBTiles](https://github.com/mapbox/mbtiles-spec)
- [TileJSON](https://github.com/mapbox/TileJSON)
- [Mapnik](http://mapnik.org/) (via [mapnik2](http://pypi.python.org/pypi/mapnik2))
- [Memcached](http://memcached.org/)
- Local file system
- Log files in any format

TileCloud is not limited to image tiles, it can also handle other tile data such as
[UTFGrid](https://github.com/mapbox/utfgrid-spec), or elevation data in JSON format.

TileCloud uses Python's generators and iterators to efficiently stream tens of millions of tiles, and can
handle multiple tiles in parallel using Python's
[multiprocessing](http://docs.python.org/library/multiprocessing.html) library.

Example tasks that TileCloud makes easy include:

- Visualize tiles stored in any TileStore with [OpenLayers](http://www.openlayers.org/), [Google
  Maps](http://maps.google.com/), [jQuery Geo](http://www.jquerygeo.com/),
  [Leaflet](http://leaflet.cloudmade.com/), [Polymaps](http://polymaps.org/), [Modest
  Maps](http://www.modestmaps.com/), and [OpenWebGlobe](http://www.openwebglobe.org/).
- Convert sixty million PNG tiles stored in S3 to JPEG format with different quality settings at different
  zoom levels.
- Transform image formats and perform arbitrary image transformations on the fly, including PNG
  optimization.
- Generate semi-transparent tiles with embedded tile coordinates for debugging.
- Pack multiple tile layers into a single tile on the server.
- Efficiently calculate bounding boxes and detect missing tiles in existing tile datasets.
- Simulate fast and slow tile servers.
- Efficiently delete millions of tiles in S3.
- Read JSON tiles from a tarball, compress them, and upload them.

## Getting started

TileCloud depends on some Python modules. It's easiest to install them with `pip` in a `virtualenv`:

    $ python3 -m venv .venv
    $ . .venv/bin/activate
    $ pip install -r requirements.txt

For a quick demo, run

    $ ./tc-viewer --root=3/4/2 'http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_GB&z=%(z)d&x=%(x)d&y=%(y)d&v=9'

and point your browser at <http://localhost:8080/>. Type `Ctrl-C` to terminate `tc-viewer`.

Next, download an example MBTiles file from [MapBox](http://mapbox.com/), such as [Geography
Class](http://tiles.mapbox.com/mapbox/map/geography-class). We can quickly find out more about this tile set
with the `tc-info` command. For example, to count the number of tiles:

    $ ./tc-info -t count geography-class.mbtiles
    87381

To calculate the bounding pyramid:

    $ ./tc-info -t bounding-pyramid -r geography-class.mbtiles
    0/0/0:+1/+1
    1/0/0:+2/+2
    2/0/0:+4/+4
    3/0/0:+8/+8
    4/0/0:+16/+16
    5/0/0:+32/+32
    6/0/0:+64/+64
    7/0/0:+128/+128
    8/0/0:+256/+256

To check for missing tiles against a bounding pyramid:

    $ ./tc-info -b 0/0/0:8/*/* -t completion geography-class.mbtiles
    0 1/1 (100%)
    1 4/4 (100%)
    2 16/16 (100%)
    3 64/64 (100%)
    4 256/256 (100%)
    5 1024/1024 (100%)
    6 4096/4096 (100%)
    7 16384/16384 (100%)
    8 65536/65536 (100%)

This shows, for each zoom level, the number of tiles at that zoom level, the total number of tiles expected at
that zoom level for the specified bounding pyramid (`0/0/0:8/*/*` means all tiles from level 0 to level 8),
and a percentage completion. This can be useful for checking that a tile set is complete.

Now, display this MBTiles tile set on top of the [OpenStreetMap](http://www.openstreetmap.org/) tiles and a
debug tile layer:

    $ ./tc-viewer tiles.openstreetmap_org geography-class.mbtiles tiles.debug.black

You'll need to point your browser at <http://localhost:8080/> and choose your favorite library.

`tc-info` and `tc-viewer` are utility programs. Normally you use TileCloud by writing short Python programs
that connect the TileCloud's modules to perform the action that you want.

As a first example, run the following:

    $ PYTHONPATH=. examples/download.py

This will download a few tiles from [OpenStreetMap](http://www.openstreetmap.org/) and save them in a local
MBTiles file called `local.mbtiles`. Look at the source code to `examples/download.py` to see how it works. If
there are problems with the download, just interrupt it with `Ctrl-C` and re-run it: the program will
automatically resume where it left off.

Once you have downloaded a few tiles, you can view them directly with `tc-viewer`:

    $ ./tc-viewer --root=4/8/5 local.mbtiles tiles.debug.black

Point your browser at <http://localhost:8080> as usual. The `--root` option to `tc-viewer` instructs the
viewer to start at a defined tile, rather than at 0/0/0, so you don't have to zoom in to find the tiles that
you downloaded.

## Changelog

### 1.9.0

- Add the following extra dependencies `azure`, `aws`, `wsgi`, `redis`, `all`.

## Tile coordinates, tile layouts, tile grids and bounding pyramids

TileCloud always represents tile coordinates as strings like `z/x/y`. TileCloud primarily works in tile
coordinates, although geographic coordinates can be used in some places.

Tile layouts convert tile coordinates to and from strings for use in paths, URLs, keys, etc.

Tile grids are used to convert tile coordinates to and from geographic coordinates, and to relate tiles with
different z values.

Bounding pyramids represent a range of tiles in the x, y and z directions. The format is basically
`minz/minx/miny:maxz/maxx/maxy` but `maxz` is optional and `maxz`, `maxx` and `maxy` can be prefixed with an
`+` sign to indicate that they are relative to the corresponding `min` value. This is probably best
demonstrated by a few examples:

`4/10/20:15/25`

: This corresponds to a range of tiles with z=4, x=10..15 and y=20..25

`4/10/20:+5/+5`

: This is the same range (z=4, x=10..15, y=20..25) but expressed using relative sizes.

`4/10/20:5/15/20`

: This is the same range of tiles above, but also includes all the tiles at level z=5 which overlap the
above range. TileCloud uses the tile grid to calculate which tiles from level z=5 to include.

`4/10/20:+1/+5/+5`

: This represents the range same as the previous example using a relative `maxz`.

## Quick tile generation

The `tc-copy` command can be used to copy tiles between different TileStores. If a TileStore has the side
effect of generating tiles, then it functions as a quick tile generation utility. First, some quick examples.

To convert from one tile format to another, just copy from source to destination. For example, to convert an
MBTiles file in to a ZIP file, just run:

    $ ./tc-copy geography-class.mbtiles geography-class.zip

You can check this worked with `unzip`:

    $ unzip -t geography-class.zip

Equally, `tc-copy` can be used to download multiple tiles:

    $ ./tc-copy --bounding-pyramid 4/0/0:0/16/16 tiles.openstreetmap_org osm-up-to-z4.mbtiles

Here we downloaded zoom levels 0 to 4 of the OpenStreetMap tiles into a local MBTiles file. The
`--bounding-pyramid` option is required because otherwise we would download _all_ OpenStreetMap tiles -- which
might take some time (and also contravene OpenStreetMap's tile usage policy). Note that, by default, `tc-copy`
won't overwrite tiles if they already exist in the destination. This means that you can interrupt the above
command and restart it, and it will resume where it was interrupted. If you want to overwrite tiles in the
destination then pass the `--overwrite` option to `tc-copy`.

In the same way, `tc-copy` can also be used to upload tiles. For example, to upload an MBTiles file to S3,
just use:

    $ ./tc-copy osm-up-to-z4.mbtiles s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

`bucket` is the name of your S3 bucket. You'll need to have set the `AWS_ACCESS_KEY_ID` and
`AWS_SECRET_ACCESS_KEY` environment variables to have permission to upload to S3. The rest of the destination
(`prefix/%(z)d/%(x)d/%(y)d.jpg`) is a template describing the layout of the tiles in S3. It's a normal Python
format string: `%(x)d` means substitute the tile's `x` coordinate as a decimal integer.

You can pass the same `s3://` URL to `tc-viewer`. This allows you to visualize your tiles stored in S3 with
your favorite mapping library. For example:

    $ ./tc-viewer s3://bucket/prefix/%(z)d/%(x)d/%(y)d.jpg

Here, `tc-viewer` is acting as a proxy, serving tiles stored in S3 over HTTP, bypassing any caches or access
controls (assuming you have the correct credentials, of course). This allows you to visualize the exact tiles
that you've stored.

## Rendering the World

At [FOSS4G-NA](http://foss4g-na.org/), [MapBox](http://mapbox.com/) presented an excellent strategy for
[rendering the world](http://mapbox.com/blog/rendering-the-world/). TileCloud supports the subdivision
strategy. To run the demo, execute:

    $ python examples/renderingtheworld.py

This will generate tiles from a WMTS tile server and save them in a local MBTiles tiles. When the above
command is complete, you can see the bounding pyramid of the generated tiles:

    $ ./tc-info -t bounding-pyramid -r medford_buildings.mbtiles
    0/0/0:+1/+1
    1/0/0:+1/+1
    2/0/1:+1/+1
    3/1/2:+1/+1
    4/2/5:+1/+1
    5/5/11:+1/+1
    6/10/23:+1/+1
    7/20/47:+1/+1
    8/40/94:+2/+2
    9/80/189:+2/+1
    10/162/378:+1/+2
    11/324/757:+2/+2
    12/649/1514:+3/+3
    13/1299/3028:+4/+5
    14/2598/6057:+7/+8
    15/5196/12114:+13/+15

You can look at these tiles (which show buildings in Medford, OR) with the command:

    ./tc-viewer --root=7/20/47 tiles.openstreetmap_org medford_buildings.mbtiles

## A cheap-and-cheerful tile server

`tc-viewer` can be used as a lightweight tile server, which can be useful for development, debugging and
off-line demos. The TileStores passed as arguments to `tc-viewer` are available at the URL:

    http://localhost:8080/tiles/{index}/tiles/{z}/{x}/{y}

where `{index}` is the index of the TileStore on the command line (starting from 0 for the first tile store),
and `{z}`, `{x}` and `{y}` are the components of the tile coordinate. The second `tiles` in the URL is present
to work around assumptions made by OpenWebGlobe. This layout is directly usable by most mapping libraries, see
the code in `views/*.tpl` for examples. The host and port can be set with the `--host` and `--port` command
line options, respectively.

Note that there is no file extension. `tc-viewer` will automatically set the correct content type and content
encoding headers if it can determine them, and, failing this, most browsers will figure it out for themselves.

For convenience, `tc-viewer` serves everything in the `static` directory under the URL `/static`. This can be
used to serve your favorite mapping library and/or application code directly for testing purposes.

By default, `tc-viewer` will use [Tornado](http://www.tornadoweb.org/) as a web server, if it is available,
otherwise it will fall back to [WSGIRef](http://docs.python.org/library/wsgiref.html). Tornado has reasonably
good performance, and is adequate for local development and off-line demos, especially when used with a
MBTiles TileStore. WSGIRef has very poor performance (it handles only one request at a time) and as such can
be used as a "slow" tile server, ideal for debugging tile loading code or testing how your web application
performs over a slow network connection. `tc-viewer` is particularly slow when used to proxy tiles being
served by a remote server. You can set the server explicitly with the `--server` option.

`tc-viewer` sets the `Access-Control-Allow-Origin` header to `*` for all the tiles it serves, this allows the
tiles to be used as textures for WebGL applications running on different hosts/ports. For more information,
see [Cross-Domain Textures](https://developer.mozilla.org/en/WebGL/Cross-Domain_Textures).

`tc-viewer` is designed as a development tool, and the power that it offers comes at the expense of fragility.
It makes many assumptions - including the benevolence of the user - that make it entirely unsuitable as a
generic tile server. It should only be used in development or demonstration environments.

## Comparing mapping libraries

`tc-viewer` supports most popular web mapping libraries out-of-the box. This can be very useful for quick,
practical comparisons. If your favorite mapping library is missing, please submit an
[issue](https://github.com/camptocamp/tilecloud/issues), or, even better, a [pull
request](https://github.com/camptocamp/tilecloud/pulls).

## Contributing

Please report bugs and feature requests using the [GitHub issue
tracker](https://github.com/camptocamp/tilecloud/issues).

If you'd like to contribute to TileCloud, please install the development requirements:

    $ pip install -r dev-requirements.txt

TileCloud comes with unit tests in the `tilecloud/tests` directory. You can run these with the command:

    $ make test

This is equivalent to:

    $ python setup.py nosetests

For pull requests, it is very much appreciated if your code passes `prospector` without warnings. You can run
prospector on the codebase with the command:

    $ make prospector

## License

Copyright (c) 2012, Tom Payne <twpayne@gmail.com> All rights reserved.
Copyright (c) 2012, Camptocamp All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the
  following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

vim: set filetype=rst spell spelllang=en textwidth=0:



%prep
%autosetup -n tilecloud-1.9.3

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-tilecloud -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 1.9.3-1
- Package Spec generated