geoscript 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -9
- data/lib/geoscript/geom/bounds.rb +10 -14
- data/lib/geoscript/geom/geom.rb +1 -1
- data/lib/geoscript/geom/linearring.rb +8 -8
- data/lib/geoscript/geom/linestring.rb +8 -9
- data/lib/geoscript/geom/multilinestring.rb +8 -8
- data/lib/geoscript/geom/multipoint.rb +9 -10
- data/lib/geoscript/geom/multipolygon.rb +8 -9
- data/lib/geoscript/geom/point.rb +12 -7
- data/lib/geoscript/geom/polygon.rb +10 -9
- data/lib/geoscript/projection.rb +18 -1
- data/lib/geoscript/version.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -8,20 +8,18 @@ require 'geoscript'
|
|
8
8
|
include GeoScript::Geom
|
9
9
|
# => Object
|
10
10
|
|
11
|
-
p = Point.
|
12
|
-
# => #<GeoScript::Geom::Point:
|
11
|
+
p = Point.new -111.0, 45.7
|
12
|
+
# => #<GeoScript::Geom::Point:0x636c4fcb>
|
13
13
|
p.to_wkt
|
14
|
-
# => "POINT (-111
|
14
|
+
# => "POINT (-111 45.7)"
|
15
15
|
|
16
16
|
p2 = GeoScript::Projection.reproject p, 'epsg:4326', 'epsg:26912'
|
17
|
-
# => #<
|
18
|
-
p2.
|
19
|
-
# => 500000.
|
20
|
-
p2.y
|
21
|
-
# => 5060716.313515949
|
17
|
+
# => #<GeoScript::Geom::Point:0x6a55c240>
|
18
|
+
p2.to_wkt
|
19
|
+
# => "POINT (500000 5060716.313515949)"
|
22
20
|
|
23
21
|
poly = p2.buffer 100
|
24
|
-
# => #<
|
22
|
+
# => #<GeoScript::Geom::Polygon:0x7b32aba9>
|
25
23
|
poly.get_area
|
26
24
|
# => 31214.451522458345
|
27
25
|
```
|
@@ -6,42 +6,38 @@ module GeoScript
|
|
6
6
|
class Bounds < ReferencedEnvelope
|
7
7
|
include GeoScript::Geom
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
def self.create(env, proj = nil)
|
9
|
+
def initialize(env, proj = nil)
|
12
10
|
projection = GeoScript::Projection.new proj if proj
|
13
11
|
|
14
12
|
if env.kind_of? Envelope
|
15
13
|
if projection
|
16
|
-
|
14
|
+
super(env, projection)
|
17
15
|
elsif env.respond_to? :crs
|
18
16
|
if env.crs
|
19
|
-
|
17
|
+
super(env, env.crs)
|
20
18
|
else
|
21
|
-
|
19
|
+
super(env, nil)
|
22
20
|
end
|
23
21
|
else
|
24
|
-
|
22
|
+
super(env, nil)
|
25
23
|
end
|
26
24
|
else
|
27
25
|
if env.kind_of? Hash
|
28
26
|
if projection
|
29
|
-
|
27
|
+
super(env[:x_min], env[:x_max], env[:y_min], env[:y_max], projection)
|
30
28
|
else
|
31
|
-
|
29
|
+
super(env[:x_min], env[:x_max], env[:y_min], env[:y_max], nil)
|
32
30
|
end
|
33
31
|
elsif env.kind_of? Array
|
34
32
|
if projection
|
35
|
-
|
33
|
+
super(env[0], env[1], env[2], env[3], projection)
|
36
34
|
else
|
37
|
-
|
35
|
+
super(env[0], env[1], env[2], env[3])
|
38
36
|
end
|
39
37
|
else
|
40
|
-
|
38
|
+
super()
|
41
39
|
end
|
42
40
|
end
|
43
|
-
|
44
|
-
bounds
|
45
41
|
end
|
46
42
|
|
47
43
|
def get_west
|
data/lib/geoscript/geom/geom.rb
CHANGED
@@ -8,17 +8,17 @@ module GeoScript
|
|
8
8
|
|
9
9
|
attr_accessor :bounds
|
10
10
|
|
11
|
-
def initialize(*
|
12
|
-
|
13
|
-
def self.create(*coords)
|
11
|
+
def initialize(*coords)
|
14
12
|
if coords.size == 1
|
15
|
-
|
13
|
+
super(coords.first.coordinate_sequence) if coords.first.kind_of? LinearRing
|
16
14
|
else
|
17
|
-
line_string = LineString.
|
18
|
-
|
15
|
+
line_string = LineString.new *coords
|
16
|
+
super(line_string.coordinate_sequence, GEOM_FACTORY)
|
19
17
|
end
|
20
|
-
|
21
|
-
|
18
|
+
end
|
19
|
+
|
20
|
+
def buffer(dist)
|
21
|
+
Polygon.new super
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_wkt
|
@@ -8,12 +8,9 @@ module GeoScript
|
|
8
8
|
|
9
9
|
attr_accessor :bounds
|
10
10
|
|
11
|
-
def initialize(*
|
12
|
-
|
13
|
-
def self.create(*coords)
|
11
|
+
def initialize(*coords)
|
14
12
|
if coords.size == 1
|
15
|
-
if coords.first.kind_of?
|
16
|
-
ls = coords.first
|
13
|
+
if coords.first.kind_of? JTSLineString
|
17
14
|
elsif coords.kind_of? Array
|
18
15
|
if coords.first.kind_of? Array
|
19
16
|
l = []
|
@@ -36,16 +33,18 @@ module GeoScript
|
|
36
33
|
ls = GEOM_FACTORY.create_line_string l.to_java(com.vividsolutions.jts.geom.Coordinate)
|
37
34
|
end
|
38
35
|
end
|
39
|
-
|
36
|
+
|
40
37
|
if ls
|
41
|
-
|
42
|
-
GeoScript::Geom.enhance line_string
|
43
|
-
line_string
|
38
|
+
super(ls.coordinate_sequence, GEOM_FACTORY)
|
44
39
|
else
|
45
40
|
raise 'LineString could not be created. Check inputs.'
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
44
|
+
def buffer(dist)
|
45
|
+
Polygon.new super
|
46
|
+
end
|
47
|
+
|
49
48
|
def to_wkt
|
50
49
|
IO.write_wkt self
|
51
50
|
end
|
@@ -7,12 +7,10 @@ module GeoScript
|
|
7
7
|
|
8
8
|
attr_accessor :bounds
|
9
9
|
|
10
|
-
def initialize(*
|
11
|
-
|
12
|
-
def self.create(*line_strings)
|
10
|
+
def initialize(*line_strings)
|
13
11
|
strings = []
|
14
12
|
|
15
|
-
if line_strings.first.kind_of?
|
13
|
+
if line_strings.first.kind_of? JTSMultiLineString
|
16
14
|
multi_line_string_geom = line_strings.first
|
17
15
|
for i in range(0...multi_line_string_geom.num_geometries)
|
18
16
|
strings << multi_line_string_geom.get_geometry_n(i)
|
@@ -22,14 +20,16 @@ module GeoScript
|
|
22
20
|
if line_string.kind_of? LineString
|
23
21
|
strings << line_string
|
24
22
|
else
|
25
|
-
strings << LineString.
|
23
|
+
strings << LineString.new(*line_string)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
super(strings.to_java(com.vividsolutions.jts.geom.LineString), GEOM_FACTORY)
|
29
|
+
end
|
30
|
+
|
31
|
+
def buffer(dist)
|
32
|
+
Polygon.new super
|
33
33
|
end
|
34
34
|
|
35
35
|
def to_wkt
|
@@ -7,14 +7,11 @@ module GeoScript
|
|
7
7
|
|
8
8
|
attr_accessor :bounds
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
def self.create(*points)
|
10
|
+
def initialize(*points)
|
13
11
|
feature_points = []
|
14
12
|
|
15
|
-
if points.first.kind_of?
|
16
|
-
multi_point_geom =
|
17
|
-
|
13
|
+
if points.first.kind_of? JTSMultiPoint
|
14
|
+
multi_point_geom = point.first
|
18
15
|
for i in (0...multi_point_geom.num_geometries)
|
19
16
|
feature_points << multi_point_geom.get_geometry_n(i)
|
20
17
|
end
|
@@ -23,14 +20,16 @@ module GeoScript
|
|
23
20
|
if point.kind_of? Point
|
24
21
|
feature_points << point
|
25
22
|
else
|
26
|
-
feature_points << Point.
|
23
|
+
feature_points << Point.new(*point)
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
super(feature_points.to_java(com.vividsolutions.jts.geom.Point), GEOM_FACTORY)
|
29
|
+
end
|
30
|
+
|
31
|
+
def buffer(dist)
|
32
|
+
Polygon.new super
|
34
33
|
end
|
35
34
|
|
36
35
|
def to_wkt
|
@@ -7,29 +7,28 @@ module GeoScript
|
|
7
7
|
|
8
8
|
attr_accessor :bounds
|
9
9
|
|
10
|
-
def initialize(*
|
11
|
-
|
12
|
-
def self.create(*polygons)
|
10
|
+
def initialize(*polygons)
|
13
11
|
polys = []
|
14
12
|
|
15
|
-
if polygons.first.kind_of?
|
13
|
+
if polygons.first.kind_of? JTSMultiPolygon
|
16
14
|
multi_polygon = polygons.first
|
17
15
|
for i in range(0...multi_polygon.num_geometries)
|
18
16
|
polys << multi_polygon.get_geometry_n(i)
|
19
17
|
end
|
20
18
|
else
|
21
19
|
polygons.each do |polygon|
|
22
|
-
if polygon.kind_of? Polygon
|
20
|
+
if polygon.kind_of? Java::ComVividsolutionsJtsGeom::Polygon
|
23
21
|
polys << polygon
|
24
22
|
else
|
25
|
-
polys << Polygon.
|
23
|
+
polys << Polygon.new(*polygon)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
27
|
+
super(polys.to_java(com.vividsolutions.jts.geom.Polygon), GEOM_FACTORY)
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
multi_poly
|
30
|
+
def buffer(dist)
|
31
|
+
Polygon.new super
|
33
32
|
end
|
34
33
|
|
35
34
|
def to_wkt
|
data/lib/geoscript/geom/point.rb
CHANGED
@@ -8,14 +8,19 @@ module GeoScript
|
|
8
8
|
|
9
9
|
attr_accessor :bounds
|
10
10
|
|
11
|
-
def initialize(*
|
11
|
+
def initialize(*coords)
|
12
|
+
if coords.first.kind_of? JTSPoint
|
13
|
+
p = coords.first
|
14
|
+
else
|
15
|
+
c = Coordinate.new coords[0], coords[1]
|
16
|
+
c.z = coords[2] if coords[2]
|
17
|
+
p = GEOM_FACTORY.create_point c
|
18
|
+
end
|
19
|
+
super p.coordinate_sequence, GEOM_FACTORY
|
20
|
+
end
|
12
21
|
|
13
|
-
def
|
14
|
-
|
15
|
-
p = GEOM_FACTORY.create_point c
|
16
|
-
point = Point.new p.coordinate_sequence, GEOM_FACTORY
|
17
|
-
GeoScript::Geom.enhance point
|
18
|
-
point
|
22
|
+
def buffer(dist)
|
23
|
+
Polygon.new super
|
19
24
|
end
|
20
25
|
|
21
26
|
def to_wkt
|
@@ -7,32 +7,33 @@ module GeoScript
|
|
7
7
|
|
8
8
|
attr_accessor :bounds
|
9
9
|
|
10
|
-
def initialize(*
|
11
|
-
|
12
|
-
def self.create(*rings)
|
13
|
-
if rings.first.kind_of? Polygon
|
10
|
+
def initialize(*rings)
|
11
|
+
if rings.first.kind_of? JTSPolygon
|
14
12
|
interior_rings = []
|
15
13
|
num_rings = rings.first.num_interior_ring
|
16
14
|
for i in (0...num_rings)
|
17
15
|
interior_rings << rings.first.get_interior_ring_n(i)
|
18
16
|
end
|
19
|
-
|
17
|
+
shell = rings.first.exterior_ring
|
18
|
+
holes = interior_rings.to_java(com.vividsolutions.jts.geom.LinearRing)
|
20
19
|
else
|
21
20
|
linear_rings = []
|
22
21
|
rings.each do |ring|
|
23
22
|
if ring.kind_of? LinearRing
|
24
23
|
linear_rings << ring
|
25
24
|
else
|
26
|
-
linear_rings << LinearRing.
|
25
|
+
linear_rings << LinearRing.new(*ring)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
shell = linear_rings.first
|
31
30
|
holes = linear_rings[1..linear_rings.size].to_java(com.vividsolutions.jts.geom.LinearRing)
|
32
|
-
poly = Polygon.new shell, holes, GEOM_FACTORY
|
33
31
|
end
|
34
|
-
|
35
|
-
|
32
|
+
super(shell, holes, GEOM_FACTORY)
|
33
|
+
end
|
34
|
+
|
35
|
+
def buffer(dist)
|
36
|
+
Polygon.new super
|
36
37
|
end
|
37
38
|
|
38
39
|
def to_wkt
|
data/lib/geoscript/projection.rb
CHANGED
@@ -58,7 +58,24 @@ module GeoScript
|
|
58
58
|
else
|
59
59
|
geometry_transform = GeometryCoordinateSequenceTransformer.new
|
60
60
|
geometry_transform.math_transform = transform
|
61
|
-
geometry_transform.transform obj
|
61
|
+
new_geom = geometry_transform.transform obj
|
62
|
+
# not entirely comfortable with this
|
63
|
+
case new_geom.class.to_s
|
64
|
+
when 'Java::ComVividsolutionsJtsGeom::Point'
|
65
|
+
GeoScript::Geom::Point.new new_geom
|
66
|
+
when 'Java::ComVividsolutionsJtsGeom::Polygon'
|
67
|
+
GeoScript::Geom::Polygon.new new_geom
|
68
|
+
when 'Java::ComVividsolutionsJtsGeom::MultiPoint'
|
69
|
+
GeoScript::Geom::MultiPoint.create new_geom
|
70
|
+
when 'Java::ComVividsolutionsJtsGeom::MultiPolygon'
|
71
|
+
GeoScript::Geom::MultiPolygon.create new_geom
|
72
|
+
when 'Java::ComVividsolutionsJtsGeom::LineString'
|
73
|
+
GeoScript::Geom::LineString.create new_geom
|
74
|
+
when 'Java::ComVividsolutionsJtsGeom::MultiLineString'
|
75
|
+
GeoScript::Geom::MultiLineString.create new_geom
|
76
|
+
when 'Java::ComVividsolutionsJtsGeom::LinearRing'
|
77
|
+
GeoScript::Geom::LinearRing.create new_geom
|
78
|
+
end
|
62
79
|
end
|
63
80
|
end
|
64
81
|
|
data/lib/geoscript/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Scooter Wadsworth
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -129,9 +129,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
none: false
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- - ! '
|
132
|
+
- - ! '>='
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
134
|
+
version: '0'
|
135
135
|
none: false
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|