rgeo 0.3.0 → 0.3.1

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 CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.3.1 / 2011-05-24
2
+
3
+ * Running a == operator comparison between a geometry and a non-geometry caused an exception for some implementations. Fixed. (Reported by Daniel Hackney.)
4
+ * Clarified the specifications for operators on geometry objects.
5
+
1
6
  === 0.3.0 / 2011-05-23
2
7
 
3
8
  * RGeo can now use GEOS via the ffi-geos gem, in addition to RGeo's built-in C integration. The ffi-geos integration is experimental right now, since ffi-geos is still in early beta. In particular, I do not recommend using it in JRuby yet (as of JRuby 1.6.1), because an apparent JRuby bug (JRUBY-5813) causes intermittent segfaults. However, once the issue is resolved (soon, I hope, since I've already submitted a patch to the JRuby team), we should have GEOS functional on JRuby.
data/README.rdoc CHANGED
@@ -93,6 +93,7 @@ installation prefix directory using the "--with-proj-dir" option.
93
93
  The RGeo suite of tools is evolving rapidly. The current to-do list for
94
94
  the core library includes:
95
95
 
96
+ * YAML and Marshal serialization support.
96
97
  * Better JRuby support.
97
98
  * Ellipsoidal geography implementation, possibly utilizing geographiclib.
98
99
  * Windows build support.
data/Version CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -578,28 +578,41 @@ module RGeo
578
578
  end
579
579
 
580
580
 
581
- # Alias of the equals? method.
581
+ # This operator should behave almost the same as the equals? method.
582
+ # The difference is that the == operator is required to handle rhs
583
+ # values that are not geometry objects (returning false in such cases)
584
+ # in order to fulfill the standard Ruby contract for the == operator,
585
+ # whereas the equals? method may assume that any rhs is a geometry.
582
586
 
583
587
  def ==(rhs_)
584
- equals?(rhs_)
588
+ rhs_.kind_of?(::RGeo::Feature::Instance) ? equals?(rhs_) : false
585
589
  end
586
590
 
587
591
 
588
- # Alias of the difference method.
592
+ # If the given rhs is a geometry object, this operator must behave
593
+ # the same as the difference method. The behavior for other rhs
594
+ # types is not specified; an implementation may choose to provide
595
+ # additional capabilities as appropriate.
589
596
 
590
597
  def -(rhs_)
591
598
  difference(rhs_)
592
599
  end
593
600
 
594
601
 
595
- # Alias of the union method.
602
+ # If the given rhs is a geometry object, this operator must behave
603
+ # the same as the union method. The behavior for other rhs types
604
+ # is not specified; an implementation may choose to provide
605
+ # additional capabilities as appropriate.
596
606
 
597
607
  def +(rhs_)
598
608
  union(rhs_)
599
609
  end
600
610
 
601
611
 
602
- # Alias of the intersection method.
612
+ # If the given rhs is a geometry object, this operator must behave
613
+ # the same as the intersection method. The behavior for other rhs
614
+ # types is not specified; an implementation may choose to provide
615
+ # additional capabilities as appropriate.
603
616
 
604
617
  def *(rhs_)
605
618
  intersection(rhs_)
@@ -181,11 +181,17 @@ module RGeo
181
181
 
182
182
 
183
183
  def equals?(rhs_)
184
+ return false unless rhs_.kind_of?(::RGeo::Feature::Instance)
184
185
  fg_ = factory._convert_to_fg_geometry(rhs_)
186
+ if !fg_
187
+ false
185
188
  # GEOS has a bug where empty geometries are not spatially equal
186
189
  # to each other. Work around this case first.
187
- return true if fg_.empty? && @fg_geom.empty?
188
- fg_ ? @fg_geom.eql?(fg_) : false
190
+ elsif fg_.empty? && @fg_geom.empty?
191
+ true
192
+ else
193
+ @fg_geom.eql?(fg_)
194
+ end
189
195
  end
190
196
  alias_method :==, :equals?
191
197
 
@@ -63,9 +63,10 @@ module RGeo
63
63
  # Z is present); or <tt>:wkt12</tt>, indicating SFS 1.2 WKT
64
64
  # tags that indicate the presence of Z and M in a separate token.
65
65
  # Default is <tt>:wkt11</tt>.
66
+ # This option can also be specified as <tt>:type_format</tt>.
66
67
  # [<tt>:emit_ewkt_srid</tt>]
67
68
  # If true, embed the SRID of the toplevel geometry. Available only
68
- # if <tt>:type_format</tt> is <tt>:ewkt</tt>. Default is false.
69
+ # if <tt>:tag_format</tt> is <tt>:ewkt</tt>. Default is false.
69
70
  # [<tt>:square_brackets</tt>]
70
71
  # If true, uses square brackets rather than parentheses.
71
72
  # Default is false.
@@ -83,7 +84,7 @@ module RGeo
83
84
  # documentation for the options that can be passed.
84
85
 
85
86
  def initialize(opts_={})
86
- @tag_format = opts_[:tag_format] || :wkt11
87
+ @tag_format = opts_[:tag_format] || opts_[:type_format] || :wkt11
87
88
  @emit_ewkt_srid = opts_[:emit_ewkt_srid] ? true : false if @tag_format == :ewkt
88
89
  @square_brackets = opts_[:square_brackets] ? true : false
89
90
  @convert_case = opts_[:convert_case]
@@ -94,6 +95,7 @@ module RGeo
94
95
  def tag_format
95
96
  @tag_format
96
97
  end
98
+ alias_method :type_format, :tag_format
97
99
 
98
100
  # Returns whether SRID is embedded. See WKTGenerator for details.
99
101
  def emit_ewkt_srid?
@@ -157,6 +157,8 @@ module RGeo
157
157
  assert(!point1_.equals?(point3_))
158
158
  assert(point1_ != point3_)
159
159
  assert(!point1_.eql?(point3_))
160
+ assert(point1_ != 'hello')
161
+ assert(!point1_.eql?('hello'))
160
162
  end
161
163
 
162
164
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rgeo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Azuma
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-23 00:00:00 Z
13
+ date: 2011-05-24 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: RGeo is a geospatial data library for Ruby. It provides an implementation of the Open Geospatial Consortium's Simple Features Specification, used by most standard spatial/geographic data storage systems such as PostGIS. A number of add-on modules are also available to help with writing location-based applications using Ruby-based frameworks such as Ruby On Rails.