lwgeom 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d954159e5ab11a16233f6514548027f9e23fc76c
4
+ data.tar.gz: 507360127e3de317160190847458e30017701703
5
+ SHA512:
6
+ metadata.gz: d4084add6566bce97abf2501674a4ddf18eb39da7624c2a63664618844dfe9c426c398783d5d5384da72e8a31d74a6dd06668605823085d8f5c3f82ffb0eaeb0
7
+ data.tar.gz: 5b451a3265279b9f61caf141b4e4960d714f17e27276d5ce286d3d89eaa12f985087572e52f1a100e2b26b5e362e7b205921d8b2691cc3160fc15cbddca88e8d
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ require 'mkmf'
3
+
4
+ # checking is postgis/lwgeom installed
5
+ if have_library("lwgeom")
6
+ create_header
7
+ create_makefile 'lwgeom'
8
+ else
9
+ puts "Oops..."
10
+ end
11
+
@@ -0,0 +1,41 @@
1
+ #include <ruby.h>
2
+ #include <liblwgeom.h>
3
+
4
+ double EARTH_MAJOR_AXIS_RADIUS = 6378137.0;
5
+ double EARTH_MINOR_AXIS_RADIUS = 6356752.314245179498;
6
+
7
+ LWGEOM *lwg;
8
+ SPHEROID s;
9
+
10
+ static VALUE get_area(VALUE self, VALUE geom_wkt)
11
+ {
12
+ lwg = lwgeom_from_wkt(RSTRING_PTR(geom_wkt), 0);
13
+ double area = lwgeom_area_spheroid(lwg, &s);
14
+ lwgeom_free(lwg);
15
+
16
+ return rb_float_new(area);
17
+ }
18
+
19
+ VALUE get_length(VALUE self, VALUE geom_wkt)
20
+ {
21
+ lwg = lwgeom_from_wkt(RSTRING_PTR(geom_wkt), 0);
22
+ double length = lwgeom_length_spheroid(lwg, &s);
23
+ lwgeom_free(lwg);
24
+
25
+ return rb_float_new(length);
26
+ }
27
+
28
+ void Init_lwgeom()
29
+ {
30
+ /* define module */
31
+ VALUE mLwGeom = rb_define_module("LwGeom");
32
+
33
+ /* define class */
34
+ VALUE cSpheroid = rb_define_class_under(mLwGeom, "Spheroid", rb_cObject);
35
+
36
+ rb_define_module_function(cSpheroid, "get_area", get_area, 1);
37
+ rb_define_module_function(cSpheroid, "get_length", get_length, 1);
38
+
39
+ spheroid_init(&s, EARTH_MAJOR_AXIS_RADIUS, EARTH_MINOR_AXIS_RADIUS);
40
+ }
41
+
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lwgeom
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Nelin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: With this gem you can call lwgeom methods from ruby
14
+ email:
15
+ - y.nelin@gmail.com
16
+ executables: []
17
+ extensions:
18
+ - ext/lwgeom/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ext/lwgeom/extconf.rb
22
+ - ext/lwgeom/lwgeom.c
23
+ homepage: http://cropio.com
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - ext/lwgeom
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.4.5
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Ruby bindings for lwgeom library
47
+ test_files: []