Class: SimplerTiles::Query

Inherits:
Object
  • Object
show all
Includes:
PP
Defined in:
lib/simpler_tiles/query.rb,
ext/simpler_tiles/query.c

Overview

A Query represents an OGR SQL query against a layer’s datasource. Queries contain styles that are applied to each returned object from the datastore.

Instance Method Summary collapse

Methods included from PP

#inspect

Constructor Details

#initialize(query) {|_self| ... } ⇒ Query

Initialize a query with a string containing OGR SQL.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
# File 'lib/simpler_tiles/query.rb', line 8

def initialize(query)
  self.query = query
  yield self if block_given?
end

Instance Method Details

#queryString

Get the OGR SQL for this Query.

Returns:

  • (String)


50
51
52
53
54
55
56
# File 'ext/simpler_tiles/query.c', line 50

static VALUE
get_sql(VALUE self){
  simplet_query_t *query = get_query(self);
  char *str;
  simplet_query_get(query, &str);
  return rb_str_new2(str);
}

#query=(query) ⇒ String

Set the OGR SQL for this Query.

Returns:

  • (String)


37
38
39
40
41
42
43
# File 'ext/simpler_tiles/query.c', line 37

static VALUE
set_sql(VALUE self, VALUE query){
  Check_Type(query, T_STRING);
  simplet_query_t *qry = get_query(self);
  simplet_query_set(qry, RSTRING_PTR(query));
  return query;
}

#styles(styles) ⇒ Object

Styles will take a hash of style declarations and adds them to the internal c list.



15
16
17
18
19
20
# File 'lib/simpler_tiles/query.rb', line 15

def styles(styles)
  styles.each do |k,v|
    style = SimplerTiles::Style.new k, v
    add_style style
  end
end