rgeo 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +8 -0
- data/README.rdoc +2 -2
- data/Version +1 -1
- data/lib/rgeo/cartesian/factory.rb +10 -1
- data/lib/rgeo/cartesian/interface.rb +46 -2
- data/lib/rgeo/coord_sys/cs/entities.rb +758 -39
- data/lib/rgeo/coord_sys/cs/factories.rb +82 -12
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +1 -0
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +83 -1
- data/lib/rgeo/coord_sys/srs_database/interface.rb +53 -0
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +60 -15
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +20 -0
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +18 -0
- data/lib/rgeo/feature/factory_generator.rb +17 -4
- data/lib/rgeo/geographic/factory.rb +5 -1
- data/lib/rgeo/geographic/interface.rb +205 -71
- data/lib/rgeo/geographic/proj4_projector.rb +1 -1
- data/lib/rgeo/geographic/simple_mercator_projector.rb +17 -1
- data/lib/rgeo/geos/factory.rb +10 -1
- data/lib/rgeo/geos/interface.rb +26 -0
- data/lib/rgeo/geos/zm_factory.rb +18 -2
- data/test/coord_sys/tc_active_record_table.rb +8 -3
- metadata +3 -3
@@ -82,7 +82,7 @@ module RGeo
|
|
82
82
|
|
83
83
|
|
84
84
|
def create_from_proj4(geography_factory_, proj4_, opts_={})
|
85
|
-
projection_factory_ = Cartesian.preferred_factory(:proj4 => proj4_, :srid => opts_[:srid], :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :has_z_coordinate => opts_[:has_z_coordinate], :has_m_coordinate => opts_[:has_m_coordinate])
|
85
|
+
projection_factory_ = Cartesian.preferred_factory(:proj4 => proj4_, :coord_sys => opts_[:coord_sys], :srid => opts_[:srid], :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :has_z_coordinate => opts_[:has_z_coordinate], :has_m_coordinate => opts_[:has_m_coordinate])
|
86
86
|
new(geography_factory_, projection_factory_)
|
87
87
|
end
|
88
88
|
|
@@ -46,7 +46,7 @@ module RGeo
|
|
46
46
|
|
47
47
|
def initialize(geography_factory_, opts_={})
|
48
48
|
@geography_factory = geography_factory_
|
49
|
-
@projection_factory = Cartesian.preferred_factory(:srid =>
|
49
|
+
@projection_factory = Cartesian.preferred_factory(:srid => 3785, :proj4 => SimpleMercatorProjector._proj4_3785, :coord_sys => SimpleMercatorProjector._coordsys_3785, :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :has_z_coordinate => opts_[:has_z_coordinate], :has_m_coordinate => opts_[:has_m_coordinate])
|
50
50
|
end
|
51
51
|
|
52
52
|
|
@@ -125,6 +125,22 @@ module RGeo
|
|
125
125
|
end
|
126
126
|
|
127
127
|
|
128
|
+
def self._proj4_3785 # :nodoc:
|
129
|
+
unless defined?(@proj4_3785)
|
130
|
+
@proj4_3785 = CoordSys::Proj4.create('+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs')
|
131
|
+
end
|
132
|
+
@proj4_3785
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def self._coordsys_3785 # :nodoc:
|
137
|
+
unless defined?(@coordsys_3785)
|
138
|
+
@coordsys_3785 = CoordSys::CS.create_from_wkt('PROJCS["Popular Visualisation CRS / Mercator",GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y",NORTH]]')
|
139
|
+
end
|
140
|
+
@coordsys_3785
|
141
|
+
end
|
142
|
+
|
143
|
+
|
128
144
|
end
|
129
145
|
|
130
146
|
|
data/lib/rgeo/geos/factory.rb
CHANGED
@@ -66,6 +66,7 @@ module RGeo
|
|
66
66
|
end
|
67
67
|
buffer_resolution_ = opts_[:buffer_resolution].to_i
|
68
68
|
buffer_resolution_ = 1 if buffer_resolution_ < 1
|
69
|
+
srid_ = opts_[:srid]
|
69
70
|
proj4_ = opts_[:proj4]
|
70
71
|
if CoordSys::Proj4.supported?
|
71
72
|
if proj4_.kind_of?(::String) || proj4_.kind_of?(::Hash)
|
@@ -78,7 +79,15 @@ module RGeo
|
|
78
79
|
if coord_sys_.kind_of?(::String)
|
79
80
|
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_) rescue nil
|
80
81
|
end
|
81
|
-
|
82
|
+
if (!proj4_ || !coord_sys_) && srid_ && (db_ = opts_[:srs_database])
|
83
|
+
entry_ = db_.get(srid_.to_i)
|
84
|
+
if entry_
|
85
|
+
proj4_ ||= entry_.proj4
|
86
|
+
coord_sys_ ||= entry_.coord_sys
|
87
|
+
end
|
88
|
+
end
|
89
|
+
srid_ ||= coord_sys_.authority_code if coord_sys_
|
90
|
+
result_ = _create(flags_, srid_.to_i, buffer_resolution_)
|
82
91
|
result_.instance_variable_set(:@proj4, proj4_)
|
83
92
|
result_.instance_variable_set(:@coord_sys, coord_sys_)
|
84
93
|
result_
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -88,6 +88,19 @@ module RGeo
|
|
88
88
|
# <tt>:srid</tt>::
|
89
89
|
# Set the SRID returned by geometries created by this factory.
|
90
90
|
# Default is 0.
|
91
|
+
# <tt>:proj4</tt>::
|
92
|
+
# The coordinate system in Proj4 format, either as a
|
93
|
+
# CoordSys::Proj4 object or as a string or hash representing the
|
94
|
+
# proj4 format. Optional.
|
95
|
+
# <tt>:coord_sys</tt>::
|
96
|
+
# The coordinate system in OGC form, either as a subclass of
|
97
|
+
# CoordSys::CS::CoordinateSystem, or as a string in WKT format.
|
98
|
+
# Optional.
|
99
|
+
# <tt>:srs_database</tt>::
|
100
|
+
# Optional. If provided, the value should be an implementation of
|
101
|
+
# CoordSys::SRSDatabase::Interface. If both this and an SRID are
|
102
|
+
# provided, they are used to look up the proj4 and coord_sys
|
103
|
+
# objects from a spatial reference system database.
|
91
104
|
# <tt>:has_z_coordinate</tt>::
|
92
105
|
# Support <tt>z_coordinate</tt>. Default is false.
|
93
106
|
# <tt>:has_m_coordinate</tt>::
|
@@ -106,6 +119,19 @@ module RGeo
|
|
106
119
|
end
|
107
120
|
|
108
121
|
|
122
|
+
# Returns a Feature::FactoryGenerator that creates Geos-backed
|
123
|
+
# factories. The given options are used as the default options.
|
124
|
+
#
|
125
|
+
# A common case for this is to provide the <tt>:srs_database</tt>
|
126
|
+
# as a default. Then, the factory generator need only be passed
|
127
|
+
# an SRID and it will automatically fetch the appropriate Proj4
|
128
|
+
# and CoordSys objects.
|
129
|
+
|
130
|
+
def factory_generator(defaults_={})
|
131
|
+
::Proc.new{ |c_| factory(defaults_.merge(c_)) }
|
132
|
+
end
|
133
|
+
|
134
|
+
|
109
135
|
end
|
110
136
|
|
111
137
|
end
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -62,8 +62,24 @@ module RGeo
|
|
62
62
|
|
63
63
|
|
64
64
|
def initialize(opts_={}) # :nodoc:
|
65
|
-
|
66
|
-
|
65
|
+
proj4_ = opts_[:proj4]
|
66
|
+
coord_sys_ = opts_[:coord_sys]
|
67
|
+
srid_ = opts_[:srid]
|
68
|
+
if (!proj4_ || !coord_sys_) && srid_ && (db_ = opts_[:srs_database])
|
69
|
+
entry_ = db_.get(srid_.to_i)
|
70
|
+
if entry_
|
71
|
+
proj4_ ||= entry_.proj4
|
72
|
+
coord_sys_ ||= entry_.coord_sys
|
73
|
+
end
|
74
|
+
end
|
75
|
+
srid_ ||= coord_sys_.authority_code if coord_sys_
|
76
|
+
config_ = {
|
77
|
+
:lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions],
|
78
|
+
:buffer_resolution => opts_[:buffer_resolution],
|
79
|
+
:srid => srid_.to_i, :proj4 => proj4_, :coord_sys => coord_sys_,
|
80
|
+
}
|
81
|
+
@zfactory = Factory.create(config_.merge(:has_z_coordinate => true))
|
82
|
+
@mfactory = Factory.create(config_.merge(:has_m_coordinate => true))
|
67
83
|
end
|
68
84
|
|
69
85
|
|
@@ -45,11 +45,16 @@ module RGeo
|
|
45
45
|
module ActiveRecordTableTests # :nodoc:
|
46
46
|
|
47
47
|
database_configs_ = ::YAML.load_file(::File.dirname(__FILE__)+'/database.yml') rescue nil
|
48
|
+
if database_configs_
|
49
|
+
begin
|
50
|
+
require 'active_record'
|
51
|
+
rescue ::LoadError
|
52
|
+
database_configs_ = nil
|
53
|
+
end
|
54
|
+
end
|
48
55
|
|
49
56
|
if database_configs_
|
50
57
|
|
51
|
-
require 'active_record'
|
52
|
-
|
53
58
|
PostGIS_CONFIG = database_configs_['postgis'] rescue nil
|
54
59
|
|
55
60
|
|
@@ -88,7 +93,7 @@ module RGeo
|
|
88
93
|
|
89
94
|
|
90
95
|
else
|
91
|
-
puts "WARNING: Couldn't find database.yml; skipping ActiveRecord tests."
|
96
|
+
puts "WARNING: Couldn't find database.yml or ActiveRecord gem is not present; skipping ActiveRecord tests."
|
92
97
|
end
|
93
98
|
|
94
99
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Azuma
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-19 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|