simpler-tiles 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b61f77954101ab8a753016497e1add4289eda62
4
- data.tar.gz: de284f7de5e1a8508003946f42d98e6df6a2ca8f
3
+ metadata.gz: bd21718ad62a0b2238de78ce0096cd783d25e1b3
4
+ data.tar.gz: a096000461cd55af2e4af2ff5485a10e5358ffa7
5
5
  SHA512:
6
- metadata.gz: e1cd8686e83a43ea74d0fd2de2167b99f646296fb63d15a932a389cff36c13c02fbfaa7cec581ed9747ebdd2f8620a0032fc27a9bcfef285e1ac02d61c2a52b8
7
- data.tar.gz: 7dcdfec476b4ffbf3459c685f6b8afd9951491b7a13362268fe8abe1eed7eb935982c2582876dfd8e8b298b93683e287dea313a11a8e94e3a0dd753faf4e7abb
6
+ metadata.gz: 4071fcc119529339f57fb9d91b902f1f5794cde59de0aad1a7469064d6a4ace72bcc2c15248291e8e044dcbb1cf42d0690f0a7b93edda8e298efcf72fefdeaa4
7
+ data.tar.gz: e89e44f566b8a41069fff6828445b4246fb3db9eaf47852ea3511feb5d6bfb30b15da8bdd9c15488e5ef009578a20de01b494bc3b5be92b26d61cf1d268c15a1
data/.gitignore CHANGED
@@ -12,6 +12,7 @@ Gemfile
12
12
  .document
13
13
  Gemfile.lock
14
14
  *.orig
15
+ *.gem
15
16
  test/*.png
16
17
  mkmf.log
17
18
  ext/simpler_tiles/Makefile
data/Rakefile CHANGED
@@ -29,7 +29,6 @@ task :publish do |t|
29
29
  `git checkout master`
30
30
  end
31
31
 
32
-
33
32
  require 'rake/testtask'
34
33
  Rake::TestTask.new(:test) do |test|
35
34
  test.libs << 'lib' << 'test'
@@ -38,17 +37,15 @@ Rake::TestTask.new(:test) do |test|
38
37
  end
39
38
 
40
39
  task :default => :test
41
-
40
+ # e.g. DEV_CONFIG='--with-simple-tiles-include=/tmp/simple-tiles/usr/local/include/ --with-simple-tiles-lib=/tmp/simple-tiles/usr/local/lib/' bundle exec rake test
42
41
  require 'rake/extensiontask'
43
42
  Rake::ExtensionTask.new('simpler_tiles') do |ext|
43
+ if ENV['DEV_CONFIG']
44
+ ext.config_options << ENV['DEV_CONFIG']
45
+ end
44
46
  ext.lib_dir = File.join('lib', 'simpler_tiles')
45
47
  end
46
48
 
47
- DEPEND = "ext/simpler_tiles/depend"
48
- file DEPEND => FileList["ext/simpler_tiles/*.c"] do |t|
49
- `cd ext/simpler_tiles/; gcc -MM *.c > depend`
50
- end
51
-
52
49
  DATA = "data/tl_2010_us_state10.shp"
53
50
  file DATA do |t|
54
51
  if !File.exists? t.name
@@ -62,10 +59,5 @@ file DATA do |t|
62
59
  end
63
60
  end
64
61
 
65
- Rake::Task[:compile].prerequisites.unshift DEPEND
66
62
  Rake::Task[:test].prerequisites.unshift DATA
67
- Rake::Task[:test].prerequisites.unshift :compile
68
-
69
-
70
-
71
-
63
+ Rake::Task[:test].prerequisites.unshift :compile
@@ -70,7 +70,6 @@ reproject(VALUE self, VALUE from, VALUE to) {
70
70
  static VALUE
71
71
  alloc_bounds(VALUE self){
72
72
  simplet_bounds_t *bounds;
73
- VALUE args[4];
74
73
  if(!(bounds = simplet_bounds_new()))
75
74
  rb_raise(rb_eRuntimeError, "Error in creating bounds.");
76
75
 
@@ -6,8 +6,8 @@ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
6
6
  LIBDIR = RbConfig::CONFIG['libdir']
7
7
  INCLUDEDIR = RbConfig::CONFIG['includedir']
8
8
 
9
- $CFLAGS << " #{ENV["CFLAGS"]}" << `PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH pkg-config --cflags simple-tiles pangocairo`.chomp << `gdal-config --cflags`.chomp
10
- $LIBS << " #{ENV["LIBS"]}" << `PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH pkg-config --libs simple-tiles pangocairo`.chomp << `gdal-config --libs`
9
+ $CFLAGS << " #{ENV["CFLAGS"]}" << `pkg-config --cflags simple-tiles`.chomp << `gdal-config --cflags`.chomp
10
+ $LIBS << " #{ENV["LIBS"]}" << `pkg-config --libs simple-tiles`.chomp << `gdal-config --libs`
11
11
 
12
12
  HEADER_DIRS = [
13
13
  '/usr/local/include',
@@ -1,10 +1,7 @@
1
1
  #include "layer.h"
2
2
  #include <simple-tiles/layer.h>
3
- #include <simple-tiles/query.h>
4
3
  #include <simple-tiles/list.h>
5
4
 
6
- VALUE cSimplerTilesLayer;
7
-
8
5
  static simplet_layer_t *
9
6
  get_layer(VALUE self){
10
7
  simplet_layer_t *layer;
@@ -12,27 +9,13 @@ get_layer(VALUE self){
12
9
  return layer;
13
10
  }
14
11
 
15
- static void
16
- mark_layer(void *layer){
17
- simplet_layer_t *lyr = layer;
18
- VALUE ref = (VALUE)simplet_layer_get_user_data(lyr);
19
- if(ref) rb_gc_mark(ref);
20
- }
21
-
22
- static void
23
- layer_free(void *layer){
24
- simplet_layer_t *lyr = layer;
25
- simplet_layer_free(lyr);
26
- }
27
-
28
-
29
12
  /*
30
13
  Set the source attribute for the Layer.
31
14
 
32
15
  @return (String)
33
16
  @param (String)
34
17
  */
35
- static VALUE
18
+ VALUE
36
19
  set_source(VALUE self, VALUE source){
37
20
  Check_Type(source, T_STRING);
38
21
  simplet_layer_t *layer = get_layer(self);
@@ -45,47 +28,10 @@ Get a copy of the Layer's source.
45
28
 
46
29
  @return (String)
47
30
  */
48
- static VALUE
31
+ VALUE
49
32
  get_source(VALUE self) {
50
33
  simplet_layer_t *layer = get_layer(self);
51
34
  char *source;
52
35
  simplet_layer_get_source(layer, &source);
53
36
  return rb_str_new2(source);
54
- }
55
-
56
- /*
57
- Add a query object to this Layer's list of queries.
58
-
59
- @param (String)
60
- @return (Query)
61
- */
62
- static VALUE
63
- add_query(VALUE self, VALUE query){
64
- simplet_layer_t *layer = get_layer(self);
65
- simplet_query_t *qry;
66
- Data_Get_Struct(query, simplet_query_t, qry);
67
- simplet_layer_add_query_directly(layer, qry);
68
- VALUE circ_ref = self;
69
- simplet_query_set_user_data(qry, (void *)circ_ref);
70
- simplet_retain((simplet_retainable_t*) qry);
71
- return query;
72
- }
73
-
74
- VALUE
75
- layer_alloc(VALUE klass){
76
- simplet_layer_t *layer;
77
- if(!(layer = simplet_layer_new("")))
78
- rb_fatal("Could not allocate space for a new SimplerTiles::Layer in memory.");
79
-
80
- return Data_Wrap_Struct(klass, mark_layer, layer_free, layer);
81
- }
82
-
83
- void init_layer(){
84
- VALUE rlayer = rb_define_class_under(mSimplerTiles, "Layer", rb_cObject);
85
- rb_define_alloc_func(rlayer, layer_alloc);
86
- rb_define_method(rlayer, "source=", set_source, 1);
87
- rb_define_method(rlayer, "source", get_source, 0);
88
- rb_define_private_method(rlayer, "add_query", add_query, 1);
89
-
90
- cSimplerTilesLayer = rlayer;
91
- }
37
+ }
@@ -7,10 +7,14 @@
7
7
  extern "C" {
8
8
  #endif
9
9
 
10
- void init_layer();
11
- extern VALUE cSimplerTilesLayer;
10
+ VALUE
11
+ set_source(VALUE self, VALUE source);
12
+
13
+ VALUE
14
+ get_source(VALUE self);
15
+
12
16
  #ifdef __cplusplus
13
17
  }
14
18
  #endif
15
19
 
16
- #endif
20
+ #endif
@@ -1,7 +1,9 @@
1
1
  #include "map.h"
2
- #include "util.h"
2
+ #include <simple-tiles/util.h>
3
3
  #include <simple-tiles/map.h>
4
- #include <simple-tiles/layer.h>
4
+ #include <simple-tiles/memory.h>
5
+ #include <simple-tiles/vector_layer.h>
6
+ #include <simple-tiles/raster_layer.h>
5
7
  #include <simple-tiles/bounds.h>
6
8
  #include <simple-tiles/list.h>
7
9
 
@@ -211,23 +213,42 @@ set_height(VALUE self, VALUE height){
211
213
 
212
214
 
213
215
  /*
214
- Create and return a {Layer} based on the passed in string.
216
+ Create and return a {VectorLayer} based on the passed in string.
215
217
 
216
218
  @param (String)
217
219
  @return (Layer)
218
220
  */
219
221
  static VALUE
220
- add_layer(VALUE self, VALUE layer){
222
+ add_vector_layer(VALUE self, VALUE layer){
221
223
  simplet_map_t *map = get_map(self);
222
- simplet_layer_t *lyr;
223
- Data_Get_Struct(layer, simplet_layer_t, lyr);
224
- simplet_map_add_layer_directly(map, lyr);
224
+ simplet_vector_layer_t *lyr;
225
+ Data_Get_Struct(layer, simplet_vector_layer_t, lyr);
226
+ simplet_map_add_layer_directly(map, (simplet_layer_t *) lyr);
225
227
  VALUE circ_ref = self;
226
- simplet_layer_set_user_data(lyr, (void *)circ_ref);
228
+ simplet_vector_layer_set_user_data(lyr, (void *)circ_ref);
227
229
  simplet_retain((simplet_retainable_t*) lyr);
228
230
  return layer;
229
231
  }
230
232
 
233
+ /*
234
+ Create and return a {RasterLayer} based on the passed in string.
235
+
236
+ @param (String)
237
+ @return (Layer)
238
+ */
239
+ static VALUE
240
+ add_raster_layer(VALUE self, VALUE layer){
241
+ simplet_map_t *map = get_map(self);
242
+ simplet_raster_layer_t *lyr;
243
+ Data_Get_Struct(layer, simplet_raster_layer_t, lyr);
244
+ simplet_map_add_layer_directly(map, (simplet_layer_t *) lyr);
245
+ VALUE circ_ref = self;
246
+ simplet_raster_layer_set_user_data(lyr, (void *)circ_ref);
247
+ simplet_retain((simplet_retainable_t*) lyr);
248
+ return layer;
249
+ }
250
+
251
+
231
252
  /*
232
253
  Test to see if the Map has fulfilled the requirements for rendering
233
254
 
@@ -333,7 +354,8 @@ init_map(){
333
354
  rb_define_method(rmap, "slippy", slippy, 3);
334
355
  rb_define_method(rmap, "valid?", is_valid, 0);
335
356
  rb_define_private_method(rmap, "to_png_stream", to_png_stream, 1);
336
- rb_define_private_method(rmap, "add_layer", add_layer, 1);
357
+ rb_define_private_method(rmap, "add_vector_layer", add_vector_layer, 1);
358
+ rb_define_private_method(rmap, "add_raster_layer", add_raster_layer, 1);
337
359
 
338
360
  cSimplerTilesMap = rmap;
339
361
  }
@@ -1,6 +1,7 @@
1
1
  #include "query.h"
2
2
  #include <simple-tiles/query.h>
3
3
  #include <simple-tiles/style.h>
4
+ #include <simple-tiles/memory.h>
4
5
 
5
6
  VALUE cSimplerTilesQuery;
6
7
 
@@ -0,0 +1,39 @@
1
+ #include "raster_layer.h"
2
+ #include "layer.h"
3
+ #include <simple-tiles/layer.h>
4
+ #include <simple-tiles/raster_layer.h>
5
+ #include <simple-tiles/list.h>
6
+
7
+ VALUE cSimplerTilesRasterLayer;
8
+
9
+ static void
10
+ mark_layer(void *layer){
11
+ simplet_raster_layer_t *lyr = layer;
12
+ VALUE ref = (VALUE)simplet_raster_layer_get_user_data(lyr);
13
+ if(ref) rb_gc_mark(ref);
14
+ }
15
+
16
+ static void
17
+ layer_free(void *layer){
18
+ simplet_raster_layer_t *lyr = layer;
19
+ simplet_raster_layer_free(lyr);
20
+ }
21
+
22
+ VALUE
23
+ raster_layer_alloc(VALUE klass){
24
+ simplet_raster_layer_t *layer;
25
+ if(!(layer = simplet_raster_layer_new("")))
26
+ rb_fatal("Could not allocate space for a new SimplerTiles::Layer in memory.");
27
+
28
+ return Data_Wrap_Struct(klass, mark_layer, layer_free, layer);
29
+ }
30
+
31
+ void init_raster_layer(){
32
+ VALUE rRasterLayer = rb_define_class_under(mSimplerTiles, "RasterLayer", rb_cObject);
33
+ rb_define_alloc_func(rRasterLayer, raster_layer_alloc);
34
+
35
+ rb_define_method(rRasterLayer, "source=", set_source, 1);
36
+ rb_define_method(rRasterLayer, "source", get_source, 0);
37
+
38
+ cSimplerTilesRasterLayer = rRasterLayer;
39
+ }
@@ -0,0 +1,17 @@
1
+ #ifndef _SIMPLER_RASTER_LAYER_H
2
+ #define _SIMPLER_RASTER_LAYER_H
3
+
4
+ #include "simpler_tiles.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ void init_raster_layer();
11
+ extern VALUE cSimplerTilesRasterLayer;
12
+
13
+ #ifdef __cplusplus
14
+ }
15
+ #endif
16
+
17
+ #endif
@@ -7,7 +7,8 @@ Init_simpler_tiles(){
7
7
  mSimplerTiles = rb_define_module("SimplerTiles");
8
8
  init_map();
9
9
  init_bounds();
10
- init_layer();
10
+ init_vector_layer();
11
+ init_raster_layer();
11
12
  init_query();
12
13
  init_style();
13
14
  }
@@ -2,11 +2,14 @@
2
2
  #define _SIMPLER_TILES_H
3
3
 
4
4
  #include <simple-tiles/simple_tiles.h>
5
+ #undef STRNCASECMP
6
+ #undef STRCASECMP
5
7
  #include <ruby.h>
6
8
 
7
9
  #include "map.h"
8
10
  #include "bounds.h"
9
- #include "layer.h"
11
+ #include "vector_layer.h"
12
+ #include "raster_layer.h"
10
13
  #include "query.h"
11
14
  #include "style.h"
12
15
 
@@ -1,5 +1,5 @@
1
1
  #include "style.h"
2
- #include "util.h"
2
+ #include <simple-tiles/util.h>
3
3
  #include <simple-tiles/style.h>
4
4
 
5
5
  VALUE cSimplerTilesStyle;
@@ -0,0 +1,67 @@
1
+ #include "vector_layer.h"
2
+ #include "layer.h"
3
+ #include <simple-tiles/layer.h>
4
+ #include <simple-tiles/vector_layer.h>
5
+ #include <simple-tiles/query.h>
6
+ #include <simple-tiles/list.h>
7
+ #include <simple-tiles/memory.h>
8
+
9
+ VALUE cSimplerTilesVectorLayer;
10
+
11
+ static simplet_vector_layer_t *
12
+ get_layer(VALUE self){
13
+ simplet_vector_layer_t *layer;
14
+ Data_Get_Struct(self, simplet_vector_layer_t, layer);
15
+ return layer;
16
+ }
17
+
18
+
19
+ static void
20
+ mark_layer(void *layer){
21
+ simplet_vector_layer_t *lyr = layer;
22
+ VALUE ref = (VALUE)simplet_vector_layer_get_user_data(lyr);
23
+ if(ref) rb_gc_mark(ref);
24
+ }
25
+
26
+ static void
27
+ layer_free(void *layer){
28
+ simplet_vector_layer_t *lyr = layer;
29
+ simplet_vector_layer_free(lyr);
30
+ }
31
+
32
+ /*
33
+ Add a query object to this Layer's list of queries.
34
+
35
+ @param (String)
36
+ @return (Query)
37
+ */
38
+ static VALUE
39
+ add_query(VALUE self, VALUE query){
40
+ simplet_vector_layer_t *layer = get_layer(self);
41
+ simplet_query_t *qry;
42
+ Data_Get_Struct(query, simplet_query_t, qry);
43
+ simplet_vector_layer_add_query_directly(layer, qry);
44
+ VALUE circ_ref = self;
45
+ simplet_query_set_user_data(qry, (void *)circ_ref);
46
+ simplet_retain((simplet_retainable_t*) qry);
47
+ return query;
48
+ }
49
+
50
+ VALUE
51
+ vector_layer_alloc(VALUE klass){
52
+ simplet_vector_layer_t *layer;
53
+ if(!(layer = simplet_vector_layer_new("")))
54
+ rb_fatal("Could not allocate space for a new SimplerTiles::Layer in memory.");
55
+
56
+ return Data_Wrap_Struct(klass, mark_layer, layer_free, layer);
57
+ }
58
+
59
+ void init_vector_layer(){
60
+ VALUE rVectorLayer = rb_define_class_under(mSimplerTiles, "VectorLayer", rb_cObject);
61
+ rb_define_alloc_func(rVectorLayer, vector_layer_alloc);
62
+ rb_define_method(rVectorLayer, "source=", set_source, 1);
63
+ rb_define_method(rVectorLayer, "source", get_source, 0);
64
+ rb_define_private_method(rVectorLayer, "add_query", add_query, 1);
65
+
66
+ cSimplerTilesVectorLayer = rVectorLayer;
67
+ }
@@ -0,0 +1,17 @@
1
+ #ifndef _SIMPLER_VECTOR_LAYER_H
2
+ #define _SIMPLER_VECTOR_LAYER_H
3
+
4
+ #include "simpler_tiles.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ void init_vector_layer();
11
+ extern VALUE cSimplerTilesVectorLayer;
12
+
13
+ #ifdef __cplusplus
14
+ }
15
+ #endif
16
+
17
+ #endif
data/index.erb CHANGED
@@ -169,7 +169,8 @@
169
169
  GIS image generation library. It allows you to generate PNG based map
170
170
  images without having to dip into straight C and easily connects with
171
171
  ActiveRecord. It can display any vector data that
172
- <a href="http://www.gdal.org/ogr/ogr_formats.html">OGR</a> can read.
172
+ <a href="http://www.gdal.org/ogr/ogr_formats.html">OGR</a> can read and any
173
+ raster data that <a href="http://www.gdal.org/formats_list.html">GDAL</a> can read..
173
174
  </p>
174
175
 
175
176
  <p>
@@ -216,10 +217,16 @@ $ gem install simpler-tiles
216
217
  C structure and specifies the limit of the map in spatial coordinates.
217
218
  </li>
218
219
  <li>
219
- <tt><a href="doc/SimplerTiles/Map.html">SimplerTiles::Layer</a></tt>: wraps
220
- the <tt><a href="http://propublica.github.com/simple-tiles/#layers">simplet_layer_t</a></tt>
220
+ <tt><a href="doc/SimplerTiles/Map.html">SimplerTiles::VectorLayer</a></tt>: wraps
221
+ the <tt><a href="http://propublica.github.com/simple-tiles/#vector_layers">simplet_vector_layer_t</a></tt>
221
222
  C structure and contains an OGR connection string for a particular data source,
222
- and contains a list of <tt>SimplerTiles::Query</tt> objects.
223
+ and contains a list of <tt>SimplerTiles::Query</tt> objects. <strong>Note:</strong> The <tt>SimplerTiles::Layer</tt>
224
+ class now proxies to <tt>VectorLayer</tt>.
225
+ </li>
226
+ <li>
227
+ <tt><a href="doc/SimplerTiles/Map.html">SimplerTiles::RasterLayer</a></tt>: wraps
228
+ the <tt><a href="http://propublica.github.com/simple-tiles/#raster_layers">simplet_raster_layer_t</a></tt>
229
+ C structure and contains an GDAL connection string for a particular data source.
223
230
  </li>
224
231
  <li>
225
232
  <tt><a href="doc/SimplerTiles/Query.html">SimplerTiles::Query</a></tt>: wraps
@@ -256,7 +263,7 @@ map = SimplerTiles::Map.new do |m|
256
263
  m.set_bounds(-585080.885134, 6849466.721081, 4161303.603672, 9587780.816356)
257
264
 
258
265
  Dir["\#\{ROOT\}/data/*.shp"].each do |shp|
259
- m.layer shp do |l|
266
+ m.vector_layer shp do |l|
260
267
  l.query "select * from '\#\{File.basename shp, '.shp'\}'" do |q|
261
268
  q.styles "stroke" => "#111111",
262
269
  "line-join" => "round",
@@ -310,7 +317,7 @@ get '/tiles/*/:x/:y/:z.png' do
310
317
  m.slippy params[:x].to_i, params[:y].to_i, params[:z].to_i
311
318
 
312
319
  # Add a layer based on the parameters in the URL
313
- m.layer File.join(ROOT, params[:splat].first) do |l|
320
+ m.vector_layer File.join(ROOT, params[:splat].first) do |l|
314
321
 
315
322
  # Grab all of the data from the shapefile
316
323
  l.query "select * from '\#\{File.basename(params[:splat].first, '.shp')\}'" do |q|
@@ -435,6 +442,10 @@ CODE
435
442
  <h2>Change Log</h2>
436
443
 
437
444
  <dl>
445
+ <dd><b>0.2.1</b> &mdash; June 21st, 2014</dd>
446
+ <dt>Added raster support. (thanks <a href="http://github.com/ashaw">Al Shaw</a>)</dt>
447
+ <dd><b>0.1.1</b> &mdash; February, 10th 2014</dd>
448
+ <dt>Small fix for building on OSX.</dt>
438
449
  <dd><b>0.1.1</b> &mdash; February, 10th 2014</dd>
439
450
  <dt>Small fix for building on OSX.</dt>
440
451
  <dd><b>0.1.0</b> &mdash; February, 4th 2014</dd>
@@ -444,13 +455,13 @@ CODE
444
455
  <dd><b>0.0.8</b> &mdash; April, 11th 2013</dd>
445
456
  <dt>Fix missing constant</dt>
446
457
  <dd><b>0.0.7</b> &mdash; February, 27th 2013</dd>
447
- <dt>Fix deprecation warnings and compatibility with Simple Tiles 0.3.0, (thanks <a href="http://github.com/adamtrilling">adamtrilling</a>)</dt>
458
+ <dt>Fix deprecation warnings and compatibility with Simple Tiles 0.3.0, (thanks <a href="http://github.com/adamtrilling">Adam Trilling</a>)</dt>
448
459
  <dd><b>0.0.6</b> &mdash; January, 30th 2013</dd>
449
460
  <dt><tt>ar_layer</tt> now yields like <tt>layer</tt></dt>
450
461
  <dd><b>0.0.5</b> &mdash; January, 14th 2013</dd>
451
462
  <dt>Make the connection string for <tt>ar_layer</tt> more robust.</dt>
452
463
  <dd><b>0.0.4</b> &mdash; December 8, 2012</dd>
453
- <dt>Fix connection string for <tt>ar_layer</tt> (thanks <a href="http://github.com/adamtrilling">adamtrilling</a>)</dt>
464
+ <dt>Fix connection string for <tt>ar_layer</tt> (thanks <a href="http://github.com/adamtrilling">Adam Trilling</a>)</dt>
454
465
  <dd><b>0.0.3</b> &mdash; June 23, 2012</dd>
455
466
  <dt>Better search paths for cairo.</dt>
456
467
  <dd><b>0.0.2</b> &mdash; April 10, 2012</dd>
data/index.html CHANGED
@@ -415,6 +415,10 @@ $ gem install simpler-tiles
415
415
  <h2>Change Log</h2>
416
416
 
417
417
  <dl>
418
+ <dd><b>0.2.0</b> &mdash; June 21st, 2014</dd>
419
+ <dt>Added raster support. (thanks <a href="http://github.com/ashaw">Al Shaw</a>)</dt>
420
+ <dd><b>0.1.1</b> &mdash; February, 10th 2014</dd>
421
+ <dt>Small fix for building on OSX.</dt>
418
422
  <dd><b>0.1.1</b> &mdash; February, 10th 2014</dd>
419
423
  <dt>Small fix for building on OSX.</dt>
420
424
  <dd><b>0.1.0</b> &mdash; February, 4th 2014</dd>
@@ -424,13 +428,13 @@ $ gem install simpler-tiles
424
428
  <dd><b>0.0.8</b> &mdash; April, 11th 2013</dd>
425
429
  <dt>Fix missing constant</dt>
426
430
  <dd><b>0.0.7</b> &mdash; February, 27th 2013</dd>
427
- <dt>Fix deprecation warnings and compatibility with Simple Tiles 0.3.0, (thanks <a href="http://github.com/adamtrilling">adamtrilling</a>)</dt>
431
+ <dt>Fix deprecation warnings and compatibility with Simple Tiles 0.3.0, (thanks <a href="http://github.com/adamtrilling">Adam Trilling</a>)</dt>
428
432
  <dd><b>0.0.6</b> &mdash; January, 30th 2013</dd>
429
433
  <dt><tt>ar_layer</tt> now yields like <tt>layer</tt></dt>
430
434
  <dd><b>0.0.5</b> &mdash; January, 14th 2013</dd>
431
435
  <dt>Make the connection string for <tt>ar_layer</tt> more robust.</dt>
432
436
  <dd><b>0.0.4</b> &mdash; December 8, 2012</dd>
433
- <dt>Fix connection string for <tt>ar_layer</tt> (thanks <a href="http://github.com/adamtrilling">adamtrilling</a>)</dt>
437
+ <dt>Fix connection string for <tt>ar_layer</tt> (thanks <a href="http://github.com/adamtrilling">Adam Trilling</a>)</dt>
434
438
  <dd><b>0.0.3</b> &mdash; June 23, 2012</dd>
435
439
  <dt>Better search paths for cairo.</dt>
436
440
  <dd><b>0.0.2</b> &mdash; April 10, 2012</dd>
@@ -8,6 +8,8 @@ require "#{SimplerTiles::ROOT}/simpler_tiles/simpler_tiles"
8
8
  require "#{SimplerTiles::ROOT}/simpler_tiles/mixins/pp"
9
9
  require "#{SimplerTiles::ROOT}/simpler_tiles/map"
10
10
  require "#{SimplerTiles::ROOT}/simpler_tiles/layer"
11
+ require "#{SimplerTiles::ROOT}/simpler_tiles/layer/vector_layer"
12
+ require "#{SimplerTiles::ROOT}/simpler_tiles/layer/raster_layer"
11
13
  require "#{SimplerTiles::ROOT}/simpler_tiles/query"
12
14
  require "#{SimplerTiles::ROOT}/simpler_tiles/style"
13
15
  require "#{SimplerTiles::ROOT}/simpler_tiles/bounds"
@@ -1,25 +1,6 @@
1
1
  module SimplerTiles
2
2
  # The Layer object contains connection info for a particular datasource and
3
3
  # tracks a list of {Query}s.
4
- class Layer
5
- include SimplerTiles::PP
6
-
7
- # Initialize a Layer
8
- def initialize(source)
9
- self.source = source
10
- yield self if block_given?
11
- end
12
-
13
- # Add a query to this Layer's c list.
14
- def query(sql, &blk)
15
- layer = SimplerTiles::Query.new(sql, &blk)
16
- add_query layer
17
- end
18
-
19
- private
20
-
21
- def inspect_attributes
22
- [:source]
23
- end
4
+ class Layer < VectorLayer
24
5
  end
25
6
  end
@@ -0,0 +1,16 @@
1
+ module SimplerTiles
2
+ class RasterLayer
3
+ include SimplerTiles::PP
4
+
5
+ def initialize(source)
6
+ self.source = source
7
+ yield self if block_given?
8
+ end
9
+
10
+ private
11
+
12
+ def inspect_attributes
13
+ [:source]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ module SimplerTiles
2
+ # The VectorLayer object contains connection info for a particular datasource and
3
+ # tracks a list of {Query}s.
4
+ class VectorLayer
5
+ include SimplerTiles::PP
6
+
7
+ def initialize(source)
8
+ self.source = source
9
+ yield self if block_given?
10
+ end
11
+
12
+ # Add a query to this Layer's c list.
13
+ def query(sql, &blk)
14
+ layer = SimplerTiles::Query.new(sql, &blk)
15
+ add_query layer
16
+ end
17
+
18
+ private
19
+
20
+ def inspect_attributes
21
+ [:source]
22
+ end
23
+ end
24
+ end
@@ -11,8 +11,14 @@ module SimplerTiles
11
11
 
12
12
  # Add a layer to the c list of layers and yield the new layer.
13
13
  def layer(source, &blk)
14
- layer = SimplerTiles::Layer.new(source, &blk)
15
- add_layer layer
14
+ layer = SimplerTiles::VectorLayer.new(source, &blk)
15
+ add_vector_layer layer
16
+ end
17
+
18
+ # Add a raster layer
19
+ def raster_layer(source)
20
+ layer = SimplerTiles::RasterLayer.new(source)
21
+ add_raster_layer layer
16
22
  end
17
23
 
18
24
  # A convienence method to use Active Record configuration and add a new
@@ -1,4 +1,4 @@
1
1
  module SimplerTiles
2
2
  # The version of the library
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
@@ -23,7 +23,8 @@ Gem::Specification.new do |s|
23
23
  s.summary = %q{A set of ruby bindings for the Simple Tiles mapping library.}
24
24
 
25
25
  s.add_development_dependency(%q<rake-compiler>, [">= 0"])
26
- s.add_development_dependency(%q<bundler>, ["~> 1.5.0"])
26
+ s.add_development_dependency(%q<bundler>, [">= 1.5.0"])
27
+ s.add_development_dependency(%q<minitest>, ["~> 4.0.0"])
27
28
  s.add_development_dependency(%q<shoulda>, ["~> 3.5.0"])
28
29
  s.add_development_dependency(%q<yard>, ["~> 0.8.0"])
29
30
  end
@@ -3,15 +3,21 @@ require "#{File.join(File.dirname(__FILE__))}/helper"
3
3
  class TestSimplerTiles < Test::Unit::TestCase
4
4
  should "produce a png image" do
5
5
  map = SimplerTiles::Map.new do |m|
6
- m.slippy 3, 6, 4
6
+ # m.bgcolor = "#000000"
7
+ m.srs = "EPSG:32614"
8
+ m.width = 256
9
+ m.height = 256
10
+ m.set_bounds(195585.000, 3472515.000, 427815.000, 3235485.000)
7
11
  m.layer "#{File.dirname(__FILE__)}/../data/tl_2010_us_state10.shp" do |l|
8
12
  l.query "SELECT * from 'tl_2010_us_state10'" do |q|
9
- q.styles 'fill' => "#061F3799",
13
+ q.styles 'fill' => "#000dff",
10
14
  'line-join' => "round",
11
- 'line-cap' => "square",
12
- 'seamless' => "true"
15
+ 'line-cap' => "square"
13
16
  end
14
17
  end
18
+ # to set a nodata flag on a landsat look img
19
+ # gdal_translate -a_nodata 0 someplaceintexas.jpg someplaceintexas_nodata.jpg
20
+ m.raster_layer "#{File.dirname(__FILE__)}/../data/someplaceintexas-nodata.jpg"
15
21
  end
16
22
 
17
23
  assert map.valid?
@@ -26,33 +32,34 @@ class TestSimplerTiles < Test::Unit::TestCase
26
32
 
27
33
 
28
34
  should "not crash with memory errors" do
29
- GC.disable
30
- t = 100.times.map do
31
- Thread.new do
32
- map = SimplerTiles::Map.new do |m|
33
- m.slippy 3, 6, 4
34
- m.layer "#{File.dirname(__FILE__)}/../data/tl_2010_us_state10.shp" do |l|
35
- l.query "SELECT * from 'tl_2010_us_state10'" do |q|
36
- q.styles 'fill' => "#061F3799",
37
- 'line-join' => "round",
38
- 'line-cap' => "square",
39
- 'seamless' => "true"
40
- end
41
- end
42
- end
35
+ # GC.disable
36
+ # t = 10.times.map do
37
+ # Thread.new do
38
+ # map = SimplerTiles::Map.new do |m|
39
+ # m.slippy 3, 6, 4
40
+ # m.layer "#{File.dirname(__FILE__)}/../data/tl_2010_us_state10.shp" do |l|
41
+ # l.query "SELECT * from 'tl_2010_us_state10'" do |q|
42
+ # q.styles 'fill' => "#061F3799",
43
+ # 'line-join' => "round",
44
+ # 'line-cap' => "square",
45
+ # 'seamless' => "true"
46
+ # end
47
+ # end
48
+ # m.raster_layer "#{File.dirname(__FILE__)}/../data/someplaceintexas.jpg"
49
+ # end
43
50
 
44
- assert map.valid?
45
- map.to_png do |data|
46
- assert data
47
- File.open "#{File.dirname(__FILE__)}/out.png", "wb" do |f|
48
- f.write data
49
- end
50
- assert data.length
51
- end
52
- end
53
- end
54
- t.map(&:join)
51
+ # assert map.valid?
52
+ # map.to_png do |data|
53
+ # assert data
54
+ # File.open "#{File.dirname(__FILE__)}/out.png", "wb" do |f|
55
+ # f.write data
56
+ # end
57
+ # assert data.length
58
+ # end
59
+ # end
60
+ # end
61
+ # t.map(&:join)
62
+ # GC.enable
63
+ # GC.start
55
64
  end
56
- GC.enable
57
- GC.start
58
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpler-tiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Larson
@@ -28,16 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.5.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: shoulda
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +96,6 @@ files:
82
96
  - Rakefile
83
97
  - ext/simpler_tiles/bounds.c
84
98
  - ext/simpler_tiles/bounds.h
85
- - ext/simpler_tiles/depend
86
99
  - ext/simpler_tiles/extconf.rb
87
100
  - ext/simpler_tiles/layer.c
88
101
  - ext/simpler_tiles/layer.h
@@ -90,15 +103,21 @@ files:
90
103
  - ext/simpler_tiles/map.h
91
104
  - ext/simpler_tiles/query.c
92
105
  - ext/simpler_tiles/query.h
106
+ - ext/simpler_tiles/raster_layer.c
107
+ - ext/simpler_tiles/raster_layer.h
93
108
  - ext/simpler_tiles/simpler_tiles.c
94
109
  - ext/simpler_tiles/simpler_tiles.h
95
110
  - ext/simpler_tiles/style.c
96
111
  - ext/simpler_tiles/style.h
112
+ - ext/simpler_tiles/vector_layer.c
113
+ - ext/simpler_tiles/vector_layer.h
97
114
  - index.erb
98
115
  - index.html
99
116
  - lib/simpler_tiles.rb
100
117
  - lib/simpler_tiles/bounds.rb
101
118
  - lib/simpler_tiles/layer.rb
119
+ - lib/simpler_tiles/layer/raster_layer.rb
120
+ - lib/simpler_tiles/layer/vector_layer.rb
102
121
  - lib/simpler_tiles/map.rb
103
122
  - lib/simpler_tiles/mixins/pp.rb
104
123
  - lib/simpler_tiles/query.rb
File without changes