shp 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/ext/shp/shapefile.cpp +18 -0
- data/ext/shp/shapefile.hpp +1 -0
- data/lib/shp/version.rb +1 -1
- data/spec/shp_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWM3ZjQ1MmRkMjEzNmQ4Y2NlOWQ5ODk2Mjk2MWZjYTJiMTVkMDQ3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODIyOTkxM2M2NGIwOTFjOThlYWE2N2Y5NDgxMzdkNDdlYjBhZjE2Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzAzNzc4NDc3YmRmZWM4NDcwNGI3ODNhZjE1YzY5M2ZlYzU1ZjQwMjkyMGIw
|
10
|
+
ZTlkY2IyZGIxYmQ2NDkzYjFiMDk3NzNiZjNiNzlmZjIxMGY5NjgyZWQwMjNj
|
11
|
+
M2EyNmZmYjQxYjM4ZWRmMTBmMWRlYjRiNDljNWU4NWI4MTZiM2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjRiYTM3NGFjZDM2Y2FiM2QzOThlNjlhZTliYjMxNzY0OGRlMjM4YWUzODIy
|
14
|
+
ZDE1Yzk1N2QwODcwNjVhNDIzNWNiZGU2ODUzOTdhYjU1MGMyZjNmYjYwYzBj
|
15
|
+
NmQ4M2Q1MGUzYTg1NzdjNjgwYzk5NDM3N2ZmMGVkOGI4MTgwOGM=
|
data/ext/shp/shapefile.cpp
CHANGED
@@ -22,6 +22,23 @@ shapefile::~shapefile() {
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
+
VALUE shapefile::open(VALUE klass, VALUE filename, VALUE accessType)
|
26
|
+
{
|
27
|
+
CHECK_ARGUMENT_STRING(filename);
|
28
|
+
CHECK_ARGUMENT_STRING(accessType);
|
29
|
+
|
30
|
+
SHPHandle handle = SHPOpen(RSTRING_PTR(filename), RSTRING_PTR(accessType));
|
31
|
+
|
32
|
+
if (handle == NULL) {
|
33
|
+
SHP_FATAL("Failed to open shapefile.");
|
34
|
+
return Qnil;
|
35
|
+
}
|
36
|
+
|
37
|
+
shapefile *shp = new shapefile(handle);
|
38
|
+
|
39
|
+
return shp->wrapped();
|
40
|
+
}
|
41
|
+
|
25
42
|
VALUE shapefile::create(VALUE klass, VALUE filename, VALUE shapeType)
|
26
43
|
{
|
27
44
|
CHECK_ARGUMENT_STRING(filename);
|
@@ -285,6 +302,7 @@ void shapefile::define(VALUE module)
|
|
285
302
|
{
|
286
303
|
shapefile::_klass = rb_define_class_under(module, "Shapefile", rb_cObject);
|
287
304
|
base::define(shapefile::_klass, false);
|
305
|
+
rb_define_singleton_method(shapefile::_klass, "open", SHP_METHOD(shapefile::open), 2);
|
288
306
|
rb_define_singleton_method(shapefile::_klass, "create", SHP_METHOD(shapefile::create), 2);
|
289
307
|
rb_define_singleton_method(shapefile::_klass, "create_simple_object", SHP_METHOD(shapefile::create_simple_object), 5);
|
290
308
|
rb_define_singleton_method(shapefile::_klass, "create_object", SHP_METHOD(shapefile::create_simple_object), 10);
|
data/ext/shp/shapefile.hpp
CHANGED
@@ -10,6 +10,7 @@ namespace shp {
|
|
10
10
|
shapefile() : base<shapefile>(), _handle(0) {};
|
11
11
|
shapefile(SHPHandle handle);
|
12
12
|
static void define(VALUE module);
|
13
|
+
static VALUE open(VALUE klass, VALUE filename, VALUE accessType);
|
13
14
|
static VALUE create(VALUE klass, VALUE filename, VALUE shapeType);
|
14
15
|
static VALUE create_simple_object(VALUE klass, VALUE shapeType, VALUE numberOfVertices, VALUE arrayOfX, VALUE arrayOfY, VALUE arrayOfZ);
|
15
16
|
static VALUE create_object(VALUE klass, VALUE shapeType, VALUE shapeIndex, VALUE numberOfParts,
|
data/lib/shp/version.rb
CHANGED
data/spec/shp_spec.rb
CHANGED
@@ -43,6 +43,11 @@ describe "SHP" do
|
|
43
43
|
File.open("testfile.prj", "wb") {|f| f.write(prj_content)}
|
44
44
|
end
|
45
45
|
|
46
|
+
it 'open should open a shapefile for reading' do
|
47
|
+
shp = SHP::Shapefile.open('testfile', 'rb')
|
48
|
+
shp.should_not be_nil
|
49
|
+
end
|
50
|
+
|
46
51
|
it 'get_info to return the shapefile info' do
|
47
52
|
info = @shp.get_info
|
48
53
|
info[:number_of_entities].should eq(2001)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zac McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|