lwgeom 0.2 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/lwgeom/lwgeom.c +26 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31d546340dbcf627c9ed2891476a92ee19f0a8be
|
4
|
+
data.tar.gz: 3074c9946e7eb2f8fe88ce8b7919fdf0a5135672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0809a0f1a90f036f537bd77ffcc96ca4314e74ed46db7a304d6c7fd6bfe594d8b22df36b1eee3285379caf4da4d259889fd4791002a9e9668f209fa09f4d234c
|
7
|
+
data.tar.gz: 90041d93e90cc8e0468ca0ada14fd32ec6d1e6463777cda399761e2268209d255346004daf03a6deaec47c269e4673dc1c56303424996e5533c0b1e2f89533a8
|
data/ext/lwgeom/lwgeom.c
CHANGED
@@ -7,6 +7,8 @@ double EARTH_MINOR_AXIS_RADIUS = 6356752.314245179498;
|
|
7
7
|
LWGEOM *lwg;
|
8
8
|
SPHEROID s;
|
9
9
|
|
10
|
+
static VALUE cSpheroid;
|
11
|
+
|
10
12
|
double get_area_for_lwg()
|
11
13
|
{
|
12
14
|
double area = lwgeom_area_spheroid(lwg, &s);
|
@@ -70,13 +72,35 @@ static VALUE get_length_from_hexwkb(VALUE self, VALUE geom_hexwkb)
|
|
70
72
|
return rb_float_new(length);
|
71
73
|
}
|
72
74
|
|
75
|
+
// trying to make polygon to be valid
|
76
|
+
// accept only string-polygon in wkb format
|
77
|
+
static VALUE make_valid(VALUE self, VALUE geom_wkb)
|
78
|
+
{
|
79
|
+
VALUE result;
|
80
|
+
LWGEOM *valid_lwg;
|
81
|
+
|
82
|
+
int wkb_size_a;
|
83
|
+
wkb_size_a = RSTRING_LEN(geom_wkb);
|
84
|
+
|
85
|
+
lwg = lwgeom_from_wkb(RSTRING_PTR(geom_wkb), wkb_size_a, 0);
|
86
|
+
|
87
|
+
valid_lwg = lwgeom_make_valid(lwg);
|
88
|
+
//make multi
|
89
|
+
valid_lwg = lwgeom_as_multi(valid_lwg);
|
90
|
+
|
91
|
+
char *wkb_str = (char*)lwgeom_to_wkb(valid_lwg, WKB_HEX, NULL);
|
92
|
+
|
93
|
+
|
94
|
+
return rb_str_new2(wkb_str);
|
95
|
+
}
|
96
|
+
|
73
97
|
void Init_lwgeom()
|
74
98
|
{
|
75
99
|
/* define module */
|
76
100
|
VALUE mLwGeom = rb_define_module("LwGeom");
|
77
101
|
|
78
102
|
/* define class */
|
79
|
-
|
103
|
+
cSpheroid = rb_define_class_under(mLwGeom, "Spheroid", rb_cObject);
|
80
104
|
|
81
105
|
rb_define_module_function(cSpheroid, "get_area_from_hexwkb", get_area_from_hexwkb, 1);
|
82
106
|
rb_define_module_function(cSpheroid, "get_area_from_wkb", get_area_from_wkb, 1);
|
@@ -84,6 +108,7 @@ void Init_lwgeom()
|
|
84
108
|
rb_define_module_function(cSpheroid, "get_length_from_wkt", get_length_from_wkt, 1);
|
85
109
|
rb_define_module_function(cSpheroid, "get_length_from_wkb", get_length_from_wkb, 1);
|
86
110
|
rb_define_module_function(cSpheroid, "get_length_from_hexwkb",get_length_from_hexwkb,1);
|
111
|
+
rb_define_module_function(cSpheroid, "make_valid", make_valid, 1);
|
87
112
|
|
88
113
|
spheroid_init(&s, EARTH_MAJOR_AXIS_RADIUS, EARTH_MINOR_AXIS_RADIUS);
|
89
114
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lwgeom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Nelin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: With this gem you can call lwgeom methods from ruby
|
14
14
|
email:
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.4.5
|
43
|
+
rubygems_version: 2.4.5.1
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Ruby bindings for lwgeom library
|