shp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +34 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE +28 -0
- data/README.md +30 -0
- data/Rakefile +23 -0
- data/ext/shp/base.hpp +113 -0
- data/ext/shp/dbf.cpp +381 -0
- data/ext/shp/dbf.hpp +44 -0
- data/ext/shp/extconf.rb +13 -0
- data/ext/shp/shape_object.cpp +58 -0
- data/ext/shp/shape_object.hpp +27 -0
- data/ext/shp/shapefile.cpp +299 -0
- data/ext/shp/shapefile.hpp +35 -0
- data/ext/shp/shapelib/.cvsignore +15 -0
- data/ext/shp/shapelib/ChangeLog +450 -0
- data/ext/shp/shapelib/HOWTO-RELEASE +16 -0
- data/ext/shp/shapelib/LICENSE.LGPL +483 -0
- data/ext/shp/shapelib/Makefile +113 -0
- data/ext/shp/shapelib/README +41 -0
- data/ext/shp/shapelib/README.tree +172 -0
- data/ext/shp/shapelib/contrib/.cvsignore +12 -0
- data/ext/shp/shapelib/contrib/Makefile +66 -0
- data/ext/shp/shapelib/contrib/ShapeFileII.pas +234 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly.cpp +238 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly_README.txt +59 -0
- data/ext/shp/shapelib/contrib/csv2shp.c +558 -0
- data/ext/shp/shapelib/contrib/dbfcat.c +166 -0
- data/ext/shp/shapelib/contrib/dbfinfo.c +106 -0
- data/ext/shp/shapelib/contrib/makefile.vc +34 -0
- data/ext/shp/shapelib/contrib/my_nan.h +46 -0
- data/ext/shp/shapelib/contrib/shpcat.c +100 -0
- data/ext/shp/shapelib/contrib/shpcentrd.c +159 -0
- data/ext/shp/shapelib/contrib/shpdata.c +129 -0
- data/ext/shp/shapelib/contrib/shpdxf.c +340 -0
- data/ext/shp/shapelib/contrib/shpfix.c +110 -0
- data/ext/shp/shapelib/contrib/shpgeo.c +1595 -0
- data/ext/shp/shapelib/contrib/shpgeo.h +154 -0
- data/ext/shp/shapelib/contrib/shpinfo.c +113 -0
- data/ext/shp/shapelib/contrib/shpproj.c +260 -0
- data/ext/shp/shapelib/contrib/shpsort.c +605 -0
- data/ext/shp/shapelib/contrib/shpsort.txt +44 -0
- data/ext/shp/shapelib/contrib/shpwkb.c +123 -0
- data/ext/shp/shapelib/contrib/tests/shpproj.sh +38 -0
- data/ext/shp/shapelib/dbfopen.c +2221 -0
- data/ext/shp/shapelib/makefile.vc +86 -0
- data/ext/shp/shapelib/makeshape.sh +21 -0
- data/ext/shp/shapelib/mkdist.sh +37 -0
- data/ext/shp/shapelib/mkinstalldirs +38 -0
- data/ext/shp/shapelib/mkrelease.sh +55 -0
- data/ext/shp/shapelib/safileio.c +286 -0
- data/ext/shp/shapelib/shapefil.h +647 -0
- data/ext/shp/shapelib/shapelib.def +46 -0
- data/ext/shp/shapelib/shpopen.c +2388 -0
- data/ext/shp/shapelib/shptree.c +1187 -0
- data/ext/shp/shapelib/shputils.c +1072 -0
- data/ext/shp/shapelib/stream1.out +1465 -0
- data/ext/shp/shapelib/stream1.sh +28 -0
- data/ext/shp/shapelib/stream2.out +530 -0
- data/ext/shp/shapelib/stream2.sh +11 -0
- data/ext/shp/shapelib/stream3.out +37 -0
- data/ext/shp/shapelib/web/.cvsignore +2 -0
- data/ext/shp/shapelib/web/codepage.html +403 -0
- data/ext/shp/shapelib/web/dbf_api.html +436 -0
- data/ext/shp/shapelib/web/index.html +235 -0
- data/ext/shp/shapelib/web/license.html +78 -0
- data/ext/shp/shapelib/web/manifest.html +87 -0
- data/ext/shp/shapelib/web/release.html +80 -0
- data/ext/shp/shapelib/web/shapelib-tools.html +352 -0
- data/ext/shp/shapelib/web/shp_api.html +376 -0
- data/ext/shp/shp.cpp +19 -0
- data/ext/shp/shp.hpp +47 -0
- data/lib/shp.rb +35 -0
- data/lib/shp/version.rb +3 -0
- data/shp.gemspec +23 -0
- data/spec/shp_spec.rb +127 -0
- metadata +176 -0
data/lib/shp/version.rb
ADDED
data/shp.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/shp/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Zac McCormick"]
|
6
|
+
gem.email = ["zac.mccormick@gmail.com"]
|
7
|
+
gem.description = %q{ESRI Shapefile bindings for ruby using shapelib}
|
8
|
+
gem.summary = %q{ESRI Shapefile bindings for ruby using shapelib. Currently contains native extensions for ShapeLib 1.3}
|
9
|
+
gem.homepage = "https://github.com/spatialnetworks/shp-ruby"
|
10
|
+
gem.licenses = ['BSD']
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.extensions = ['ext/shp/extconf.rb']
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "shp"
|
17
|
+
gem.require_paths = ['lib', 'ext']
|
18
|
+
gem.version = SHP::VERSION
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rake', ['>= 0']
|
21
|
+
gem.add_development_dependency 'rake-compiler', ['>= 0']
|
22
|
+
gem.add_development_dependency 'rspec', ['>= 0']
|
23
|
+
end
|
data/spec/shp_spec.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'shp'
|
2
|
+
|
3
|
+
describe "SHP" do
|
4
|
+
before(:all) do
|
5
|
+
@shp = SHP::Shapefile.create("testfile", 1)
|
6
|
+
@dbf = SHP::DBF.create("testfile")
|
7
|
+
|
8
|
+
rnd = Random.new
|
9
|
+
lat_range = 26.0..28.0
|
10
|
+
lon_range = -82.0..-80.0
|
11
|
+
|
12
|
+
(0..100).each do |field|
|
13
|
+
@dbf.add_field("field_#{field}", 0, 254, 0)
|
14
|
+
end
|
15
|
+
|
16
|
+
@dbf.add_field("integer_0", 1, 2^31, 0)
|
17
|
+
@dbf.add_field("double_0", 2, 2^31, 10)
|
18
|
+
@dbf.add_field("null_0", 1, 2^31, 0)
|
19
|
+
|
20
|
+
(0..2000).each do |num|
|
21
|
+
shape = SHP::Shapefile.create_simple_object(1, 1, [rnd.rand(lon_range)], [rnd.rand(lat_range)], nil)
|
22
|
+
@shp.write_object(-1, shape)
|
23
|
+
shape.compute_extents
|
24
|
+
@shp.rewind_object(shape)
|
25
|
+
|
26
|
+
(0..100).each do |field|
|
27
|
+
@dbf.write_string_attribute(num, field, "Record #{num} Field #{field}")
|
28
|
+
end
|
29
|
+
|
30
|
+
@dbf.write_integer_attribute(num, @dbf.get_field_index("integer_0"), 1337)
|
31
|
+
@dbf.write_double_attribute(num, @dbf.get_field_index("double_0"), 1337.1337)
|
32
|
+
@dbf.write_null_attribute(num, @dbf.get_field_index("null_0"))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:all) do
|
37
|
+
@dbf.close
|
38
|
+
@shp.close
|
39
|
+
|
40
|
+
# write .prj file
|
41
|
+
prj_content = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
|
42
|
+
|
43
|
+
File.open("testfile.prj", "wb") {|f| f.write(prj_content)}
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'get_info to return the shapefile info' do
|
47
|
+
info = @shp.get_info
|
48
|
+
info[:number_of_entities].should eq(2001)
|
49
|
+
info[:shape_type].should eq(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'get_field_count to return the field count' do
|
53
|
+
@dbf.get_field_count.should eq(104)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'get_record_count to return the record count' do
|
57
|
+
@dbf.get_record_count.should eq(2001)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'get_field_index to return the field index' do
|
61
|
+
@dbf.get_field_index("field_1").should eq(1)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'get_field_info to return the field info' do
|
65
|
+
@dbf.get_field_info(0).should eq({ name: "field_0", type: 0, width: 254, decimals: 0 })
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'read_integer_attribute to read the correct integer value' do
|
69
|
+
@dbf.read_integer_attribute(0, @dbf.get_field_index("integer_0")).should eq(1337)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'read_double_attribute to read the correct double value' do
|
73
|
+
@dbf.read_double_attribute(0, @dbf.get_field_index("double_0")).should eq(1337.1337)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'read_string_attribute to read the correct string value' do
|
77
|
+
@dbf.read_string_attribute(0, @dbf.get_field_index("field_0")).should eq('Record 0 Field 0')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'is_attribute_null to check if an attribute is NULL' do
|
81
|
+
@dbf.is_attribute_null(0, @dbf.get_field_index("null_0")).should eq(1)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'is_record_deleted to return 0 when a record has not been deleted' do
|
85
|
+
@dbf.is_record_deleted(0).should eq(0)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'mark_record_deleted to mark a record as deleted' do
|
89
|
+
@dbf.mark_record_deleted(0, 1).should eq(1)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'is_record_deleted to return 1 when a record has been deleted' do
|
93
|
+
@dbf.is_record_deleted(0).should eq(1)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'get_native_field_type on integer to be correct' do
|
97
|
+
@dbf.get_native_field_type(@dbf.get_field_index("integer_0")).should eq(SHP::DBF::FT_NATIVE_TYPE_INTEGER)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'get_native_field_type on double to be correct' do
|
101
|
+
@dbf.get_native_field_type(@dbf.get_field_index("double_0")).should eq(SHP::DBF::FT_NATIVE_TYPE_DOUBLE)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'get_native_field_type on string to be correct' do
|
105
|
+
@dbf.get_native_field_type(@dbf.get_field_index("field_0")).should eq(SHP::DBF::FT_NATIVE_TYPE_STRING)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should raise an error when destroy is called twice' do
|
109
|
+
shape = SHP::Shapefile.create_simple_object(1, 1, [-82.1], [-27.2], nil)
|
110
|
+
lambda { shape.destroy }.should_not raise_error
|
111
|
+
lambda { shape.destroy }.should raise_error
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should raise an error when calling a method after it has been destroyed' do
|
115
|
+
shape = SHP::Shapefile.create_simple_object(1, 1, [-82.1], [-27.2], nil)
|
116
|
+
lambda { shape.destroy }.should_not raise_error
|
117
|
+
lambda { shape.compute_extents }.should raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should raise an error when calling a method after it has been closed' do
|
121
|
+
file = SHP::Shapefile.create("testfile2", 1)
|
122
|
+
lambda { file.close }.should_not raise_error
|
123
|
+
lambda { file.get_info }.should raise_error
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zac McCormick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ESRI Shapefile bindings for ruby using shapelib
|
56
|
+
email:
|
57
|
+
- zac.mccormick@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/shp/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- ext/shp/base.hpp
|
70
|
+
- ext/shp/dbf.cpp
|
71
|
+
- ext/shp/dbf.hpp
|
72
|
+
- ext/shp/extconf.rb
|
73
|
+
- ext/shp/shape_object.cpp
|
74
|
+
- ext/shp/shape_object.hpp
|
75
|
+
- ext/shp/shapefile.cpp
|
76
|
+
- ext/shp/shapefile.hpp
|
77
|
+
- ext/shp/shapelib/.cvsignore
|
78
|
+
- ext/shp/shapelib/ChangeLog
|
79
|
+
- ext/shp/shapelib/HOWTO-RELEASE
|
80
|
+
- ext/shp/shapelib/LICENSE.LGPL
|
81
|
+
- ext/shp/shapelib/Makefile
|
82
|
+
- ext/shp/shapelib/README
|
83
|
+
- ext/shp/shapelib/README.tree
|
84
|
+
- ext/shp/shapelib/contrib/.cvsignore
|
85
|
+
- ext/shp/shapelib/contrib/Makefile
|
86
|
+
- ext/shp/shapelib/contrib/ShapeFileII.pas
|
87
|
+
- ext/shp/shapelib/contrib/Shape_PointInPoly.cpp
|
88
|
+
- ext/shp/shapelib/contrib/Shape_PointInPoly_README.txt
|
89
|
+
- ext/shp/shapelib/contrib/csv2shp.c
|
90
|
+
- ext/shp/shapelib/contrib/dbfcat.c
|
91
|
+
- ext/shp/shapelib/contrib/dbfinfo.c
|
92
|
+
- ext/shp/shapelib/contrib/makefile.vc
|
93
|
+
- ext/shp/shapelib/contrib/my_nan.h
|
94
|
+
- ext/shp/shapelib/contrib/shpcat.c
|
95
|
+
- ext/shp/shapelib/contrib/shpcentrd.c
|
96
|
+
- ext/shp/shapelib/contrib/shpdata.c
|
97
|
+
- ext/shp/shapelib/contrib/shpdxf.c
|
98
|
+
- ext/shp/shapelib/contrib/shpfix.c
|
99
|
+
- ext/shp/shapelib/contrib/shpgeo.c
|
100
|
+
- ext/shp/shapelib/contrib/shpgeo.h
|
101
|
+
- ext/shp/shapelib/contrib/shpinfo.c
|
102
|
+
- ext/shp/shapelib/contrib/shpproj.c
|
103
|
+
- ext/shp/shapelib/contrib/shpsort.c
|
104
|
+
- ext/shp/shapelib/contrib/shpsort.txt
|
105
|
+
- ext/shp/shapelib/contrib/shpwkb.c
|
106
|
+
- ext/shp/shapelib/contrib/tests/shpproj.sh
|
107
|
+
- ext/shp/shapelib/dbfadd.c
|
108
|
+
- ext/shp/shapelib/dbfcreate.c
|
109
|
+
- ext/shp/shapelib/dbfdump.c
|
110
|
+
- ext/shp/shapelib/dbfopen.c
|
111
|
+
- ext/shp/shapelib/makefile.vc
|
112
|
+
- ext/shp/shapelib/makeshape.sh
|
113
|
+
- ext/shp/shapelib/mkdist.sh
|
114
|
+
- ext/shp/shapelib/mkinstalldirs
|
115
|
+
- ext/shp/shapelib/mkrelease.sh
|
116
|
+
- ext/shp/shapelib/safileio.c
|
117
|
+
- ext/shp/shapelib/shapefil.h
|
118
|
+
- ext/shp/shapelib/shapelib.def
|
119
|
+
- ext/shp/shapelib/shpadd.c
|
120
|
+
- ext/shp/shapelib/shpcreate.c
|
121
|
+
- ext/shp/shapelib/shpdump.c
|
122
|
+
- ext/shp/shapelib/shpopen.c
|
123
|
+
- ext/shp/shapelib/shprewind.c
|
124
|
+
- ext/shp/shapelib/shptest.c
|
125
|
+
- ext/shp/shapelib/shptree.c
|
126
|
+
- ext/shp/shapelib/shptreedump.c
|
127
|
+
- ext/shp/shapelib/shputils.c
|
128
|
+
- ext/shp/shapelib/stream1.out
|
129
|
+
- ext/shp/shapelib/stream1.sh
|
130
|
+
- ext/shp/shapelib/stream2.out
|
131
|
+
- ext/shp/shapelib/stream2.sh
|
132
|
+
- ext/shp/shapelib/stream3.out
|
133
|
+
- ext/shp/shapelib/web/.cvsignore
|
134
|
+
- ext/shp/shapelib/web/codepage.html
|
135
|
+
- ext/shp/shapelib/web/dbf_api.html
|
136
|
+
- ext/shp/shapelib/web/index.html
|
137
|
+
- ext/shp/shapelib/web/license.html
|
138
|
+
- ext/shp/shapelib/web/manifest.html
|
139
|
+
- ext/shp/shapelib/web/release.html
|
140
|
+
- ext/shp/shapelib/web/shapelib-tools.html
|
141
|
+
- ext/shp/shapelib/web/shp_api.html
|
142
|
+
- ext/shp/shp.cpp
|
143
|
+
- ext/shp/shp.hpp
|
144
|
+
- lib/shp.rb
|
145
|
+
- lib/shp/version.rb
|
146
|
+
- shp.gemspec
|
147
|
+
- spec/shp_spec.rb
|
148
|
+
homepage: https://github.com/spatialnetworks/shp-ruby
|
149
|
+
licenses:
|
150
|
+
- BSD
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
- ext
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.1.5
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: ESRI Shapefile bindings for ruby using shapelib. Currently contains native
|
173
|
+
extensions for ShapeLib 1.3
|
174
|
+
test_files:
|
175
|
+
- spec/shp_spec.rb
|
176
|
+
has_rdoc:
|