-
Notifications
You must be signed in to change notification settings - Fork 56
Fixed to work with updated DBF library (last commit Aug 2nd 2018 ca2b… #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ def [](v) | |
end | ||
end | ||
|
||
class Field < Column::Base | ||
class Field < ColumnType::Base | ||
def initialize(name, type, length, decimal = 0, version = 1, enc = nil) | ||
super(name, type, length, decimal, version, enc) | ||
end | ||
|
@@ -33,8 +33,10 @@ def header_length | |
@columns_count | ||
end | ||
|
||
def self.open(f) | ||
new(f) | ||
# Open DBF with specified encoding (it can also be nil and DBF reader | ||
# will use what it finds in header). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/Tab: Tab detected. |
||
def self.open(f, memo = nil, encoding) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/Tab: Tab detected. |
||
new(f, memo, encoding) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/IndentationWidth: Use 2 (not 8) spaces for indentation. |
||
end | ||
|
||
def close | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ class ShpFile | |
|
||
# Opens a SHP file. Both "abc.shp" and "abc" are accepted. | ||
# The files "abc.shp", "abc.shx" and "abc.dbf" must be present | ||
def initialize(file) | ||
def initialize(file, dbf_encoding) | ||
# strip the shp out of the file if present | ||
@file_root = file.gsub(/.shp$/i, '') | ||
# check existence of shp, dbf and shx files | ||
|
@@ -41,7 +41,7 @@ def initialize(file) | |
fail MalformedShpException.new("Missing one of shp, dbf or shx for: #{@file}") | ||
end | ||
|
||
@dbf = Dbf::Reader.open(@file_root + '.dbf') | ||
@dbf = Dbf::Reader.open(@file_root + '.dbf', nil, dbf_encoding) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
@shx = File.open(@file_root + '.shx', 'rb') | ||
@shp = File.open(@file_root + '.shp', 'rb') | ||
read_index | ||
|
@@ -56,8 +56,10 @@ def reload! | |
# opens a SHP "file". If a block is given, the ShpFile object | ||
# is yielded to it and is closed upon return. | ||
# Else a call to <tt>open</tt> is equivalent to <tt>ShpFile.new(...)</tt>. | ||
def self.open(file) | ||
shpfile = ShpFile.new(file) | ||
# You can specify encoding of the table, by default it is not set, maybe | ||
# it should be UTF-8? | ||
def self.open(file, dbf_encoding = nil) | ||
shpfile = ShpFile.new(file, dbf_encoding) | ||
if block_given? | ||
yield shpfile | ||
shpfile.close | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/Tab: Tab detected.