proj4rb 0.2.0-i486-linux

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ Copyright (c) 2000 Frank Warmerdam
2
+ Copyright (c) 2006 Guilhem Vellut <guilhem.vellut@gmail.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,151 @@
1
+ =Proj4rb
2
+
3
+ This is a Ruby binding for the Proj.4 Carthographic Projection library
4
+ (http://proj.maptools.org), that supports conversions between a very large
5
+ number of geographic coordinate systems and datums.
6
+
7
+ Most functions of the C library are implemented in the Ruby binding. Where
8
+ there is a direct equivalent between C and Ruby, identifiers (like names of
9
+ functions and constants) are the same. But the usage has been changed to
10
+ take advantage of Rubys object-oriented features.
11
+
12
+ ==Operations
13
+ The library can be loaded this way:
14
+ require 'proj4'
15
+ The classes are in the Proj4 module:
16
+ include Proj4
17
+ First you have to create a projection like this:
18
+ proj = Projection.new( :proj => "utm", :zone => "21", :units => "m" )
19
+ (There are several alternative ways of specifying the arguments, see
20
+ the documentation for Proj4::Projection.new for details.)
21
+
22
+ This defines a UTM21 North projection in WGS84. Note that the <tt>proj</tt> /
23
+ <tt>proj.exe</tt> initialization arguments equivalent to the one above would
24
+ be:
25
+ +proj=utm +zone=21 +units=m
26
+
27
+ To use the projection, you have 2 operations: +forward+ and +inverse+.
28
+ +forward+ transforms the point in WGS84 lon/lat (in radians) to the coordinate
29
+ system defined during the creation of the Projection object. +inverse+ does the
30
+ opposite. For example:
31
+
32
+ projected_point = proj.forward(lonlat_point)
33
+ lonlat_point = proj.inverse(projected_point)
34
+
35
+ There is also a +transform+ function which can transform between any two
36
+ projections including datum conversions:
37
+
38
+ point_in_projB = projA.transform(projB, point_in_projA)
39
+
40
+ The +forward+, +inverse+, and +transform+ methods all have an in-place
41
+ equivalent: <tt>forward!</tt>, <tt>inverse!</tt>, and <tt>transform!</tt>
42
+ which projects the given point in place. There are also +forwardDeg+
43
+ and +inverseDeg+ methods which work with longitudes and latitudes in
44
+ degrees rather than radians.
45
+
46
+ For the points you can use an object of the Proj4::Point class. It has
47
+ properties: +x+, +y+, and +z+, which can be set and retrieved. Aliases
48
+ +lon+ and +lat+ for +x+ and +y+, respectively, are available.
49
+ (For backwards compatibility there is also an UV class, but this will go away
50
+ in future versions.) Instead of the Proj4::Point object you can use any other
51
+ objects which responds to the methods +x+ and +y+ (and +z+ for 3D datum
52
+ transformations with the +transform+ method).
53
+
54
+ The methods +forward_all+, +inverse_all+, and +transform_all+ (and their
55
+ in-place versions <tt>forward_all!</tt>, <tt>inverse_all!</tt>, and
56
+ <tt>transform_all!</tt> work just like their simple counterparts, but
57
+ instead of a single point they convert a collection of points in one go.
58
+ They take an array as an argument or any object responding to the
59
+ +each+ method (for the in-place versions) or +each+, +clear+, and
60
+ <tt><<</tt> methods (for the normal version).
61
+
62
+ You are also given 2 constants to convert between degrees and radians:
63
+ +DEG_TO_RAD+ and +RAD_TO_DEG+
64
+
65
+ ==Error handling
66
+ The projection initialization (Proj4::Projection.new) and all projection
67
+ functions (Proj4::Projection#forward/inverse/transform) in their different
68
+ versions throw an exception when there is a problem. There is a catch-all
69
+ exception Proj4::Error and many subclasses of it for all the different errors
70
+ that the Proj.4 C library can return. See Proj4::Error for more information or
71
+ use the <tt>list-errors.rb</tt> program from the examples for a list.
72
+
73
+ ==Definition lists
74
+ Proj.4 knows about many different datums, ellipsoids, prime meridians,
75
+ projection types and length units. The Proj4::Datum, Proj4::Ellipsoid,
76
+ Proj4::PrimeMeridian, Proj4::ProjectionType, and Proj4::Unit classes
77
+ can be used to access those lists and get details about each definition.
78
+ See the <i>list-*</i> files in the <i>example</i> directory for some code
79
+ examples.
80
+
81
+ Note that these lists are only available since the version 449 of the
82
+ Proj.4 C library.
83
+
84
+ ==Installation
85
+ Just install the gem with
86
+ gem install proj4rb
87
+
88
+ ==Compiling
89
+ ===Linux
90
+ To compile the proj4rb Ruby bindings from source you'll need the
91
+ Proj.4 C library installed. Enter the <i>src</i> directory and create
92
+ a Makefile:
93
+ cd src
94
+ ruby extconf.rb
95
+ If there are any problems consult the <i>mkmf.log</i> log file.
96
+ Then compile with
97
+ make
98
+ The result is the file <i>projrb.so</i> which you need to copy into
99
+ the <i>lib</i> directory:
100
+ cp projrb.so ../lib/
101
+
102
+ If you want to, you can now create a gem with
103
+ rake gem
104
+
105
+ This will create a file <tt>proj4rb-<i>version</i>-i486-linux.gem</tt>
106
+ or similar in the <i>pkg</i> directory.
107
+
108
+ ===Mac OS X
109
+ To compile the proj4rb Ruby bindings from source you'll need the
110
+ Proj.4 C library installed. Enter the <i>src</i> directory and create
111
+ a Makefile:
112
+ cd src
113
+ ruby extconf.rb
114
+ If there are any problems consult the <i>mkmf.log</i> log file.
115
+ Then compile with
116
+ make
117
+ The result is the file <i>projrb.bundle</i> which you need to copy into
118
+ the <i>lib</i> directory:
119
+ cp projrb.bundle ../lib/
120
+
121
+ If you want to, you can now create a gem with
122
+ rake gem
123
+
124
+ This will create a file <tt>proj4rb-<i>version</i>-universal-darwin8.0.gem</tt>
125
+ or similar in the <i>pkg</i> directory.
126
+
127
+
128
+ ===Windows
129
+ The result is the file <i>proj.dll</i> which you need to copy into
130
+ the <i>lib</i> directory:
131
+ cp proj.dll ../lib/
132
+
133
+ ==TODO
134
+ - Completely cross-platform build system (mkrf?)
135
+
136
+ ==Changes since the last version
137
+ - Added most functions supported by C library and many tests.
138
+ - Added support for Linux builds.
139
+ - Improved error handling. On error the methods throw exceptions now.
140
+
141
+ ==License
142
+ Proj4rb is released under the MIT license.
143
+
144
+ ==Support
145
+ Any questions, enhancement proposals, bug notifications or corrections can be
146
+ sent to mailto:guilhem.vellut@gmail.com or mailto:jochen@topf.org.
147
+
148
+ ==Authors
149
+ The proj4rb Ruby bindings were created by Guilhelm Vellut with many additions
150
+ by Jochen Topf.
151
+
data/example/basic.rb ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ # create projection object
9
+ proj = Projection.new(["proj=utm", "zone=21", "units=m", "no.defs"])
10
+
11
+ # create the point you want to project
12
+ point = Point.new(45000,2700000)
13
+
14
+ # do the projection
15
+ res = proj.inverse(point)
16
+
17
+ puts "x=#{point.x}, y=#{point.y} ==> lon=#{res.lon}, lat=#{res.lat}"
18
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ if ARGV[0] == '-v'
9
+ puts "%-15s %-10s %-50s" % [ 'ID', 'Ellipse ID', 'Comment' ]
10
+ puts '-----------------------------------------------------------------------------'
11
+ Datum.list.sort.each do |datum|
12
+ puts "%-15s %-10s %-50s\n %s\n " % [ datum.id, datum.ellipse_id, datum.comments, datum.defn ]
13
+ end
14
+ else
15
+ puts Datum.list.sort
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ if ARGV[0] == '-v'
9
+ puts "%-9s %-14s %-18s %-36s" % [ 'ID', 'a', 'b/rf', 'Name' ]
10
+ puts '-----------------------------------------------------------------------------'
11
+ Ellipsoid.list.sort.each do |ell|
12
+ puts "%-9s %-14s %-18s %-36s" % [ ell.id, ell.major, ell.ell, ell.name ]
13
+ end
14
+ else
15
+ puts Ellipsoid.list.sort
16
+ end
17
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ Error.list.collect{ |e| e + 'Error' }.each_with_index do |error, index|
9
+ puts "%2d %s" % [index, error]
10
+ end
11
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ if ARGV[0] == '-v'
9
+ puts "%-16s %-50s" % [ 'ID', 'Definition' ]
10
+ puts '-----------------------------------------------------------------------------'
11
+ PrimeMeridian.list.sort.each do |pm|
12
+ puts "%-16s %-50s" % [ pm.id, pm.defn ]
13
+ end
14
+ else
15
+ puts PrimeMeridian.list.sort
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ if ARGV[0] == '-v'
9
+ puts "%-7s %-70s" % [ 'ID', 'Name/Description' ]
10
+ puts '-----------------------------------------------------------------------------'
11
+ ProjectionType.list.sort.each do |pt|
12
+ puts "%-7s %-70s" % [ pt.id, pt.descr ]
13
+ end
14
+ else
15
+ puts ProjectionType.list
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ if ARGV[0] == '-v'
9
+ puts "%-8s %-20s %-50s" % [ 'ID', 'To meter', 'Name' ]
10
+ puts "------------------------------------------------------------------------------"
11
+ Unit.list.sort.each do |unit|
12
+ puts "%-8s %-20s %-50s" % [ unit.id, unit.to_meter, unit.name ]
13
+ end
14
+ else
15
+ puts Unit.list.sort
16
+ end
17
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
4
+
5
+ require 'proj4'
6
+ include Proj4
7
+
8
+ puts Proj4::LIBVERSION
9
+