Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/rgeo/shapefile/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ def initialize(path_, opts_={}) # :nodoc:
@opened = true
@main_file = ::File.open(path_+'.shp', 'rb:ascii-8bit')
@index_file = ::File.open(path_+'.shx', 'rb:ascii-8bit')

if ::File.file?(path_+'.prj') && ::File.readable?(path_+'.prj')
@prj_file = ::File.open(path_+'.prj', 'rb:ascii-8bit')
else
@prj_file = nil
end

if ::File.file?(path_+'.dbf') && ::File.readable?(path_+'.dbf')
@attr_dbf = ::DBF::Table.new(path_+'.dbf')
else
Expand Down Expand Up @@ -278,6 +285,7 @@ def close
if @opened
@main_file.close
@index_file.close
@prj_file.close if @prj_file
@attr_dbf.close if @attr_dbf
@opened = false
end
Expand Down Expand Up @@ -386,6 +394,10 @@ def mmax
def cur_index
@opened ? @cur_record_index : nil
end

def prj
@opened && @prj_file ? @prj_file.read : nil
end


# Read and return the next record as a Reader::Record.
Expand Down