proj4rb 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +26 -15
- data/README.rdoc +82 -44
- data/Rakefile +27 -27
- data/lib/api/api.rb +96 -118
- data/lib/api/api_5_0.rb +331 -300
- data/lib/api/api_5_1.rb +6 -6
- data/lib/api/api_5_2.rb +4 -4
- data/lib/api/api_6_0.rb +116 -14
- data/lib/api/api_6_1.rb +4 -4
- data/lib/api/api_6_2.rb +9 -6
- data/lib/api/api_6_3.rb +6 -0
- data/lib/api/api_7_0.rb +68 -0
- data/lib/api/api_7_1.rb +73 -0
- data/lib/api/api_7_2.rb +14 -0
- data/lib/api/api_8_0.rb +6 -0
- data/lib/api/api_8_1.rb +24 -0
- data/lib/api/api_8_2.rb +6 -0
- data/lib/api/api_9_1.rb +7 -0
- data/lib/api/api_9_2.rb +9 -0
- data/lib/api/api_experimental.rb +196 -0
- data/lib/proj/area.rb +73 -32
- data/lib/proj/axis_info.rb +44 -0
- data/lib/proj/bounds.rb +13 -0
- data/lib/proj/context.rb +174 -28
- data/lib/proj/conversion.rb +92 -0
- data/lib/proj/coordinate.rb +281 -197
- data/lib/proj/coordinate_operation_mixin.rb +381 -0
- data/lib/proj/coordinate_system.rb +137 -0
- data/lib/proj/crs.rb +672 -204
- data/lib/proj/crs_info.rb +47 -0
- data/lib/proj/database.rb +305 -0
- data/lib/proj/datum.rb +32 -0
- data/lib/proj/datum_ensemble.rb +34 -0
- data/lib/proj/ellipsoid.rb +77 -41
- data/lib/proj/error.rb +62 -9
- data/lib/proj/file_api.rb +166 -0
- data/lib/proj/grid.rb +121 -0
- data/lib/proj/grid_cache.rb +64 -0
- data/lib/proj/grid_info.rb +19 -0
- data/lib/proj/network_api.rb +92 -0
- data/lib/proj/operation.rb +42 -42
- data/lib/proj/operation_factory_context.rb +136 -0
- data/lib/proj/parameter.rb +38 -0
- data/lib/proj/parameters.rb +106 -0
- data/lib/proj/pj_object.rb +670 -80
- data/lib/proj/pj_objects.rb +44 -0
- data/lib/proj/prime_meridian.rb +65 -39
- data/lib/proj/projection.rb +698 -207
- data/lib/proj/session.rb +46 -0
- data/lib/proj/strings.rb +32 -0
- data/lib/proj/transformation.rb +101 -60
- data/lib/proj/unit.rb +108 -53
- data/lib/proj.rb +110 -9
- data/proj4rb.gemspec +5 -5
- data/test/abstract_test.rb +23 -1
- data/test/context_test.rb +172 -82
- data/test/conversion_test.rb +368 -0
- data/test/coordinate_system_test.rb +144 -0
- data/test/crs_test.rb +770 -71
- data/test/database_test.rb +360 -0
- data/test/datum_ensemble_test.rb +65 -0
- data/test/datum_test.rb +55 -0
- data/test/ellipsoid_test.rb +64 -18
- data/test/file_api_test.rb +66 -0
- data/test/grid_cache_test.rb +72 -0
- data/test/grid_test.rb +141 -0
- data/test/network_api_test.rb +45 -0
- data/test/operation_factory_context_test.rb +201 -0
- data/test/parameters_test.rb +40 -0
- data/test/pj_object_test.rb +179 -0
- data/test/prime_meridian_test.rb +76 -0
- data/test/proj_test.rb +46 -4
- data/test/projection_test.rb +646 -222
- data/test/session_test.rb +78 -0
- data/test/transformation_test.rb +149 -7
- data/test/unit_test.rb +57 -28
- metadata +51 -13
- data/lib/api/api_4_9.rb +0 -31
- data/lib/proj/config.rb +0 -70
- data/lib/proj/point.rb +0 -72
- data/test/prime_meridians_test.rb +0 -33
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Proj
|
3
|
+
class PjObjects
|
4
|
+
def self.finalize(pointer)
|
5
|
+
proc do
|
6
|
+
Api.proj_list_destroy(pointer)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(pointer, context)
|
11
|
+
@pointer = pointer
|
12
|
+
@context = context
|
13
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_ptr
|
17
|
+
@pointer
|
18
|
+
end
|
19
|
+
|
20
|
+
def context
|
21
|
+
@context || Context.current
|
22
|
+
end
|
23
|
+
|
24
|
+
def count
|
25
|
+
Api.proj_list_get_count(self)
|
26
|
+
end
|
27
|
+
alias :size :count
|
28
|
+
|
29
|
+
def [](index)
|
30
|
+
ptr = Api.proj_list_get(context, self, index)
|
31
|
+
PjObject.create_object(ptr, self.context)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the index of the operation that would be the most appropriate to transform the specified coordinates.
|
35
|
+
#
|
36
|
+
# @param direction [PJ_DIRECTION] - Direction into which to transform the point.
|
37
|
+
# @param coord [Coordinate] - Coordinate to transform
|
38
|
+
#
|
39
|
+
# @return [Integer] - Index of operation
|
40
|
+
def suggested_operation(direction, coord)
|
41
|
+
Api.proj_get_suggested_operation(self.context, self, direction, coord)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/proj/prime_meridian.rb
CHANGED
@@ -1,40 +1,66 @@
|
|
1
|
-
module Proj
|
2
|
-
class PrimeMeridian
|
3
|
-
|
4
|
-
|
5
|
-
def self.
|
6
|
-
pointer_to_array = FFI::Pointer.new(Api::PJ_PRIME_MERIDIANS, Api.proj_list_prime_meridians)
|
7
|
-
result = Array.new
|
8
|
-
0.step do |i|
|
9
|
-
prime_meridian_info = Api::PJ_PRIME_MERIDIANS.new(pointer_to_array[i])
|
10
|
-
break result if prime_meridian_info[:id].nil?
|
11
|
-
result <<
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
1
|
+
module Proj
|
2
|
+
class PrimeMeridian < PjObject
|
3
|
+
# Returns a list of Prime Meridians that are built into Proj. A more comprehensive
|
4
|
+
# list is stored in the Proj database and can be queried via PjObject#create_from_database
|
5
|
+
def self.built_in
|
6
|
+
pointer_to_array = FFI::Pointer.new(Api::PJ_PRIME_MERIDIANS, Api.proj_list_prime_meridians)
|
7
|
+
result = Array.new
|
8
|
+
0.step do |i|
|
9
|
+
prime_meridian_info = Api::PJ_PRIME_MERIDIANS.new(pointer_to_array[i])
|
10
|
+
break result if prime_meridian_info[:id].nil?
|
11
|
+
result << prime_meridian_info
|
12
|
+
end
|
13
|
+
result
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns prime meridian parameters
|
17
|
+
#
|
18
|
+
# @see https://proj.org/development/reference/functions.html#c.proj_prime_meridian_get_parameters
|
19
|
+
#
|
20
|
+
# @return [Hash] Hash of ellipsoid parameters. Axes are in meters
|
21
|
+
def parameters
|
22
|
+
@parameters ||= begin
|
23
|
+
out_longitude = FFI::MemoryPointer.new(:double)
|
24
|
+
out_unit_conv_factor = FFI::MemoryPointer.new(:double)
|
25
|
+
out_unit_name = FFI::MemoryPointer.new(:string)
|
26
|
+
|
27
|
+
result = Api.proj_prime_meridian_get_parameters(self.context, self, out_longitude, out_unit_conv_factor, out_unit_name)
|
28
|
+
|
29
|
+
if result != 1
|
30
|
+
Error.check_object(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
{longitude: out_longitude.read_double,
|
34
|
+
unit_conv_factor: out_unit_conv_factor.read_double,
|
35
|
+
unit_name: out_unit_name.read_pointer.read_string_to_null}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the longitude of the prime meridian in its native unit
|
40
|
+
#
|
41
|
+
# @see https://proj.org/development/reference/functions.html#c.proj_prime_meridian_get_parameters
|
42
|
+
#
|
43
|
+
# @return [Double]
|
44
|
+
def longitude
|
45
|
+
self.parameters[:longitude]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the conversion factor of the prime meridian longitude unit to radians
|
49
|
+
#
|
50
|
+
# @see https://proj.org/development/reference/functions.html#c.proj_prime_meridian_get_parameters
|
51
|
+
#
|
52
|
+
# @return [Double]
|
53
|
+
def unit_conv_factor
|
54
|
+
self.parameters[:unit_conv_factor]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the unit name
|
58
|
+
#
|
59
|
+
# @see https://proj.org/development/reference/functions.html#c.proj_prime_meridian_get_parameters
|
60
|
+
#
|
61
|
+
# @return [String ]
|
62
|
+
def unit_name
|
63
|
+
self.parameters[:unit_name]
|
64
|
+
end
|
65
|
+
end
|
40
66
|
end
|