Class: Proj::PjObject
- Inherits:
-
Object
- Object
- Proj::PjObject
- Defined in:
- lib/pj_object.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #accuracy ⇒ Object
- #auth(index = 0) ⇒ Object
- #auth_code(index = 0) ⇒ Object
- #auth_name(index = 0) ⇒ Object
- #context ⇒ Object
- #definition ⇒ Object
- #description ⇒ Object
- #has_inverse? ⇒ Boolean
- #id ⇒ Object
- #info ⇒ Object
-
#initialize(pointer, context = nil) ⇒ PjObject
constructor
A new instance of PjObject.
- #name ⇒ Object
- #proj_type ⇒ Object
- #to_json ⇒ Object
- #to_proj_string(string_type = :PJ_PROJ_4) ⇒ Object
- #to_ptr ⇒ Object
- #to_wkt(wkt_type = :PJ_WKT2_2018) ⇒ Object
Constructor Details
#initialize(pointer, context = nil) ⇒ PjObject
Returns a new instance of PjObject.
10 11 12 13 14 |
# File 'lib/pj_object.rb', line 10 def initialize(pointer, context=nil) @pointer = pointer @context = context ObjectSpace.define_finalizer(self, self.class.finalize(@pointer)) end |
Class Method Details
.finalize(pointer) ⇒ Object
4 5 6 7 8 |
# File 'lib/pj_object.rb', line 4 def self.finalize(pointer) proc do Api.proj_destroy(pointer) end end |
Instance Method Details
#accuracy ⇒ Object
64 65 66 |
# File 'lib/pj_object.rb', line 64 def accuracy self.info[:accuracy] end |
#auth(index = 0) ⇒ Object
48 49 50 |
# File 'lib/pj_object.rb', line 48 def auth(index=0) "#{self.auth_name(index)}:#{self.auth_code(index)}" end |
#auth_code(index = 0) ⇒ Object
44 45 46 |
# File 'lib/pj_object.rb', line 44 def auth_code(index=0) Api.proj_get_id_code(self, index) end |
#auth_name(index = 0) ⇒ Object
40 41 42 |
# File 'lib/pj_object.rb', line 40 def auth_name(index=0) Api.proj_get_id_auth_name(self, index).force_encoding('UTF-8') end |
#context ⇒ Object
20 21 22 |
# File 'lib/pj_object.rb', line 20 def context @context || Context.current end |
#definition ⇒ Object
56 57 58 |
# File 'lib/pj_object.rb', line 56 def definition self.info[:definition] ? self.info[:definition].force_encoding('UTF-8') : nil end |
#description ⇒ Object
52 53 54 |
# File 'lib/pj_object.rb', line 52 def description self.info[:description] ? self.info[:description].force_encoding('UTF-8') : nil end |
#has_inverse? ⇒ Boolean
60 61 62 |
# File 'lib/pj_object.rb', line 60 def has_inverse? self.info[:has_inverse] == 1 ? true : false end |
#id ⇒ Object
32 33 34 |
# File 'lib/pj_object.rb', line 32 def id self.info[:id] end |
#info ⇒ Object
28 29 30 |
# File 'lib/pj_object.rb', line 28 def info Api.proj_pj_info(self) end |
#name ⇒ Object
36 37 38 |
# File 'lib/pj_object.rb', line 36 def name Api.proj_get_name(self).force_encoding('UTF-8') end |
#proj_type ⇒ Object
24 25 26 |
# File 'lib/pj_object.rb', line 24 def proj_type Api.proj_get_type(self) end |
#to_json ⇒ Object
72 73 74 |
# File 'lib/pj_object.rb', line 72 def to_json Api.proj_as_projjson(self.context, self, nil).force_encoding('UTF-8') end |
#to_proj_string(string_type = :PJ_PROJ_4) ⇒ Object
68 69 70 |
# File 'lib/pj_object.rb', line 68 def to_proj_string(string_type=:PJ_PROJ_4) Api.proj_as_proj_string(self.context, self, string_type, nil).force_encoding('UTF-8') end |
#to_ptr ⇒ Object
16 17 18 |
# File 'lib/pj_object.rb', line 16 def to_ptr @pointer end |
#to_wkt(wkt_type = :PJ_WKT2_2018) ⇒ Object
76 77 78 |
# File 'lib/pj_object.rb', line 76 def to_wkt(wkt_type=:PJ_WKT2_2018) Api.proj_as_wkt(self.context, self, wkt_type, nil).force_encoding('UTF-8') end |