ffi-proj4 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,53 @@
1
+ ## NAD83 / BC Albers (this has been superceeded but is kept for compatibility)
2
+ <42102> +proj=aea +ellps=GRS80 +lat_0=45 +lon_0=-126.0 +lat_1=50.0 +lat_2=58.5 +x_0=1000000.0 +y_0=0 +datum=NAD83 +units=m no_defs <>
3
+
4
+
5
+ #
6
+ # OGC-defined extended codes (41000--41999)
7
+ # see http://www.digitalearth.gov/wmt/auto.html
8
+ #
9
+ # WGS84 / Simple Mercator
10
+ <41001> +proj=merc +lat_ts=0 +lon_0=0 +k=1.000000 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs no_defs <>
11
+ #
12
+ # CubeWerx-defined extended codes (42100--42199)
13
+ #
14
+ # WGS 84 / LCC Canada
15
+ <42101> +proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95 +x_0=0 +y_0=-8000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs no_defs <>
16
+ #EPSG:42102,"PROJCS[\"NAD83 / BC Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Decimal_Degree\",0.0174532925199433]],PROJECTION[\"Albers_conic_equal_area\"],PARAMETER[\"central_meridian\",-126.0],PARAMETER[\"latitude_of_origin\",45],PARAMETER[\"standard_parallel_1\",50.0],PARAMETER[\"standard_parallel_2\",58.5],PARAMETER[\"false_easting\",1000000.0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]"
17
+ # WGS 84 / LCC USA
18
+ <42103> +proj=lcc +lat_1=33 +lat_2=45 +lat_0=0 +lon_0=-100 +x_0=0 +y_0=0 +ellps=WGS72 +datum=WGS84 +units=m +no_defs no_defs <>
19
+ # NAD83 / MTM zone 8 Québec
20
+ <42104> +proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.999900 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m +no_defs no_defs <>
21
+ # WGS84 / Merc NorthAm
22
+ <42105> +proj=merc +lat_ts=0 +lon_0=-96 +k=1.000000 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs no_defs <>
23
+ # WGS84 / Lambert Azim Mozambique
24
+ <42106> +proj=laea +lat_0=5 +lon_0=20 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +datum=WGS84 +units=m +no_defs no_defs <>
25
+ #
26
+ # CubeWerx-customer definitions (42300--42399)
27
+ #
28
+ # NAD27 / Polar Stereographic / CM=-98
29
+ <42301> +proj=stere +lat_0=90 +lon_0=-98 +x_0=0 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m +no_defs no_defs <>
30
+ # JapanOrtho.09 09
31
+ <42302> +proj=tmerc +lat_0=36 +lon_0=139.833333333333 +k=0.999900 +x_0=0 +y_0=0 +ellps=bessel +units=m +no_defs no_defs <>
32
+ # NAD83 / Albers NorthAm
33
+ <42303> +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs no_defs <>
34
+ # NAD83 / NRCan LCC Canada
35
+ <42304> +proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs no_defs <>
36
+ # France_II
37
+ <42305> +proj=lcc +lat_1=45.898918964419 +lat_2=47.696014502038 +lat_0=46.8 +lon_0=2.337229166666667 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356514.999904194 +pm=2.337229166666667 +units=m +no_defs no_defs <>
38
+ # NAD83/QC_LCC
39
+ <42306> +proj=lcc +lat_1=46 +lat_2=60 +lat_0=44 +lon_0=-68.5 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs no_defs <>
40
+ # NAD83 / Texas Central - feet
41
+ <42307> +proj=lcc +lat_1=31.8833333333333 +lat_2=30.1166666666667 +lat_0=29.6666666666667 +lon_0=-100.333333333333 +x_0=700000.0000000001 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs no_defs <>
42
+ # NAD27 / California Albers
43
+ <42308> +proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m +no_defs no_defs <>
44
+ # NAD 83 / LCC Canada AVHRR-2
45
+ <42309> +proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs no_defs <>
46
+ # WGS84+GRS80 / Mercator
47
+ <42310> +proj=merc +lat_ts=0 +lon_0=0 +k=1.000000 +x_0=0 +y_0=0 +ellps=GRS80 +datum=WGS84 +units=m +no_defs no_defs <>
48
+ # NAD83 / LCC Statcan
49
+ <42311> +proj=lcc +lat_1=49 +lat_2=77 +lat_0=63.390675 +lon_0=-91.86666700000001 +x_0=6200000 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs no_defs <>
50
+ #
51
+ # Funny epsgish code for google mercator - you should really use EPSG:3857
52
+ #
53
+ <900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs <>
@@ -0,0 +1,17 @@
1
+ # Projection library defaults file
2
+ # SCCSID--- @(#)proj_def.dat 4.3 94/02/23 GIE REL"
3
+ # very preliminary version
4
+ <general>
5
+ ellps=WGS84
6
+ <>
7
+ <aea> # Conterminous U.S. map
8
+ lat_1=29.5
9
+ lat_2=45.5
10
+ <>
11
+ <lcc> # Conterminous U.S. map
12
+ lat_1=33
13
+ lat_2=45
14
+ <>
15
+ <lagrng>
16
+ W=2
17
+ <>
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,212 @@
1
+ # SCCSID @(#)world 1.2 95/08/05 GIE REL
2
+ # proj +init files for various non-U.S. coordinate systems.
3
+ #
4
+ <CH1903> # Swiss Coordinate System
5
+ +proj=somerc +lat_0=46d57'8.660"N +lon_0=7d26'22.500"E
6
+ +ellps=bessel +x_0=600000 +y_0=200000
7
+ +k_0=1. no_defs <>
8
+ <madagascar> # Laborde grid for Madagascar
9
+ proj=labrd ellps=intl lon_0=46d26'13.95E lat_0=18d54S
10
+ azi=18d54 k_0=.9995 x_0=400000 y_0=800000
11
+ no_defs <>
12
+ <new_zealand> # New Zealand Map Grid (NZMG)
13
+ proj=nzmg # Projection unique to N.Z. so all factors fixed
14
+ no_defs <>
15
+ # Secondary grids DMA TM8358.1, p. 4.3
16
+ <bwi> # British West Indies
17
+ proj=tmerc ellps=clrk80 lon_0=62W
18
+ x_0=400000 k_0=0.9995
19
+ no_defs <>
20
+ <costa-n> # Costa Rica Norte
21
+ proj=lcc ellps=clrk66 lat_1=10d28N lon_0=84d20W
22
+ x_0=500000 y_0=217820.522 k_0=0.99995696
23
+ no_defs <>
24
+ <costa-s> # Costa Rica Sud
25
+ proj=lcc ellps=clrk66 lat_1=9dN lon_0=83d40W
26
+ x_0=500000 y_0=327987.436 k_0=0.99995696
27
+ no_defs <>
28
+ <cuba-n> # Cuba Norte
29
+ proj=lcc ellps=clrk66 lat_1=22d21N lon_0=81dW
30
+ x_0=500000 y_0=280296.016 k_0=0.99993602
31
+ no_defs <>
32
+ <cuba-s> # Cuba Sud
33
+ proj=lcc ellps=clrk66 lat_1=20d43'N lon_0=76d50'W
34
+ x_0=500000 y_0=229126.939 k_0=0.99994848
35
+ no_defs <>
36
+ <domin_rep> # Dominican Republic
37
+ proj=lcc ellps=clrk66 lat_1=18d49'N lon_0=71d30'W
38
+ x_0=500000 y_0=277063.657 k_0=0.99991102
39
+ no_defs <>
40
+ <egypt-1> # Egypt
41
+ proj=tmerc ellps=intl lon_0=25d30'E x_0=300000 k_0=0.99985
42
+ no_defs <>
43
+ <egypt-2> # Egypt
44
+ proj=tmerc ellps=intl lon_0=28d30'E x_0=300000 k_0=0.99985
45
+ no_defs <>
46
+ <egypt-3> # Egypt
47
+ proj=tmerc ellps=intl lon_0=31d30'E x_0=300000 k_0=0.99985
48
+ no_defs <>
49
+ <egypt-4> # Egypt
50
+ proj=tmerc ellps=intl lon_0=34d30'E x_0=300000 k_0=0.99985
51
+ no_defs <>
52
+ <egypt-5> # Egypt
53
+ proj=tmerc ellps=intl lon_0=37d30'E x_0=300000 k_0=0.99985
54
+ no_defs <>
55
+ <el_sal> # El Salvador
56
+ proj=lcc ellps=clrk66 lat_1=13d47'N lon_0=89dW
57
+ x_0=500000 y_0=295809.184 k_0=0.99996704
58
+ no_defs <>
59
+ <guat-n> # Guatemala Norte
60
+ proj=lcc ellps=clrk66 lat_1=16d49'N lon_0=90d20'W
61
+ x_0=500000 y_0=292209.579 k_0=0.99992226
62
+ no_defs <>
63
+ <guat-s> # Guatemala Sud
64
+ proj=lcc ellps=clrk66 lat_1=14d54'N lon_0=90d20'W
65
+ x_0=500000 y_0=325992.681 k_0=0.99989906
66
+ no_defs <>
67
+ <haiti> # Haiti
68
+ proj=lcc ellps=clrk66 lat_1=18d49'N lon_0=71d30'W
69
+ x_0=500000 y_0=277063.657 k_0=0.99991102
70
+ no_defs <>
71
+ <hond-n> # Honduras Norte
72
+ proj=lcc ellps=clrk66 lat_1=15d30'N lon_0=86d10'W
73
+ x_0=500000 y_0=296917.439 k_0=0.99993273
74
+ no_defs <>
75
+ <hond-s> # Honduras Sud
76
+ proj=lcc ellps=clrk66 lat_1=13d47'N lon_0=87d10'W
77
+ x_0=500000 y_0=296215.903 k_0=0.99995140
78
+ no_defs <>
79
+ <levant> # Levant
80
+ proj=lcc ellps=clrk66 lat_1=34d39'N lon_0=37d21'E
81
+ x_0=500000 y_0=300000 k_0=0.9996256
82
+ no_defs <>
83
+ <nica-n> # Nicaragua Norte
84
+ proj=lcc ellps=clrk66 lat_1=13d52'N lon_0=85d30'W
85
+ x_0=500000 y_0=359891.816 k_0=0.99990314
86
+ no_defs <>
87
+ <nica-s> # Nicaragua Sud
88
+ proj=lcc ellps=clrk66 lat_1=11d40'N lon_0=85d30'W
89
+ x_0=500000 y_0=288876.327 k_0=0.99992228
90
+ no_defs <>
91
+ <nw-africa> # Northwest Africa
92
+ proj=lcc ellps=clrk80 lat_1=34dN lon_0=0dE
93
+ x_0=1000000 y_0=500000 k_0=0.99908
94
+ no_defs <>
95
+ <palestine> # Palestine
96
+ proj=tmerc a=6378300.79 rf=293.488307656
97
+ lat_0=31d44'2.749"N lon_0=35d12'43.490"E
98
+ x_0=170251.555 y_0=126867.909 k_0=1
99
+ no_defs <>
100
+ <panama> # Panama
101
+ proj=lcc ellps=clrk66 lat_1=8d25'N lon_0=80dW
102
+ x_0=500000 y_0=294865.303 k_0=0.99989909
103
+ no_defs <>
104
+ # other grids in DMA TM8358.1
105
+ <bng> # British National Grid
106
+ proj=tmerc ellps=airy lat_0=49dN lon_0=2dW
107
+ k_0=0.9996012717 x_0=400000 y_0=-100000
108
+ no_defs <>
109
+ <malay> # West Malaysian RSO Grid
110
+ proj=omerc a=6377295.66402 rf=300.8017 alpha=323d01'32.846"
111
+ no_uoff rot_conv lonc=102d15E lat_0=4dN k_0=0.99984 x_0=804670.240 y_0=0
112
+ no_defs <>
113
+ <india-I> # India Zone I
114
+ proj=lcc ellps=everest lon_0=68E lat_1=32d30'N
115
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
116
+ no_defs <>
117
+ <india-IIA> # India Zone IIA
118
+ proj=lcc ellps=everest lon_0=74E lat_1=26N
119
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
120
+ no_defs <>
121
+ <india-IIB> # India Zone IIB
122
+ proj=lcc ellps=everest lon_0=90E lat_1=26N
123
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
124
+ no_defs <>
125
+ <india-IIIA> # India Zone IIIA
126
+ proj=lcc ellps=everest lon_0=80E lat_1=19N
127
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
128
+ no_defs <>
129
+ <india-IIIB> # India Zone IIIB
130
+ proj=lcc ellps=everest lon_0=100E lat_1=19N
131
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
132
+ no_defs <>
133
+ <india-IVA> # India Zone IVA
134
+ proj=lcc ellps=everest lon_0=80E lat_1=12N
135
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
136
+ no_defs <>
137
+ <india-IVB> # India Zone IVB
138
+ proj=lcc ellps=everest lon_0=104E lat_1=12N
139
+ x_0=2743185.69 y_0=914395.23 k_0=.998786408
140
+ no_defs <>
141
+ <ceylon> # Ceylon Belt
142
+ proj=tmerc ellps=everest lon_0=80d46'18.160"E lat_0=7d0'1.729"N
143
+ x_0=160933.56048 y_0=160933.56048 k_0=1.
144
+ no_defs <>
145
+ <irish> # Irish Transverse Mercator Grid
146
+ proj=tmerc ellps=mod_airy lat_0=53d30'N lon_0=8W
147
+ x_0=200000 y_0=250000 k_0=1.000035
148
+ no_defs <>
149
+ <neiez> # Netherlands East Indies Equitorial Zone
150
+ proj=merc ellps=bessel lon_0=110E
151
+ x_0=3900000 y_0=900000 k_0=0.997
152
+ no_defs <>
153
+ <n-alger> # Nord Algerie Grid
154
+ proj=lcc ellps=clrk80 lon_0=2d42E lat_0=36N
155
+ x_0=500000 y_0=300000 k_0=0.999625544
156
+ no_defs <>
157
+ <n-maroc> # Nord Maroc Grid
158
+ proj=lcc ellps=clrk80 lon_0=5d24'W lat_0=33d18'N
159
+ x_0=500000 y_0=300000 k_0=0.999625769
160
+ no_defs <>
161
+ <n-tunis> # Nord Tunisie Grid
162
+ proj=lcc ellps=clrk80 lon_0=9d54E lat_0=36N
163
+ x_0=500000 y_0=300000 k_0=0.999625544
164
+ no_defs <>
165
+ <s-alger> # Sud Algerie Grid
166
+ proj=lcc ellps=clrk80 lon_0=2d42E lat_0=33d18'N
167
+ x_0=500000 y_0=300000 k_0=0.999625769
168
+ no_defs <>
169
+ <s-maroc> # Sud Maroc Grid
170
+ proj=lcc ellps=clrk80 lon_0=5d24W lat_0=29d42'N
171
+ x_0=500000 y_0=300000 k_0=0.999615596
172
+ no_defs <>
173
+ <s-tunis> # Sud Tunisie Grid
174
+ proj=lcc ellps=clrk80 lon_0=9d54'E lat_0=33d18'N
175
+ x_0=500000 y_0=300000 k_0=0.999625769
176
+ no_defs <>
177
+ # Gauss Krueger Grid for Germany
178
+ #
179
+ # The first figure of the easting is lon_0 devided by 3
180
+ # ( 2 for 6d0E, 3 for 9d0E, 4 for 12d0E)
181
+ # For translations you have to remove this first figure
182
+ # and convert northings and eastings from km to meter .
183
+ # The other way round, devide by 1000 and add the figure.
184
+ # I made 3 entrys for the officially used grids in Germany
185
+ #
186
+ #
187
+ # Und nochmal in deutsch :
188
+ # Die erste Ziffer des Rechtswerts beschreibt den Hauptmeridian
189
+ # und ist dessen Gradzahl geteilt durch 3.
190
+ # Zum Umrechnen in Grad muss daher die erste Ziffer des Rechtswertes
191
+ # entfernt werden und evt. von km auf Metern umgerechnet werden.
192
+ # Zur Umrechnung in Gauss Krueger Koordinaten entsprechend die
193
+ # Ziffer fuer den Hauptmeridian vor dem Rechtswert ergaenzen.
194
+ # Ich hab fuer alle drei in Deutschland ueblichen Hauptmeridiane
195
+ # jeweils einen Eintrag ergaenzt.
196
+ #
197
+ #
198
+ # added by Michael Goepel <goepel@ffm.plusline.de>
199
+ #
200
+ <gk2-d> # Gauss Krueger Grid for Germany
201
+ proj=tmerc ellps=bessel lon_0=6d0E lat_0=0
202
+ x_0=500000
203
+ no_defs<>
204
+ <gk3-d> # Gauss Krueger Grid for Germany
205
+ proj=tmerc ellps=bessel lon_0=9d0E lat_0=0
206
+ x_0=500000
207
+ no_defs<>
208
+ <gk4-d> # Gauss Krueger Grid for Germany
209
+ proj=tmerc ellps=bessel lon_0=12d0E lat_0=0
210
+ x_0=500000
211
+ no_defs<>
212
+
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/ffi-proj4/version', __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ffi-proj4"
7
+ s.version = Proj4::VERSION
8
+
9
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.authors = ["J Smith"]
11
+ s.description = "An ffi wrapper for the PROJ.4 Cartographic Projections library."
12
+ s.summary = s.description
13
+ s.email = "dark.panda@gmail.com"
14
+ s.license = "MIT"
15
+ s.files = `git ls-files`.split($\)
16
+ s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.homepage = "http://github.com/dark-panda/ffi-proj4"
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency("ffi", [">= 1.0.0"])
22
+ end
23
+
@@ -0,0 +1,164 @@
1
+
2
+ require 'rubygems'
3
+ require 'ffi'
4
+ require 'rbconfig'
5
+ require 'ffi-proj4/version'
6
+ require 'ffi-proj4/error'
7
+
8
+ #ENV['PROJ_LIB'] = File.join(File.dirname(__FILE__), %w{ .. data }) unless ENV['PROJ_LIB']
9
+ #p ENV['PROJ_LIB']
10
+
11
+ module Proj4
12
+ PROJ4_BASE = File.join(File.dirname(__FILE__), 'ffi-proj4')
13
+
14
+ autoload :Projection,
15
+ File.join(PROJ4_BASE, 'projection')
16
+ autoload :ProjXY,
17
+ File.join(PROJ4_BASE, 'projxy')
18
+ autoload :Tools,
19
+ File.join(PROJ4_BASE, 'tools')
20
+ autoload :Point,
21
+ File.join(PROJ4_BASE, 'point')
22
+
23
+ module FFIProj4
24
+ def self.proj4_library_path
25
+ return @proj4_library_path if defined?(@proj4_library_path)
26
+
27
+ lib = if FFI::Platform::IS_WINDOWS
28
+ # For MinGW and the official binaries
29
+ '{libproj-?,proj}.dll'
30
+ else
31
+ "libproj.#{FFI::Platform::LIBSUFFIX}"
32
+ end
33
+
34
+ paths = if ENV['PROJ4_LIBRARY_PATH']
35
+ [ ENV['PROJ4_LIBRARY_PATH'] ]
36
+ elsif FFI::Platform::IS_WINDOWS
37
+ ENV['PATH'].split(File::PATH_SEPARATOR)
38
+ else
39
+ [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu' ]
40
+ end
41
+
42
+ @proj4_library_path = Dir.glob(paths.collect { |path|
43
+ File.expand_path(File.join(path, lib))
44
+ }).first
45
+ end
46
+
47
+ extend ::FFI::Library
48
+
49
+ ffi_lib(*proj4_library_path)
50
+
51
+ FFI_LAYOUT = {
52
+ :pj_get_release => [
53
+ :string
54
+ ],
55
+
56
+ :pj_init_plus => [
57
+ :pointer, :string
58
+ ],
59
+
60
+ :pj_free => [
61
+ :void, :pointer
62
+ ],
63
+
64
+ :pj_is_latlong => [
65
+ :int, :pointer
66
+ ],
67
+
68
+ :pj_is_geocent => [
69
+ :int, :pointer
70
+ ],
71
+
72
+ :pj_get_def => [
73
+ :string, :pointer, :int
74
+ ],
75
+
76
+ :pj_latlong_from_proj => [
77
+ :pointer, :pointer
78
+ ],
79
+
80
+ :pj_set_finder => [
81
+ :void, callback([ :string ], :string)
82
+ ],
83
+
84
+ :pj_set_searchpath => [
85
+ :void, :int, :pointer
86
+ ],
87
+
88
+ :pj_deallocate_grids => [
89
+ :void
90
+ ],
91
+
92
+ :pj_strerrno => [
93
+ :string, :int
94
+ ],
95
+
96
+ :pj_get_errno_ref => [
97
+ :pointer
98
+ ],
99
+
100
+ :pj_fwd => [
101
+ Proj4::ProjXY.by_value, Proj4::ProjXY.by_value, :pointer
102
+ ],
103
+
104
+ :pj_inv => [
105
+ Proj4::ProjXY.by_value, Proj4::ProjXY.by_value, :pointer
106
+ ],
107
+
108
+ :pj_transform => [
109
+ :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
110
+ ],
111
+
112
+ :pj_datum_transform => [
113
+ :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
114
+ ],
115
+
116
+ :setenv => [
117
+ :int, :string, :string, :int
118
+ ]
119
+ }
120
+
121
+ FFI_LAYOUT.each do |fun, ary|
122
+ ret = ary.shift
123
+ begin
124
+ self.class_eval do
125
+ attach_function(fun, ary, ret)
126
+ end
127
+ rescue FFI::NotFoundError
128
+ # that's okay
129
+ end
130
+ end
131
+ end
132
+
133
+ class << self
134
+ attr_reader :proj_lib
135
+
136
+ def version
137
+ FFIProj4.pj_get_release
138
+ end
139
+
140
+ def proj_lib=(lib)
141
+ @proj_lib = lib
142
+ if RUBY_PLATFORM == 'java' && FFIProj4.respond_to?(:setenv)
143
+ FFIProj4.setenv('PROJ_LIB', lib, 1)
144
+ else
145
+ ENV['PROJ_LIB'] = lib
146
+ end
147
+ end
148
+ end
149
+
150
+ module Constants
151
+ PROJ4_VERSION = if Proj4.version =~ /Rel\. (\d+)\.(\d+)\.(\d+)/
152
+ "#{$1}#{$2}#{$3}".to_f
153
+ end
154
+
155
+ LIBVERSION = PROJ4_VERSION
156
+
157
+ RAD_TO_DEG = 57.29577951308232
158
+ DEG_TO_RAD = 0.0174532925199432958
159
+ end
160
+
161
+ include Constants
162
+
163
+ self.proj_lib = ENV['PROJ_LIB'] || File.join(File.dirname(__FILE__), %w{ .. data })
164
+ end