lwgeom 0.1 → 0.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 +54 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90f94d270e97fb98b8e98482107832dccfc25ea
|
4
|
+
data.tar.gz: 6c56624d707c2d4b30d61f21c5290493331d613c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81d8d8d808c76623e3617f42c7a773bfaef3a86fd7f2d2b6f6721eb5eefe0637dd07c3822a53a8d08c2e150d454e12b9c05194f336988b832dc330d61d495c5b
|
7
|
+
data.tar.gz: 7dadac221fafd6b8845bfd1271be3abb9f17127b9073edb5889eb6664e3cfb8924e3f9a88ba60586596fca06b245995af016dfb5c0597a3810e4126e7afc7472
|
data/ext/lwgeom/lwgeom.c
CHANGED
@@ -7,21 +7,66 @@ double EARTH_MINOR_AXIS_RADIUS = 6356752.314245179498;
|
|
7
7
|
LWGEOM *lwg;
|
8
8
|
SPHEROID s;
|
9
9
|
|
10
|
-
|
10
|
+
double get_area_for_lwg()
|
11
11
|
{
|
12
|
-
lwg = lwgeom_from_wkt(RSTRING_PTR(geom_wkt), 0);
|
13
12
|
double area = lwgeom_area_spheroid(lwg, &s);
|
14
13
|
lwgeom_free(lwg);
|
14
|
+
return area;
|
15
|
+
}
|
16
|
+
|
17
|
+
static VALUE get_area_from_wkb(VALUE self, VALUE geom_wkb)
|
18
|
+
{
|
19
|
+
int wkb_size_a;
|
20
|
+
wkb_size_a = RSTRING_LEN(geom_wkb);
|
21
|
+
lwg = lwgeom_from_wkb(RSTRING_PTR(geom_wkb), wkb_size_a, 0);
|
22
|
+
double area = get_area_for_lwg();
|
23
|
+
return rb_float_new(area);
|
24
|
+
}
|
15
25
|
|
26
|
+
static VALUE get_area_from_hexwkb(VALUE self, VALUE geom_wkb)
|
27
|
+
{
|
28
|
+
lwg = lwgeom_from_hexwkb(RSTRING_PTR(geom_wkb), 0);
|
29
|
+
double area = get_area_for_lwg();
|
16
30
|
return rb_float_new(area);
|
17
31
|
}
|
18
32
|
|
19
|
-
VALUE
|
33
|
+
static VALUE get_area_from_wkt(VALUE self, VALUE geom_wkt)
|
20
34
|
{
|
21
35
|
lwg = lwgeom_from_wkt(RSTRING_PTR(geom_wkt), 0);
|
36
|
+
double area = lwgeom_area_spheroid(lwg, &s);
|
37
|
+
return rb_float_new(area);
|
38
|
+
}
|
39
|
+
|
40
|
+
// methods for calculating length
|
41
|
+
double get_length_for_lwg()
|
42
|
+
{
|
22
43
|
double length = lwgeom_length_spheroid(lwg, &s);
|
23
44
|
lwgeom_free(lwg);
|
45
|
+
return length;
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE get_length_from_wkt(VALUE self, VALUE geom_wkt)
|
49
|
+
{
|
50
|
+
lwg = lwgeom_from_wkt(RSTRING_PTR(geom_wkt), 0);
|
51
|
+
double length = get_length_for_lwg();
|
52
|
+
return rb_float_new(length);
|
53
|
+
}
|
24
54
|
|
55
|
+
|
56
|
+
static VALUE get_length_from_wkb(VALUE self, VALUE geom_wkb)
|
57
|
+
{
|
58
|
+
int wkb_size_a;
|
59
|
+
wkb_size_a = RSTRING_LEN(geom_wkb);
|
60
|
+
lwg = lwgeom_from_wkb(RSTRING_PTR(geom_wkb), wkb_size_a, 0);
|
61
|
+
double area = get_length_for_lwg();
|
62
|
+
return rb_float_new(area);
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE get_length_from_hexwkb(VALUE self, VALUE geom_hexwkb)
|
66
|
+
{
|
67
|
+
size_t wkb_size_a;
|
68
|
+
lwg = lwgeom_from_hexwkb(RSTRING_PTR(geom_hexwkb), 0);
|
69
|
+
double length = get_length_for_lwg();
|
25
70
|
return rb_float_new(length);
|
26
71
|
}
|
27
72
|
|
@@ -33,8 +78,12 @@ void Init_lwgeom()
|
|
33
78
|
/* define class */
|
34
79
|
VALUE cSpheroid = rb_define_class_under(mLwGeom, "Spheroid", rb_cObject);
|
35
80
|
|
36
|
-
rb_define_module_function(cSpheroid, "
|
37
|
-
rb_define_module_function(cSpheroid, "
|
81
|
+
rb_define_module_function(cSpheroid, "get_area_from_hexwkb", get_area_from_hexwkb, 1);
|
82
|
+
rb_define_module_function(cSpheroid, "get_area_from_wkb", get_area_from_wkb, 1);
|
83
|
+
rb_define_module_function(cSpheroid, "get_area_from_wkt", get_area_from_wkt, 1);
|
84
|
+
rb_define_module_function(cSpheroid, "get_length_from_wkt", get_length_from_wkt, 1);
|
85
|
+
rb_define_module_function(cSpheroid, "get_length_from_wkb", get_length_from_wkb, 1);
|
86
|
+
rb_define_module_function(cSpheroid, "get_length_from_hexwkb",get_length_from_hexwkb,1);
|
38
87
|
|
39
88
|
spheroid_init(&s, EARTH_MAJOR_AXIS_RADIUS, EARTH_MINOR_AXIS_RADIUS);
|
40
89
|
}
|
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: '0.
|
4
|
+
version: '0.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-09-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: With this gem you can call lwgeom methods from ruby
|
14
14
|
email:
|