-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
820 lines (723 loc) · 34.2 KB
/
index.html
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
<!doctype html>
<html>
<head>
<title>Simple Tiles</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--
+-----------------------------+
|^^^^ / ~|
|^^^ ---------- /|
|^^ Simple / --------- |
| / ~ / ** |
| / / **** |
| ---- ~ / ****** |
| / ~~ -- ******* |
| / / ***** |
| / / |
| / ~~ / Tiles ^^^^ ^|
|- / ^^^ ^^|
| ~~~ / ^^ ^^^|
+-----------------------------+
documentation layout inspired by backbone and underscore, obvs
-->
<style>
/* reset */
div, html, body {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
ul { list-style: none; padding-left: 10px;}
li { margin-bottom: 1em; }
/* text styles */
body {
font-family: "Helvetica Nueue", Helvetica, sans-serif;
font-size: 14px;
line-height: 1.7em;
margin-left: 270px;
padding: 20px;
}
p, li {
width: 600px;
margin: 0px 0px 1em;
}
h1, h2, h3 {
text-rendering: optimizeLegibility;
margin-left: -5px;
}
h4 {
margin: 0px;
margin-top: 30px;
margin-left: -5px;
font-weight: normal;
}
h4 code {
padding: 4px;
background-color: #e6f3ff;
}
code, pre, tt { font-family: Monaco, monospace; font-size: 12px; }
tt { border:1px solid #efefef; padding: 2px;}
dd { margin-left: 1em; }
a { color: black; }
a:hover { text-decoration: none; }
pre {
padding-left: 10px;
font-size: 12px;
border-left: 5px solid #efefef;
}
hr {
border: 0;
border-top: 1px solid #efefef;
height: 1px;
}
/* layout */
#sidebar {
top:0;
left:0;
bottom:0;
position:fixed;
padding: 20px;
width: 230px;
border-right: 1px solid #efefef;
overflow-y: auto;
overflow-x: hidden;
}
#sidebar a { font-weight: bold; }
#sidebar li a {
font-weight: normal;
text-decoration:none;
}
#sidebar li a:hover { text-decoration: underline; }
#sidebar li {
font-size: 12px;
margin-left: 5px;
margin-bottom: 0;
}
#sidebar h4 { margin: 0.7em 0;}
#map {
width: 768px;
height:1%;
overflow:auto;
}
#map img {
margin: 0;
padding: 0;
border: 0;
float: left;
width: 256px;
height: 256px;
}
:target code {
background-color: #d8f7ee;
border: 1px solid #ababab;
}
</style>
</head>
<body>
<div id="sidebar">
<h4><a href="#dependencies">Dependencies</a></h4>
<h4><a href="#installation">Installation</a></h4>
<h4><a href="#compilation">Compilation & Linking</a></h4>
<h4><a href="#overview">Overview</a></h4>
<hr>
<h4><a href="#maps">Maps</a> map.h</h4>
<ul>
<li><a href="#simplet_map_new">simplet_map_new</a></li>
<li><a href="#simplet_map_free">simplet_map_free</a></li>
<li><a href="#simplet_map_set_srs">simplet_map_set_srs</a></li>
<li><a href="#simplet_map_get_srs">simplet_map_get_srs</a></li>
<li><a href="#simplet_map_set_size">simplet_map_set_size</a></li>
<li><a href="#simplet_map_get_width">simplet_map_get_width</a></li>
<li><a href="#simplet_map_get_height">simplet_map_get_height</a></li>
<li><a href="#simplet_map_set_width">simplet_map_set_width</a></li>
<li><a href="#simplet_map_set_height">simplet_map_set_height</a></li>
<li><a href="#simplet_map_set_bounds">simplet_map_set_bounds</a></li>
<li><a href="#simplet_map_set_slippy">simplet_map_set_slippy</a></li>
<li><a href="#simplet_map_set_bgcolor">simplet_map_set_bgcolor</a></li>
<li><a href="#simplet_map_get_bgcolor">simplet_map_get_bgcolor</a></li>
<li><a href="#simplet_map_add_vector_layer">simplet_map_add_vector_layer</a></li>
<li><a href="#simplet_map_add_raster_layer">simplet_map_add_raster_layer</a></li>
<li><a href="#simplet_map_add_layer_directly">simplet_map_add_layer_directly</a></li>
<li><a href="#simplet_map_get_status">simplet_map_get_status</a></li>
<li><a href="#simplet_map_status_to_string">simplet_map_status_to_string</a></li>
<li><a href="#simplet_map_is_valid">simplet_map_is_valid</a></li>
<li><a href="#simplet_map_render_to_png">simplet_map_render_to_png</a></li>
<li><a href="#simplet_map_render_to_stream">simplet_map_render_to_stream</a></li>
<li><a href="#simplet_map_set_buffer">simplet_map_set_buffer</a></li>
<li><a href="#simplet_map_get_buffer">simplet_map_get_buffer</a></li>
</ul>
<hr>
<h4><a href="#bounds">Bounds</a> bounds.h</h4>
<ul>
<li><a href="#simplet_bounds_new">simplet_bounds_new</a></li>
<li><a href="#simplet_bounds_free">simplet_bounds_free</a></li>
<li><a href="#simplet_bounds_extend">simplet_bounds_extend</a></li>
<li><a href="#simplet_bounds_to_wkt">simplet_bounds_to_wkt</a></li>
</ul>
<hr>
<h4><a href="#layers">Layers</a> layer.h</h4>
<ul>
<li><a href="#simplet_layer_get_source">simplet_layer_get_source</a></li>
<li><a href="#simplet_layer_set_source">simplet_layer_set_source</a></li>
</ul>
<hr>
<h4><a href="#vector_layers">Vector Layers</a> vector_layer.h</h4>
<ul>
<li><a href="#simplet_vector_layer_new">simplet_vector_layer_new</a></li>
<li><a href="#simplet_vector_layer_free">simplet_vector_layer_free</a></li>
<li><a href="#simplet_vector_layer_add_query">simplet_vector_layer_add_query</a></li>
<li><a href="#simplet_vector_layer_add_query_directly">simplet_vector_layer_add_query_directly</a></li>
</ul>
<hr>
<h4><a href="#raster_layers">Raster Layers</a> raster_layer.h</h4>
<ul>
<li><a href="#simplet_raster_layer_new">simplet_raster_layer_new</a></li>
<li><a href="#simplet_raster_layer_free">simplet_raster_layer_free</a></li>
</ul>
<hr>
<h4><a href="#queries">Filters</a> query.h</h4>
<ul>
<li><a href="#simplet_query_new">simplet_query_new</a></li>
<li><a href="#simplet_query_free">simplet_query_free</a></li>
<li><a href="#simplet_query_set_query">simplet_query_set_query</a></li>
<li><a href="#simplet_query_get_query">simplet_query_get_query</a></li>
<li><a href="#simplet_query_add_style">simplet_query_add_style</a></li>
<li><a href="#simplet_query_add_style_directly">simplet_query_add_style_directly</a></li>
</ul>
<hr>
<h4><a href="#styles">Styles</a> style.h</h4>
<ul>
<li><a href="#simplet_style_new">simplet_style_new</a></li>
<li><a href="#simplet_style_free">simplet_style_free</a></li>
<li><a href="#simplet_style_set_key">simplet_style_set_key</a></li>
<li><a href="#simplet_style_set_arg">simplet_style_set_arg</a></li>
<li><a href="#simplet_style_get_key">simplet_style_get_key</a></li>
<li><a href="#simplet_style_get_arg">simplet_style_get_arg</a></li>
</ul>
<hr>
<h4><a href="#user_data">User Data</a> user_data.h</h4>
<ul>
<li><a href="#simplet_set_user_data">simplet_##type##_set_user_data</a></li>
<li><a href="#simplet_get_user_data">simplet_##type##_get_user_data</a></li>
<li><a href="#simplet_free_user_data">simplet_##type##_free_user_data</a></li>
</ul>
<hr>
<h4><a href="#demo">Demo</a></h4>
<h4><a href="#license">License</a></h4>
</div>
<img src="docs/simple-tiles-logo.png">
<p><a href="http://github.com/propublica/simple-tiles">Simple Tiles</a>
is an image generation library for spatial data written in C. At it's
core it is a thin wrapper on top of <a href="http://www.gdal.org/ogr">OGR</a>
for spatial data and <a href="http://cairographics.org">Cairo</a>
for image generation.</p>
<p>The library's source is over at <a href="http://github.com/propublica/simple-tiles">github</a>.
Please report issues or ask questions in the
<a href="https://github.com/propublica/simple-tiles/issues">issue tracker</a></p>
<p>There are Ruby bindings over at
<a href="http://github.com/propublica/simpler-tiles">Simpler Tiles</a>.
</p>
<p>Download version 0.6.1:
<a href="https://github.com/propublica/simple-tiles/archive/v0.6.1.zip">ZIP</a>
<a href="https://github.com/propublica/simple-tiles/archive/v0.6.1.tar.gz">tar.gz</a>
</p>
<h2 id="dependencies">Dependencies</h2>
<p>Simple Tiles relies on GDAL and OGR for abstractions over geospatial data. You'll
need at least version 1.9.0 of GDAL to use Simple Tiles. On Ubuntu you can install
the library using the <a href="https://launchpad.net/~ubuntugis/+archive/ppa/">ubuntugis ppa</a>.
On OS X the version from homebrew works well.
</p>
<p>Simple Tiles uses <a href="http://cairographics.org">Cairo (version >= 1.12)</a> and
<a href="http://developer.gnome.org/pango/stable/">Pango (version >= 1.30)</a> for the final
png output, you'll need an installed and working version of both. On Ubuntu
apt-get installs a perfectly fine version of both, and OS X users can use homebrew.
</p>
<h2 id="installation">Installation</h2>
<p>To install Simple Tiles run:</p>
<pre>
$ git clone git@github.com:propublica/simple-tiles.git
$ cd simple-tiles
$ ./configure
$ make && make install
</pre>
<p>You'll probably also want to run:</p>
<pre>
$ make test
</pre>
<p>to ensure the library and its dependencies are playing nice with one another.</p>
<h2 id="compilation">Compilation and Linking</h2>
<p>Once you have a working copy of Simple Tiles, you'll want to use <b>pkg-config</b>
to link to the library. For example, to compile a file with Simple Tiles use:</p>
<pre>
cc `pkg-config --cflags simple-tiles` `gdal-config --cflags` -c -o main.o main.c
cc main.o `pkg-config --libs simple-tiles` `gdal-config --libs` -o main
</pre>
<p>And your program should be linked correctly.</p>
<h2 id="overview">Overview</h2>
<p>Simple Tiles is written in an object oriented fashion with thin data structures.
The hierarchy of <a href="docs/types_h.html">structures</a> consists of:</p>
<ul>
<li>
<tt>simplet_map_t</tt>: Each <tt>simplet_map_t</tt> stores the projection,
bounds, the width and height of the desired image, and a list of <tt>simplet_layer_t</tt>
instances, which are dispatched to <tt>simplet_vector_layer_t</tt> or
<tt>simplet_raster_layer_t</tt> depending on the data type.
</li>
<li>
<tt>simplet_vector_layer_t</tt>: Each <tt>simplet_vector_layer_t</tt> contains an
<a href="http://www.gdal.org/ogr/ogr_formats.html">OGR</a> compatible
datasource string, and stores a list of <tt>simplet_query_t</tt> instances.
Layers define access to spatial storage either from physical files or
databases. Each contains a list of <tt>simplet_query_t</tt> structures.
</li>
<li>
<tt>simple_raster_layer_t</tt>: Each <tt>simple_raster_layer_t</tt> contains a
<a href="http://www.gdal.org/formats_list.html">GDAL</a> compatible raster
datasource string.
</li>
<li>
<tt>simplet_query_t</tt>: A <tt>simplet_query_t</tt> instance stores
<a href="http://www.gdal.org/ogr/ogr_sql.html">ogrsql</a>
to query the data on its parent's <tt>simplet_vector_layer_t</tt> datasource.
Each query contains a list of <tt>simplet_style_t</tt> structures.
</li>
<li>
<tt>simplet_style_t</tt>: A <tt>simplet_style_t</tt> instance stores information
on how to style and display each data row returned from queries.
</li>
</ul>
<p>
For a real-world example on how this all fits together, here is
a demo that draws the map in the Simple Tiles logo:
</p>
<pre>
#include <simple-tiles/simple_tiles.h>
#include <simple-tiles/query.h>
#include <simple-tiles/vector_layer.h>
int
main(){
simplet_map_t *map = simplet_map_new();
simplet_map_set_srs(map, "EPSG:3083");
simplet_map_set_bgcolor(map, "#ffffff");
simplet_map_set_bounds(map, -585080.885134, 6849466.721081, 4161303.603672, 9587780.816356);
simplet_map_set_size(map, 423, 260);
simplet_vector_layer_t *layer = simplet_map_add_vector_layer(map, "PG:dbname=simple_tiles_roads");
simplet_query_t *query = simplet_vector_layer_add_query(layer, "select * from roads");
simplet_query_add_style(query, "stroke", "#11111166");
simplet_query_add_style(query, "line-join", "round");
simplet_query_add_style(query, "weight", "0.1");
simplet_map_render_to_png(map, "./out.png");
simplet_map_free(map);
}
</pre>
<p>
Another example is the repo's <a href="https://github.com/propublica/simple-tiles/blob/master/test/api.c">test/api.c</a>
file.
</p>
<h2 id="maps">Maps</h2>
<p>
The <tt>simplet_map_t</tt> structure is the root of the Simple Tiles heirarchy
and has methods that set and get information on the final output.
</p>
<h4 id="simplet_map_new"><code>simplet_map_t* simplet_map_new()</code></h4>
<p>
Allocates and returns a pointer to a new instance of <tt>simplet_map_t</tt>.
Returns <tt>NULL</tt> or the instance; the new instance should be freed
with <tt>simplet_map_free</tt>.
</p>
<h4 id="simplet_map_free"><code>void simplet_map_free(simplet_map_t *map)</code></h4>
<p>
Deallocates the memory allocated for a particular <tt>simplet_map_t</tt>,
and its child structures. This should be the only deallocation function
you'll need.
</p>
<h4 id="simplet_map_set_srs"><code>simplet_status_t simplet_map_set_srs(simplet_map_t *map, const char *proj)</code></h4>
<p>
Creates and assigns a particular projection to the map you may use any
projection string that <a href="http://www.gdal.org/ogr/classOGRSpatialReference.html#ec3c6a49533fe457ddc763d699ff8796">
<tt>OGRSpatialReference::SetFromUserInput</tt></a> understands. Returns
a <a href="#status"><tt>simplet_status_t</tt></a> object. If you set a
new srs and you have set the map's bounds in a previous projection, they
will be updated for you.
</p>
<h4 id="simplet_map_get_srs"><code>void simplet_map_get_srs(simplet_map_t *map, char **srs)</code></h4>
<p>
Sets <tt>srs</tt> to the <tt>map</tt>'s srs, will allocate space for <tt>srs</tt>
and <tt>srs</tt> should be deallocated with <tt>free</tt>.
</p>
<h4 id="simplet_map_set_size"><code>simplet_status_t simplet_map_set_size(simplet_map_t *map, unsigned int width, unsigned int height)</code></h4>
<p>
Sets the physical size of the output image. For tile generation you'll want to use
<tt>simplet_map_set_slippy</tt> to set this automatically for web mercator.
</p>
<h4 id="simplet_map_get_width"><code>unsigned int simplet_map_get_width(simplet_map_t *map)</code></h4>
<p>
Return the <tt>width</tt> of the map.
</p>
<h4 id="simplet_map_get_height"><code>unsigned int simplet_map_get_height(simplet_map_t *map)</code></h4>
<p>
Return the <tt>height</tt> of the map.
</p>
<h4 id="simplet_map_set_width"><code>simplet_status_t simplet_map_set_width(simplet_map_t *map, unsigned int width)</code></h4>
<p>
Set the <tt>width</tt> of the map.
</p>
<h4 id="simplet_map_set_height"><code>simplet_status_t simplet_map_set_height(simplet_map_t *map, unsigned int height)</code></h4>
<p>
Set the <tt>height</tt> of the map.
</p>
<h4 id="simplet_map_set_bounds"><code>simplet_status_t simplet_map_set_bounds(simplet_map_t *map, double maxx, double maxy, double minx, double miny)</code></h4>
<p>
Sets the boundary of the map in the current projection. Again, <tt>simplet_map_set_slippy</tt>
is an easy way to set this for tiled maps.
</p>
<h4 id="simplet_map_set_slippy"><code>simplet_status_t simplet_map_set_slippy(simplet_map_t *map, unsigned int x, unsigned int y, unsigned int z)</code></h4>
<p>
Takes a series of google map tile coordinates and sets the bounds, projection
width and height of the <tt>simplet_map_t</tt> instance accordingly.
</p>
<h4 id="simplet_map_set_bgcolor"><code>simplet_status_t simplet_map_set_bgcolor(simplet_map_t *map, const char *str)</code></h4>
<p>
Stores a copy of <tt>str</tt> as the map's background color in <tt>#ffffffAA</tt>
format <tt>AA</tt> is the alpha index of the color.
</p>
<h4 id="simplet_map_get_bgcolor"><code>void simplet_map_get_bgcolor(simplet_map_t *map, char **str)</code></h4>
<p>
Stores a copy of the <tt>map</tt>'s background color in <tt>str</tt>. <tt>str</tt>
is then owned by the caller and should be <tt>free</tt>'d.
</p>
<h4 id="simplet_map_add_vector_layer"><code>simplet_vector_layer_t* simplet_map_add_layer(simplet_map_t *map, const char *datastring)</code></h4>
<p>
Adds a vector layer to the map's layer list. <tt>datastring</tt> represents a
resource that is readable by <a href="http://www.gdal.org/ogr/ogr_formats.html">OGR</a>,
and returns a <tt>simplet_vector_layer_t</tt> which is owned by the <tt>map</tt>
and will be freed when the map is. Returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_map_add_raster_layer"><code>simplet_raster_layer_t* simplet_map_add_raster_layer(simplet_map_t *map, const char *datastring)</code></h4>
<p>
Adds a raster layer to the map's layer list. <tt>datastring</tt> represents a
resource that is readable by <a href="http://www.gdal.org/formats_list.html">GDAL</a>,
and returns a <tt>simplet_raster_layer_t</tt> which is owned by the <tt>map</tt>
and will be freed when the map is. Returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_map_add_layer_directly"><code>simplet_layer_t* simplet_map_add_layer_directly(simplet_map_t *map, simplet_layer_t *layer)</code></h4>
<p>
Add a layer object created by <tt>simplet_layer_new</tt> directly the
<tt>map</tt>'s list of layers.
</p>
<h4 id="simplet_map_get_status"><code>simplet_status_t simplet_map_get_status(simplet_map_t *map)</code></h4>
<p>
Returns the current status of the <tt>map</tt> object. Status codes are:
<pre>
typedef enum {
SIMPLET_ERR = 0, // Generic error
SIMPLET_OOM, // Out of memory for allocation
SIMPLET_CAIRO_ERR, // Cairo error
SIMPLET_OGR_ERR, // OGR Error
SIMPLET_GDAL_ERR, // GDAL Error
SIMPLET_OK // OK
} simplet_status_t;
</pre>
</p>
<h4 id="simplet_map_status_to_string"><code>const char* simplet_map_status_to_string(simplet_map_t *map)</code></h4>
<p>
Returns a pointer to an internal english version of the <tt>map</tt>'s
status. Useful for error reporting.
</p>
<h4 id="simplet_map_is_valid"><code>simplet_status_t simplet_map_is_valid(simplet_map_t *map)</code></h4>
<p>
Returns a <tt>simplet_status_t</tt> of the current state of the <tt>map</tt>
that indicates if the requirements for successfully rendering the map are
met. In other words, if a <tt>map</tt> has bounds, width and height, projection
and at least one <tt>layer</tt>.
</p>
<h4 id="simplet_map_render_to_png"><code>void simplet_map_render_to_png(simplet_map_t *map, const char *path)</code></h4>
<p>
Renders a png to the <tt>path</tt> based on the specification defined in
<tt>map</tt>. Layers are painted on the image in order of insertion, that
is, the oldest layers are drawn first.
</p>
<h4 id="simplet_map_render_to_stream"><code>void simplet_map_render_to_stream(simplet_map_t *map, void *stream, cairo_status_t (*cb)(void *closure, const unsigned char *data, unsigned int length))</code></h4>
<p>
Renders the <tt>map</tt> to a png stream by repeatedly calling the <tt>closure</tt>.
The <tt>closure</tt> is a <a href="http://cairographics.org/manual/cairo-PNG-Support.html#cairo-write-func-t">
<tt>cairo_write_func_t</tt></a> and must conform to that API.
</p>
<h4 id="simplet_map_set_buffer"><code>void simplet_map_set_buffer(simplet_map_t *map, double buffer)</code></h4>
<p>
Sets the buffer on the <tt>map</tt>. Buffers are a kind of overprinting
where you can include more shapes in rendering in order to set type correctly.
Michal Migurski has a good <a href="http://mike.teczno.com/notes/mapnik.html">post</a>
on why this is useful.
</p>
<h4 id="simplet_map_get_buffer"><code>double simplet_map_get_buffer(simplet_map_t *map)</code></h4>
<p>
Returns the <tt>map</tt>'s buffer.
</p>
<h2 id="bounds">Bounds</h2>
<p>
Bounds store the boundary of map data. Mostly the <tt>simplet_map_t</tt>
functions handle the bounds, but <tt>simplet_bounds_to_wkt</tt> is useful
to limit queries in postgresql.
</p>
<h4 id="simplet_bounds_new"><code>simplet_bounds_t* simplet_bounds_new()</code></h4>
<p>
Create a new <tt>simplet_bounds_t</tt>, returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_bounds_free"><code>void simplet_bounds_free(simplet_bounds_t *bounds)</code></h4>
<p>
Free the <tt>bounds</tt>.
</p>
<h4 id="simplet_bounds_extend"><code>void simplet_bounds_extend(simplet_bounds_t *bounds, double x, double y)</code></h4>
<p>
Extend the <tt>bounds</tt> to include the point <tt>x</tt>, <tt>y</tt>.
</p>
<h4 id="simplet_bounds_to_wkt"><code>simplet_status_t simplet_bounds_to_wkt(simplet_bounds_t *bounds, char **wkt)</code></h4>
<p>
Store a Well Known Text representation of the bounds in the string pointing to <tt>wkt</tt>.
Returns <tt>SIMPLET_ERROR</tt> on failure.
</p>
<h2 id="layers">Layers</h2>
<p>
Each layer maps to a OGR or GDAL datasource. Vector layers contain a list of queries to
run against that source.
</p>
<h4 id="simplet_layer_set_source"><code>void simplet_layer_set_source(simplet_layer_t *layer, char *source)</code></h4>
<p>
Set the <tt>layer</tt>'s source attribute. <tt>source</tt> needs to be a
string pointing to an OGR readable <a href="http://www.gdal.org/ogr/ogr_formats.html">resource</a>.
</p>
<h4 id="simplet_layer_get_source"><code>void simplet_layer_get_source(simplet_layer_t *layer, char **source)</code></h4>
<p>
Stores a copy of the <tt>layer</tt>'s source attribute in <tt>source</tt>, and allocates
space for the copy. <tt>source</tt> should be freed when no longer needed.
</p>
<h2 id="vector_layers">Vector Layers</h2>
<h4 id="simplet_vector_layer_new"><code>simplet_vector_layer_t* simplet_vector_layer_new(const char *datastring)</code></h4>
<p>
Create a new <tt>simplet_vector_layer_t</tt>, returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_vector_layer_free"><code>void simplet_vector_layer_free(simplet_vector_layer_t *layer)</code></h4>
<p>
Deallocate the <tt>simplet_vector_layer_t</tt>.
</p>
<h4 id="simplet_vector_layer_add_query"><code>simplet_query_t* simplet_vector_layer_add_query(simplet_vector_layer_t *layer, const char *ogrsql)</code></h4>
<p>
Creates and adds a query to the <tt>layer</tt>'s query list. The returned
query is owned by the <tt>layer</tt> and should not be freed with <a href="simplet_query_free">simplet_query_free</a>.
<tt>ogrsql</tt> should be a query to query the <tt>layer</tt>'s
data source using <a href="http://www.gdal.org/ogr/ogr_sql.html">OGR SQL</a>.
Returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_vector_layer_add_query_directly"><code>simplet_query_t* simplet_vector_layer_add_query_directly(simplet_vector_layer_t *layer, simplet_query_t *query)</code></h4>
<p>
Adds a previously initialized <tt>query</tt> to the <tt>layer</tt>'s query list.
The returned query is then owned by the <tt>layer</tt> and should not
be freed with <a href="simplet_query_free">simplet_query_free</a>.
</p>
<h2 id="raster_layers">Raster Layers</h2>
<h4 id="simplet_raster_layer_new"><code>simplet_raster_layer_t* simplet_raster_layer_new(const char *datastring)</code></h4>
<p>
Create a new <tt>simplet_raster_layer_t</tt>, returns <tt>NULL</tt> on failure.
</p>
<h4 id="simplet_raster_layer_free"><code>void simplet_raster_layer_free(simplet_raster_layer_t *layer)</code></h4>
<p>
Deallocate the <tt>simplet_raster_layer_t</tt>.
</p>
<h4 id="simplet_raster_layer_set_resample"><code>void simplet_raster_layer_set_resample(simplet_raster_layer_t *layer, simplet_kern_t resample)</code></h4>
<p>
Sets the resampling algorithm the algorithm can be one of the following:
<pre>
typedef enum {
SIMPLET_NEAREST = 0, // nearest neighbor resampling, very fast but low quality
SIMPLET_BILINEAR, // bilinear resampling
SIMPLET_LANCZOS // lanczos highest quality, slowest resampling method
} simplet_kern_t;
</pre>
</p>
<h4 id="simplet_raster_layer_get_resample"><code>simplet_kern_t simplet_raster_layer_get_resample(simplet_raster_layer_t *layer)</code></h4>
<p>
Returns the resampling algorithm used for this layer.
</p>
<h2 id="queries">Filters</h2>
<p>
Each <tt>simplet_query_t</tt> contains <a href="http://www.gdal.org/ogr/ogr_sql.html">OGR SQL</a>
to query the data in its parent layer. Like layers they are drawn in
order of insertion on the map canvas.
</p>
<h4 id="simplet_query_new"><code>simplet_query_t* simplet_query_new(const char *sqlquery)</code></h4>
<p>
Creates and returns a new <tt>simplet_query_t</tt>. Returns <tt>NULL</tt>
on failure. <tt>sqlquery</tt> should be <a href="http://www.gdal.org/ogr/ogr_sql.html">OGR SQL</a>.
</p>
<h4 id="simplet_query_free"><code>void simplet_query_free(simplet_query_t *query)</code></h4>
<p>
Frees the passed in <tt>query</tt>. If the <tt>query</tt> has been added
to a <tt>layer</tt> you shouldn't use this function.
</p>
<h4 id="simplet_query_set"><code>simplet_status_t simplet_query_set(simplet_query_t *query, const char *sql)</code></h4>
<p>
Sets the sql on <tt>query</tt>. <tt>sql</tt> should be
<a href="http://www.gdal.org/ogr/ogr_sql.html">OGR SQL</a>.
</p>
<h4 id="simplet_query_get"><code>simplet_status_t simplet_query_get(simplet_query_t *query, char **sql)</code></h4>
<p>
Stores a copy of the <tt>query</tt>'s sql attribute in <tt>sql</tt>, and allocates
space for the copy. <tt>sql</tt> should be freed when no longer needed.
</p>
<h4 id="simplet_query_add_style"><code>simplet_style_t* simplet_query_add_style(simplet_query_t *query, const char *key, const char *arg)</code></h4>
<p>
Creates and returns a new <tt>simplet_style_t</tt>. Returns <tt>NULL</tt>
on failure. <a href="#styles">key</a> should be a style name, and
<a href="#styles">value</a> should be a corresponding value.
</p>
<h2 id="styles">Styles</h2>
<p>
Styles are where you'll define the visual appearance of the data emitted
by the <tt>simplet_query_t</tt>. They mimic CSS in that they operate on
individual data elements in the spatial source. All colors are in 8 digit
hex format with the last 2 digits defining the Alpha value of the color
(e.g. <tt>#fffffaa</tt>). These are the styles, and there are planned additions:
<dl>
<dt><tt>fill</tt></dt>
<dd>The fill color for each shape.</dd>
<dt><tt>stroke</tt></dt>
<dd>The stroke color for each line.</dd>
<dt><tt>weight</tt></dt>
<dd>The width of each line in pixels.</dd>
<dt><tt>line-cap</tt></dt>
<dd>How lines are ended, one of: "butt", "round", "square"</dd>
<dt><tt>line-join</tt></dt>
<dd>How lines are joined together, one of: "miter", "round", "bevel"</dd>
<dt><tt>text-field</tt></dt>
<dd>The field to grab labels from.</dd>
<dt><tt>text-stroke-color</tt></dt>
<dd>Color for the outline of the text labels.</dd>
<dt><tt>text-stroke-width</tt></dt>
<dd>The size of the outline fo the text labels.</dd>
<dt><tt>font</tt></dt>
<dd>
A font description that <a href="http://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-from-string">pango</a>
can read to set labels in (i.e. "Helvetica 12px"). You can use <tt>fc-list</tt> on your system to browse the available font families.
</dd>
<dt><tt>letter-spacing</tt></dt>
<dd>How far apart to space the letters in labels.</dd>
<dt><tt>radius</tt></dt>
<dd>For point rendering only, the radius in pixels of the circle.</dd>
</dl>
</p>
<h4 id="simplet_style_new"><code>simplet_style_t* simplet_style_new(const char *key, const char *arg)</code></h4>
<p>
Returns a new <tt>simplet_style_t</tt> or <tt>NULL</tt> on failure. <tt>key</tt>
and <tt>arg</tt> define the style according to the list of <a href="#styles">styles</a>.
</p>
<h4 id="simplet_style_free"><code>void simplet_style_free(simplet_style_t* style)</code></h4>
<p>
Frees the memory associated with the <tt>style</tt>.
</p>
<h4 id="simplet_style_set_key"><code>void simplet_style_set_key(simplet_style_t *style, char *key)</code></h4>
<p>
Makes a copy of <tt>key</tt> to store in the <tt>style</tt>.
</p>
<h4 id="simplet_style_set_arg"><code>void simplet_style_set_arg(simplet_style_t *style, char *arg)</code></h4>
<p>
Makes a copy of <tt>arg</tt> to store in the <tt>style</tt>.
</p>
<h4 id="simplet_style_get_key"><code>void simplet_style_get_key(simplet_style_t* style, char **key)</code></h4>
<p>
Allocates and stores a copy of the <tt>style</tt>'s key in <tt>key</tt>.
<tt>key</tt> should be freed when no longer needed.
</p>
<h4 id="simplet_style_get_arg"><code>void simplet_style_get_arg(simplet_style_t* style, char **arg)</code></h4>
<p>
Allocates and stores a copy of the <tt>style</tt>'s arg in <tt>arg</tt>.
<tt>arg</tt> should be freed when no longer needed.
</p>
<h2 id="user_data">User Data Interface</h2>
<p>
<tt>simplet_map_t</tt>, <tt>simplet_layer_t</tt>, <tt>simplet_query_t</tt> and
<tt>simplet_style_t</tt> each implement an interface for storing user data.
This is useful for storing references in language bindings.
</p>
<h4 id="simplet_set_user_data"><code>void simplet_##type##_set_user_data(simplet_##type##_t *obj, void *data)</code></h4>
<p>
Sets the user data on <tt>obj</tt>.
</p>
<h4 id="simplet_get_user_data"><code>void * simplet_##type##_get_user_data(simplet_##type##_t *obj)</code></h4>
<p>
Returns the user data pointer associated with <tt>obj</tt>.
</p>
<h4 id="simplet_free_user_data"><code>void simplet_##type##_free_user_data(simplet_##type##_t *obj, simplet_user_data_free free)</code></h4>
<p>
Accepts a function pointer <tt>free</tt>, type:
<tt>void (*simplet_user_data_free)(void *val)</tt>, that will free the
user data stored in the object, and frees the user data.
</p>
<h2 id="demo">Demo</h2>
<p>
Here is a small demo of the area surrounding New Orleans built with
<a href="http://www.census.gov/geo/www/tiger/">Tiger/Line</a> data from
the U.S. Census.
</p>
<div id="map">
<img src="http://tiles-a.propublica.org/redistricting-maps/tiles/LA/12/1023/1689/12.png">
<img src="http://tiles-b.propublica.org/redistricting-maps/tiles/LA/12/1024/1689/12.png">
<img src="http://tiles-c.propublica.org/redistricting-maps/tiles/LA/12/1025/1689/12.png">
<img src="http://tiles-d.propublica.org/redistricting-maps/tiles/LA/12/1023/1690/12.png">
<img src="http://tiles-a.propublica.org/redistricting-maps/tiles/LA/12/1024/1690/12.png">
<img src="http://tiles-b.propublica.org/redistricting-maps/tiles/LA/12/1025/1690/12.png">
</div>
<h2 id="changelog">Change Log</h2>
<dl>
<dd><b>0.6.1</b></dd>
<dt>
Tweaks for GDAL 2.0.
</dt>
<dd><b>0.6.0</b></dd>
<dt>
Added raster resampling because <a href="https://github.com/briantjacobs">Brian Jacobs</a> asked for it.
</dt>
<dd><b>0.5.0</b></dd>
<dt>
Added raster support thanks to <a href="https://github.com/ashaw">Al Shaw</a>.
</dt>
<dd><b>0.4.1</b></dd>
<dt>
Fix debug flag.
</dt>
<dd><b>0.4.0</b></dd>
<dt>
New build system -- waf -- and now using <tt>OGR_ENABLE_PARTIAL_REPROJECTION</tt>
so that shapes with unprojectable coordinates render correctly.
</dt>
<dd><b>0.3.2</b></dd>
<dt>Fix for <tt>config.h</tt></dt>
<dd><b>0.3.1</b></dd>
<dt>Define <tt>GNU_SOURCE</tt></dt>
<dd><b>0.3.0</b></dd>
<dt>Switch the build system to autotools and fix a big pango bug (thanks <a href="https://github.com/adamtrilling">Adam Trilling</a>.</dt>
</dl>
<h2 id="license">License</h2>
<pre>
Copyright (c) 2017, ProPublica
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
</pre>
<p><em>Simple Tiles is a project of ProPublica.</em></p>
</body>
</html>