Skip to content

Commit

Permalink
PRJ accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
snkashis committed Sep 7, 2014
1 parent f9bd341 commit 28023fb
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit 28023fb

Please sign in to comment.