Class: SimplerTiles::Bounds
- Inherits:
-
Object
- Object
- SimplerTiles::Bounds
- Includes:
- PP
- Defined in:
- lib/simpler_tiles/bounds.rb,
ext/simpler_tiles/bounds.c
Overview
Instance Method Summary collapse
-
#grow(x, y) ⇒ Bounds
Extend the bounds to include the point defined by x, y.
-
#initialize(maxx, maxy, minx, miny) ⇒ Bounds
constructor
Initialize a bounds from max and min coordinates.
-
#reproject(from, to) ⇒ Bounds
Reproject the bounds from
from_projto new projectionto_proj. -
#to_wkt ⇒ String
Return a WKT representation of the bounds.
Methods included from PP
Constructor Details
#initialize(maxx, maxy, minx, miny) ⇒ Bounds
Initialize a bounds from max and min coordinates
8 9 10 11 |
# File 'lib/simpler_tiles/bounds.rb', line 8 def initialize(maxx, maxy, minx, miny) grow maxx, maxy grow minx, miny end |
Instance Method Details
#grow(x, y) ⇒ Bounds
Extend the bounds to include the point defined by x, y.
36 37 38 39 40 41 |
# File 'ext/simpler_tiles/bounds.c', line 36
static VALUE
grow(VALUE self, VALUE x, VALUE y){
simplet_bounds_t *bounds = get_bounds(self);
simplet_bounds_extend(bounds, NUM2DBL(x), NUM2DBL(y));
return self;
}
|
#reproject(from, to) ⇒ Bounds
Reproject the bounds from from_proj to new projection to_proj. Returns a new bounds object.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'ext/simpler_tiles/bounds.c', line 50
static VALUE
reproject(VALUE self, VALUE from, VALUE to) {
Check_Type(from, T_STRING);
Check_Type(to, T_STRING);
simplet_bounds_t *bounds;
if(!(bounds = simplet_bounds_reproject(get_bounds(self), RSTRING_PTR(from), RSTRING_PTR(to))))
rb_raise(rb_eRuntimeError, "Error in creating bounds.");
VALUE id = rb_intern("new");
VALUE rbounds = rb_funcall(cSimplerTilesBounds, id, 4,
rb_float_new(bounds->nw.x),
rb_float_new(bounds->nw.y),
rb_float_new(bounds->se.x),
rb_float_new(bounds->se.y));
simplet_bounds_free(bounds);
return rbounds;
}
|
#to_wkt ⇒ String
Return a WKT representation of the bounds.
19 20 21 22 23 24 25 26 27 28 |
# File 'ext/simpler_tiles/bounds.c', line 19
static VALUE
to_wkt(VALUE self){
simplet_bounds_t *bounds = get_bounds(self);
char *wkt = NULL;
if(simplet_bounds_to_wkt(bounds, &wkt) != SIMPLET_OK)
rb_raise(rb_eRuntimeError, "Error in creating wkt string.");
return rb_str_new2(wkt);
}
|