geoscript 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.md +27 -0
  2. data/lib/geoscript.rb +21 -0
  3. data/lib/geoscript/geom.rb +12 -0
  4. data/lib/geoscript/geom/bounds.rb +82 -0
  5. data/lib/geoscript/geom/geom.rb +48 -0
  6. data/lib/geoscript/geom/io/json.rb +15 -0
  7. data/lib/geoscript/geom/io/wkb.rb +27 -0
  8. data/lib/geoscript/geom/io/wkt.rb +16 -0
  9. data/lib/geoscript/geom/linearring.rb +37 -0
  10. data/lib/geoscript/geom/linestring.rb +62 -0
  11. data/lib/geoscript/geom/multilinestring.rb +48 -0
  12. data/lib/geoscript/geom/multipoint.rb +49 -0
  13. data/lib/geoscript/geom/multipolygon.rb +48 -0
  14. data/lib/geoscript/geom/point.rb +34 -0
  15. data/lib/geoscript/geom/polygon.rb +51 -0
  16. data/lib/geoscript/projection.rb +69 -0
  17. data/lib/geoscript/util.rb +1 -0
  18. data/lib/geoscript/util/bytes.rb +43 -0
  19. data/lib/geoscript/version.rb +3 -0
  20. data/lib/geotools/commons-pool-1.5.4.jar +0 -0
  21. data/lib/geotools/gt-api-8.0-RC2.jar +0 -0
  22. data/lib/geotools/gt-coverage-8.0-RC2.jar +0 -0
  23. data/lib/geotools/gt-cql-8.0-RC2.jar +0 -0
  24. data/lib/geotools/gt-epsg-hsql-8.0-RC2.jar +0 -0
  25. data/lib/geotools/gt-geojson-8.0-RC2.jar +0 -0
  26. data/lib/geotools/gt-main-8.0-RC2.jar +0 -0
  27. data/lib/geotools/gt-metadata-8.0-RC2.jar +0 -0
  28. data/lib/geotools/gt-opengis-8.0-RC2.jar +0 -0
  29. data/lib/geotools/gt-property-8.0-RC2.jar +0 -0
  30. data/lib/geotools/gt-referencing-8.0-RC2.jar +0 -0
  31. data/lib/geotools/gt-render-8.0-RC2.jar +0 -0
  32. data/lib/geotools/gt-swing-8.0-RC2.jar +0 -0
  33. data/lib/geotools/hsqldb-1.8.0.7.jar +0 -0
  34. data/lib/geotools/imageio-ext-tiff-1.1.4.jar +0 -0
  35. data/lib/geotools/imageio-ext-utilities-1.1.4.jar +0 -0
  36. data/lib/geotools/jai_codec-1.1.3.jar +0 -0
  37. data/lib/geotools/jai_core-1.1.3.jar +0 -0
  38. data/lib/geotools/jai_imageio-1.1.jar +0 -0
  39. data/lib/geotools/jdom-1.0.jar +0 -0
  40. data/lib/geotools/jgridshift-1.0.jar +0 -0
  41. data/lib/geotools/json-simple-1.1.jar +0 -0
  42. data/lib/geotools/jsr-275-1.0-beta-2.jar +0 -0
  43. data/lib/geotools/jt-utils-1.2.0.jar +0 -0
  44. data/lib/geotools/jt-zonalstats-1.2.0.jar +0 -0
  45. data/lib/geotools/jts-1.12.jar +0 -0
  46. data/lib/geotools/miglayout-3.7-swing.jar +0 -0
  47. data/lib/geotools/vecmath-1.3.2.jar +0 -0
  48. data/lib/geotools/xercesImpl-2.4.0.jar +0 -0
  49. metadata +143 -0
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ geoscript-ruby
2
+
3
+ GeoScript for JRuby
4
+
5
+ ```ruby
6
+ require 'geoscript'
7
+ # => true
8
+ include GeoScript::Geom
9
+ # => Object
10
+
11
+ p = Point.create -111.0, 45.7
12
+ # => #<GeoScript::Geom::Point:0x7f4d4b79 @bounds=#<GeoScript::Geom::Bounds:0x50ecb7c8>>
13
+ p.to_wkt
14
+ # => "POINT (-111.0 45.7)"
15
+
16
+ p2 = GeoScript::Projection.reproject p, 'epsg:4326', 'epsg:26912'
17
+ # => #<Java::ComVividsolutionsJtsGeom::Point:0x2d547681>
18
+ p2.x
19
+ # => 500000.0
20
+ p2.y
21
+ # => 5060716.313515949
22
+
23
+ poly = p2.buffer 100
24
+ # => #<Java::ComVividsolutionsJtsGeom::Polygon:0x157106f7>
25
+ poly.get_area
26
+ # => 31214.451522458345
27
+ ```
data/lib/geoscript.rb ADDED
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path(File.join(File.dirname(__FILE__), 'geoscript'))
2
+
3
+ require 'java'
4
+
5
+ Dir.entries(File.join(File.expand_path(File.dirname(__FILE__)), 'geotools')).sort.each do |entry|
6
+ if entry =~ /.jar$/
7
+ $CLASSPATH << File.join(File.expand_path(File.dirname(__FILE__)), "/geotools/#{entry}")
8
+ end
9
+ end
10
+
11
+ java_import org.geotools.factory.Hints
12
+
13
+ unless java.lang.System.get_property("org.geotools.referencing.forceXY") == "true"
14
+ java.lang.System.set_property "org.geotools.referencing.forceXY", "true"
15
+ end
16
+ Hints.put_system_default Hints::FORCE_LONGITUDE_FIRST_AXIS_ORDER, java.lang.Boolean.new(true)
17
+
18
+ require 'geoscript/version'
19
+ require 'geoscript/util'
20
+ require 'geoscript/projection'
21
+ require 'geoscript/geom'
@@ -0,0 +1,12 @@
1
+ require 'geom/io/json'
2
+ require 'geom/io/wkt'
3
+ require 'geom/io/wkb'
4
+ require 'geom/geom'
5
+ require 'geom/bounds'
6
+ require 'geom/point'
7
+ require 'geom/multipoint'
8
+ require 'geom/linestring'
9
+ require 'geom/multilinestring'
10
+ require 'geom/linearring'
11
+ require 'geom/polygon'
12
+ require 'geom/multipolygon'
@@ -0,0 +1,82 @@
1
+ java_import com.vividsolutions.jts.geom.Envelope
2
+ java_import org.geotools.geometry.jts.ReferencedEnvelope
3
+
4
+ module GeoScript
5
+ module Geom
6
+ class Bounds < ReferencedEnvelope
7
+ include GeoScript::Geom
8
+
9
+ def initialize(*args);end
10
+
11
+ def self.create(env, proj = nil)
12
+ projection = GeoScript::Projection.new proj if proj
13
+
14
+ if env.kind_of? Envelope
15
+ if projection
16
+ bounds = Bounds.new env, projection
17
+ elsif env.respond_to? :crs
18
+ if env.crs
19
+ bounds = Bounds.new env, env.crs
20
+ else
21
+ bounds = Bounds.new env, nil
22
+ end
23
+ else
24
+ bounds = Bounds.new env, nil
25
+ end
26
+ else
27
+ if env.kind_of? Hash
28
+ if projection
29
+ bounds = Bounds.new env[:x_min], env[:x_max], env[:y_min], env[:y_max], projection
30
+ else
31
+ bounds = Bounds.new env[:x_min], env[:x_max], env[:y_min], env[:y_max], nil
32
+ end
33
+ elsif env.kind_of? Array
34
+ if projection
35
+ bounds = Bounds.new env[0], env[1], env[2], env[3], projection
36
+ else
37
+ bounds = Bounds.new env[0], env[1], env[2], env[3]
38
+ end
39
+ else
40
+ bounds = Bounds.new
41
+ end
42
+ end
43
+
44
+ bounds
45
+ end
46
+
47
+ def get_west
48
+ self.min_x
49
+ end
50
+
51
+ def get_south
52
+ self.min_y
53
+ end
54
+
55
+ def get_east
56
+ self.max_x
57
+ end
58
+
59
+ def get_north
60
+ self.max_y
61
+ end
62
+
63
+ def get_projection
64
+ crs = self.coordinate_reference_system
65
+ GeoScript::Projection.new crs if crs
66
+ end
67
+
68
+ def self.scale(bounds, factor)
69
+ width = self.width * (factor - 1) / 2
70
+ height = self.height * (factor - 1) / 2
71
+
72
+ Bounds.new self.west - width, self.south - height, self.east + width, self.north + height
73
+ end
74
+
75
+ def expand(other_bounds);end
76
+
77
+ def to_polygon;end
78
+
79
+ def tile(resolution);end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,48 @@
1
+ java_import java.awt.geom.AffineTransform
2
+ java_import com.vividsolutions.jts.geom.GeometryFactory
3
+ java_import com.vividsolutions.jts.geom.Geometry
4
+ java_import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory
5
+ java_import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier
6
+ java_import com.vividsolutions.jts.triangulate.DelaunayTriangulationBuilder
7
+ java_import com.vividsolutions.jts.triangulate.VoronoiDiagramBuilder
8
+ java_import com.vividsolutions.jts.operation.buffer.BufferParameters
9
+ java_import com.vividsolutions.jts.operation.buffer.BufferOp
10
+ java_import org.geotools.geometry.jts.JTS
11
+ java_import org.geotools.referencing.operation.transform.AffineTransform2D
12
+
13
+ module GeoScript
14
+ module Geom
15
+ GEOM_FACTORY = GeometryFactory.new
16
+ PREP_FACTORY = PreparedGeometryFactory.new
17
+
18
+ def self.prepare(geom)
19
+ PREP_FACTORY.create(geom)
20
+ end
21
+
22
+ def self.simplify(geom, tolerance)
23
+ DouglasPeuckerSimplifier.simplify(geom, tolerance)
24
+ end
25
+
26
+ def self.buffer(geom, distance, single_sided = false)
27
+ buffer_params = BufferParameters.new
28
+ buffer_params.set_single_sided(single_sided)
29
+ BufferOp.buffer_op(geom, distance, buffer_params)
30
+ end
31
+
32
+ def self.get_bounds(geom)
33
+ Bounds.create geom.get_envelope_internal
34
+ end
35
+
36
+ def self.enhance(geom)
37
+ geom.bounds = Geom.get_bounds geom
38
+ end
39
+
40
+ def self.to_wkt(geom)
41
+ GeoScript::Geom::IO.write_wkt geom
42
+ end
43
+
44
+ def self.from_wkt(wkt)
45
+ GeoScript::Geom::IO.read_wkt wkt
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ java_import org.geotools.geojson.geom.GeometryJSON
2
+
3
+ module GeoScript
4
+ module Geom
5
+ module IO
6
+ def self.write_json(geom)
7
+ GeometryJSON.new.to_string geom
8
+ end
9
+
10
+ def self.read_json(json)
11
+ GeometryJSON.new.read json.to_java
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ java_import com.vividsolutions.jts.io.WKBReader
2
+ java_import com.vividsolutions.jts.io.WKBWriter
3
+
4
+ module GeoScript
5
+ module Geom
6
+ module IO
7
+ include GeoScript::Util
8
+
9
+ def self.write_wkb(geom)
10
+ wkb = WKBWriter.new.write geom
11
+ WKBWriter.bytes_to_hex wkb
12
+ end
13
+
14
+ def self.read_wkb(wkb)
15
+ if wkb.kind_of? String
16
+ wkb = WKBReader.hex_to_bytes wkb
17
+ elsif wkb.kind_of? Array
18
+ # .to_java(java.lang.Byte) does not seem to work
19
+ # this is very hacky
20
+ wkb = WKBWriter.bytes_to_hex wkb
21
+ wkb = WKBReader.hex_to_bytes wkb
22
+ end
23
+ WKBReader.new.read wkb
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ java_import com.vividsolutions.jts.io.WKTReader
2
+ java_import com.vividsolutions.jts.io.WKTWriter
3
+
4
+ module GeoScript
5
+ module Geom
6
+ module IO
7
+ def self.read_wkt(wkt)
8
+ WKTReader.new.read wkt
9
+ end
10
+
11
+ def self.write_wkt(geom)
12
+ WKTWriter.new.write geom
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ java_import com.vividsolutions.jts.geom.Coordinate
2
+ JTSLinearRing = com.vividsolutions.jts.geom.LinearRing
3
+
4
+ module GeoScript
5
+ module Geom
6
+ class LinearRing < JTSLinearRing
7
+ include GeoScript::Geom
8
+
9
+ attr_accessor :bounds
10
+
11
+ def initialize(*args);end
12
+
13
+ def self.create(*coords)
14
+ if coords.size == 1
15
+ linear_ring = LinearRing.new coords.first.coordinate_sequence if coords.first.kind_of? LinearRing
16
+ else
17
+ line_string = LineString.create *coords
18
+ linear_ring = LinearRing.new line_string.coordinate_sequence, GEOM_FACTORY
19
+ end
20
+ GeoScript::Geom.enhance linear_ring
21
+ linear_ring
22
+ end
23
+
24
+ def to_wkt
25
+ IO.write_wkt self
26
+ end
27
+
28
+ def to_wkb
29
+ IO.write_wkb self
30
+ end
31
+
32
+ def to_json
33
+ IO.write_json self
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,62 @@
1
+ java_import com.vividsolutions.jts.geom.Coordinate
2
+ JTSLineString = com.vividsolutions.jts.geom.LineString
3
+
4
+ module GeoScript
5
+ module Geom
6
+ class LineString < JTSLineString
7
+ include GeoScript::Geom
8
+
9
+ attr_accessor :bounds
10
+
11
+ def initialize(*args);end
12
+
13
+ def self.create(*coords)
14
+ if coords.size == 1
15
+ if coords.first.kind_of? LineString
16
+ ls = coords.first
17
+ elsif coords.kind_of? Array
18
+ if coords.first.kind_of? Array
19
+ l = []
20
+ coords.first.each do |coord|
21
+ l << Coordinate.new(coord[0], coord[1])
22
+ l.last.z = coord[2] if coord[2]
23
+ end
24
+ if l.size > 0
25
+ ls = GEOM_FACTORY.create_line_string l.to_java(com.vividsolutions.jts.geom.Coordinate)
26
+ end
27
+ end
28
+ end
29
+ else
30
+ l = []
31
+ coords.each do |coord|
32
+ l << Coordinate.new(coord[0], coord[1])
33
+ l.last.z = coord[2] if coord[2]
34
+ end
35
+ if l.size > 0
36
+ ls = GEOM_FACTORY.create_line_string l.to_java(com.vividsolutions.jts.geom.Coordinate)
37
+ end
38
+ end
39
+
40
+ if ls
41
+ line_string = LineString.new ls.coordinate_sequence, GEOM_FACTORY
42
+ GeoScript::Geom.enhance line_string
43
+ line_string
44
+ else
45
+ raise 'LineString could not be created. Check inputs.'
46
+ end
47
+ end
48
+
49
+ def to_wkt
50
+ IO.write_wkt self
51
+ end
52
+
53
+ def to_wkb
54
+ IO.write_wkb self
55
+ end
56
+
57
+ def to_json
58
+ IO.write_json self
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,48 @@
1
+ JTSMultiLineString = com.vividsolutions.jts.geom.MultiLineString
2
+
3
+ module GeoScript
4
+ module Geom
5
+ class MultiLineString < JTSMultiLineString
6
+ include GeoScript::Geom
7
+
8
+ attr_accessor :bounds
9
+
10
+ def initialize(*args);end
11
+
12
+ def self.create(*line_strings)
13
+ strings = []
14
+
15
+ if line_strings.first.kind_of? MultiLineString
16
+ multi_line_string_geom = line_strings.first
17
+ for i in range(0...multi_line_string_geom.num_geometries)
18
+ strings << multi_line_string_geom.get_geometry_n(i)
19
+ end
20
+ else
21
+ line_strings.each do |line_string|
22
+ if line_string.kind_of? LineString
23
+ strings << line_string
24
+ else
25
+ strings << LineString.create(*line_string)
26
+ end
27
+ end
28
+ end
29
+
30
+ multi_line_string = MultiLineString.new strings.to_java(com.vividsolutions.jts.geom.LineString), GEOM_FACTORY
31
+ GeoScript::Geom.enhance multi_line_string
32
+ multi_line_string
33
+ end
34
+
35
+ def to_wkt
36
+ IO.write_wkt self
37
+ end
38
+
39
+ def to_wkb
40
+ IO.write_wkb self
41
+ end
42
+
43
+ def to_json
44
+ IO.write_json self
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,49 @@
1
+ JTSMultiPoint = com.vividsolutions.jts.geom.MultiPoint
2
+
3
+ module GeoScript
4
+ module Geom
5
+ class MultiPoint < JTSMultiPoint
6
+ include GeoScript::Geom
7
+
8
+ attr_accessor :bounds
9
+
10
+ def intitialize(*args);end
11
+
12
+ def self.create(*points)
13
+ feature_points = []
14
+
15
+ if points.first.kind_of? MultiPoint
16
+ multi_point_geom = points.first
17
+
18
+ for i in (0...multi_point_geom.num_geometries)
19
+ feature_points << multi_point_geom.get_geometry_n(i)
20
+ end
21
+ else
22
+ points.each do |point|
23
+ if point.kind_of? Point
24
+ feature_points << point
25
+ else
26
+ feature_points << Point.create(*point)
27
+ end
28
+ end
29
+ end
30
+
31
+ multi_point = MultiPoint.new feature_points.to_java(com.vividsolutions.jts.geom.Point), GEOM_FACTORY
32
+ GeoScript::Geom.enhance multi_point
33
+ multi_point
34
+ end
35
+
36
+ def to_wkt
37
+ IO.write_wkt self
38
+ end
39
+
40
+ def to_wkb
41
+ IO.write_wkb self
42
+ end
43
+
44
+ def to_json
45
+ IO.write_json self
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,48 @@
1
+ JTSMultiPolygon = com.vividsolutions.jts.geom.MultiPolygon
2
+
3
+ module GeoScript
4
+ module Geom
5
+ class MultiPolygon < JTSMultiPolygon
6
+ include GeoScript::Geom
7
+
8
+ attr_accessor :bounds
9
+
10
+ def initialize(*args);end
11
+
12
+ def self.create(*polygons)
13
+ polys = []
14
+
15
+ if polygons.first.kind_of? MultiPolygon
16
+ multi_polygon = polygons.first
17
+ for i in range(0...multi_polygon.num_geometries)
18
+ polys << multi_polygon.get_geometry_n(i)
19
+ end
20
+ else
21
+ polygons.each do |polygon|
22
+ if polygon.kind_of? Polygon
23
+ polys << polygon
24
+ else
25
+ polys << Polygon.create(*polygon)
26
+ end
27
+ end
28
+ end
29
+
30
+ multi_poly = MultiPolygon.new polys.to_java(com.vividsolutions.jts.geom.Polygon), GEOM_FACTORY
31
+ GeoScript::Geom.enhance multi_poly
32
+ multi_poly
33
+ end
34
+
35
+ def to_wkt
36
+ IO.write_wkt self
37
+ end
38
+
39
+ def to_wkb
40
+ IO.write_wkb self
41
+ end
42
+
43
+ def to_json
44
+ IO.write_json self
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,34 @@
1
+ java_import com.vividsolutions.jts.geom.Coordinate
2
+ JTSPoint = com.vividsolutions.jts.geom.Point
3
+
4
+ module GeoScript
5
+ module Geom
6
+ class Point < JTSPoint
7
+ include GeoScript::Geom
8
+
9
+ attr_accessor :bounds
10
+
11
+ def initialize(*args);end
12
+
13
+ def self.create(x, y = nil, z = nil)
14
+ c = Coordinate.new x, y
15
+ p = GEOM_FACTORY.create_point c
16
+ point = Point.new p.coordinate_sequence, GEOM_FACTORY
17
+ GeoScript::Geom.enhance point
18
+ point
19
+ end
20
+
21
+ def to_wkt
22
+ IO.write_wkt self
23
+ end
24
+
25
+ def to_wkb
26
+ IO.write_wkb self
27
+ end
28
+
29
+ def to_json
30
+ IO.write_json self
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,51 @@
1
+ JTSPolygon = com.vividsolutions.jts.geom.Polygon
2
+
3
+ module GeoScript
4
+ module Geom
5
+ class Polygon < JTSPolygon
6
+ include GeoScript::Geom
7
+
8
+ attr_accessor :bounds
9
+
10
+ def initialize(*args);end
11
+
12
+ def self.create(*rings)
13
+ if rings.first.kind_of? Polygon
14
+ interior_rings = []
15
+ num_rings = rings.first.num_interior_ring
16
+ for i in (0...num_rings)
17
+ interior_rings << rings.first.get_interior_ring_n(i)
18
+ end
19
+ poly = Polygon.new rings.first.exterior_ring, interior_rings, GEOM_FACTORY
20
+ else
21
+ linear_rings = []
22
+ rings.each do |ring|
23
+ if ring.kind_of? LinearRing
24
+ linear_rings << ring
25
+ else
26
+ linear_rings << LinearRing.create(*ring)
27
+ end
28
+ end
29
+
30
+ shell = linear_rings.first
31
+ holes = linear_rings[1..linear_rings.size].to_java(com.vividsolutions.jts.geom.LinearRing)
32
+ poly = Polygon.new shell, holes, GEOM_FACTORY
33
+ end
34
+ GeoScript::Geom.enhance poly
35
+ poly
36
+ end
37
+
38
+ def to_wkt
39
+ IO.write_wkt self
40
+ end
41
+
42
+ def to_wkb
43
+ IO.write_wkb self
44
+ end
45
+
46
+ def to_json
47
+ IO.write_json self
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,69 @@
1
+ java_import org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer
2
+ java_import org.geotools.referencing.CRS
3
+ java_import org.opengis.referencing.crs.CoordinateReferenceSystem
4
+ java_import org.geotools.factory.Hints
5
+
6
+ module GeoScript
7
+ class Projection
8
+ attr_accessor :crs
9
+
10
+ def initialize(proj)
11
+ if proj.kind_of? CoordinateReferenceSystem
12
+ @crs = proj
13
+ elsif proj.kind_of? GeoScript::Projection
14
+ @crs = proj.crs
15
+ elsif proj.kind_of? String
16
+ @crs = CRS.decode proj
17
+
18
+ if @crs.nil?
19
+ @crs = CRS.parseWKT proj
20
+
21
+ if @crs.nil?
22
+ raise "Unable to determine projection from #{proj}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def get_id
29
+ CRS.lookup_identifier(@crs, true).to_s
30
+ end
31
+
32
+ def get_wkt
33
+ @crs.to_s
34
+ end
35
+
36
+ def get_bounds
37
+ env = CRS.get_envelope @crs
38
+ if env
39
+ min = env.get_minimum
40
+ max = env.get_maximum
41
+ GeoScript::Geom::Bounds.create min.first, min.last, max.first, max.last
42
+ end
43
+ end
44
+
45
+ def get_geobounds
46
+ box = CRS.get_geographic_bounding_box @crs
47
+ if box
48
+ GeoScript::Geom::Bounds.create box.west_bound_longitude, box.south_bound_latitude, box.east_bound_longitude, box.north_bound_latitude, 'epsg:4326'
49
+ end
50
+ end
51
+
52
+ def transform(obj, dest)
53
+ from_crs = @crs
54
+ to_crs = Projection.new(dest).crs
55
+ transform = CRS.find_math_transform(from_crs, to_crs)
56
+
57
+ if obj.kind_of? Array
58
+ else
59
+ geometry_transform = GeometryCoordinateSequenceTransformer.new
60
+ geometry_transform.math_transform = transform
61
+ geometry_transform.transform obj
62
+ end
63
+ end
64
+
65
+ def self.reproject(obj, from_crs, to_crs)
66
+ Projection.new(from_crs).transform obj, to_crs
67
+ end
68
+ end
69
+ end
@@ -0,0 +1 @@
1
+ require 'util/bytes.rb'
@@ -0,0 +1,43 @@
1
+ JInt = java.lang.Integer
2
+
3
+ module GeoScript
4
+ module Util
5
+ class Bytes
6
+ def self.decode(str, base) # str.to_java_bytes
7
+ #n = Math.log(256, base).ceil
8
+ #bytes = []
9
+ #(0...str.size).step(n) do |i|
10
+ # bytes << string_to_byte(str[i...(i + n)].join(''), base)
11
+ #end
12
+ #bytes.to_java java.lang.Byte
13
+ str.to_java_bytes
14
+ end
15
+
16
+ def self.encode(bytes, base) # bytes.from_java_bytes
17
+ #bytes_array = []
18
+ #
19
+ #bytes.each do |byte|
20
+ # bytes_array << byte_to_string(byte, base)
21
+ #end
22
+ #
23
+ #bytes_array.join ''
24
+ bytes.from_java_bytes
25
+ end
26
+
27
+ def self.byte_to_string(byte, base)
28
+ n = Math.log(256, base).ceil
29
+ s = byte < 0 ? JInt.to_string(((b.abs ^ 0xff) + 0x01), base) : JInt.to_string(b, base)
30
+ "%0#{n}d" % s
31
+ end
32
+
33
+ def self.string_to_byte(string, base)
34
+ int = string.to_i(base)
35
+ if int > 128
36
+ -1 * ((int ^ 0xff) + 0x01)
37
+ else
38
+ int
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module GeoScript
2
+ VERSION = '0.0.1.pre'
3
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geoscript
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 0.0.1.pre
6
+ platform: ruby
7
+ authors:
8
+ - Scooter Wadsworth
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ none: false
44
+ prerelease: false
45
+ type: :development
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-rspec
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ none: false
60
+ prerelease: false
61
+ type: :development
62
+ description: GeoScript for JRuby - makes using GeoTools from JRuby easier and more fun.
63
+ email:
64
+ - scooterwadsworth@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - README.md
70
+ - lib/geoscript.rb
71
+ - lib/geoscript/geom.rb
72
+ - lib/geoscript/projection.rb
73
+ - lib/geoscript/util.rb
74
+ - lib/geoscript/version.rb
75
+ - lib/geoscript/geom/bounds.rb
76
+ - lib/geoscript/geom/geom.rb
77
+ - lib/geoscript/geom/linearring.rb
78
+ - lib/geoscript/geom/linestring.rb
79
+ - lib/geoscript/geom/multilinestring.rb
80
+ - lib/geoscript/geom/multipoint.rb
81
+ - lib/geoscript/geom/multipolygon.rb
82
+ - lib/geoscript/geom/point.rb
83
+ - lib/geoscript/geom/polygon.rb
84
+ - lib/geoscript/geom/io/json.rb
85
+ - lib/geoscript/geom/io/wkb.rb
86
+ - lib/geoscript/geom/io/wkt.rb
87
+ - lib/geoscript/util/bytes.rb
88
+ - lib/geotools/commons-pool-1.5.4.jar
89
+ - lib/geotools/gt-api-8.0-RC2.jar
90
+ - lib/geotools/gt-coverage-8.0-RC2.jar
91
+ - lib/geotools/gt-cql-8.0-RC2.jar
92
+ - lib/geotools/gt-epsg-hsql-8.0-RC2.jar
93
+ - lib/geotools/gt-geojson-8.0-RC2.jar
94
+ - lib/geotools/gt-main-8.0-RC2.jar
95
+ - lib/geotools/gt-metadata-8.0-RC2.jar
96
+ - lib/geotools/gt-opengis-8.0-RC2.jar
97
+ - lib/geotools/gt-property-8.0-RC2.jar
98
+ - lib/geotools/gt-referencing-8.0-RC2.jar
99
+ - lib/geotools/gt-render-8.0-RC2.jar
100
+ - lib/geotools/gt-swing-8.0-RC2.jar
101
+ - lib/geotools/hsqldb-1.8.0.7.jar
102
+ - lib/geotools/imageio-ext-tiff-1.1.4.jar
103
+ - lib/geotools/imageio-ext-utilities-1.1.4.jar
104
+ - lib/geotools/jai_codec-1.1.3.jar
105
+ - lib/geotools/jai_core-1.1.3.jar
106
+ - lib/geotools/jai_imageio-1.1.jar
107
+ - lib/geotools/jdom-1.0.jar
108
+ - lib/geotools/jgridshift-1.0.jar
109
+ - lib/geotools/json-simple-1.1.jar
110
+ - lib/geotools/jsr-275-1.0-beta-2.jar
111
+ - lib/geotools/jt-utils-1.2.0.jar
112
+ - lib/geotools/jt-zonalstats-1.2.0.jar
113
+ - lib/geotools/jts-1.12.jar
114
+ - lib/geotools/miglayout-3.7-swing.jar
115
+ - lib/geotools/vecmath-1.3.2.jar
116
+ - lib/geotools/xercesImpl-2.4.0.jar
117
+ homepage: https://github.com/scooterw/geoscript-ruby
118
+ licenses:
119
+ - MIT
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ none: false
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>'
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.1
135
+ none: false
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.24
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: GeoScript is a library for making use of GeoTools from JRuby easier and more fun.
142
+ test_files: []
143
+ ...