charta 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1ebd7fd8007ba50a0fd0b0a4fbbf6449a25f58a
4
- data.tar.gz: 0f64a9330f1b9dd64e4070f4b1c2721c1ff87bf7
3
+ metadata.gz: 7330e4893e3f07c1558d79a93fd56077ed7a6e38
4
+ data.tar.gz: d101ae5be607fd0a6ce27447c03504a74cdfd03a
5
5
  SHA512:
6
- metadata.gz: b3d86e98cfae5d05b12b27f745a46a27802aedfcd3b54ae173c32421b4ca7882abc0f510dd234441086c5620e2a460362cf9cc08f8c0b79cb39f0ff7cde592a2
7
- data.tar.gz: 82d85768aca4670d5885ec144062d774860e9c70954c69f0093b80520ec15fe667776599d4ec1cb27c5c1078625f8939d5af2f43acd2d6ae21e178ca63ed0ebc
6
+ metadata.gz: 5a779aff4072ca8118cb65e66b711816b51e1a6f2194b520a174c5b7549072afe064581e245940c59fcf7126274b1f463d732792b17101dcf044fa57891dcee2
7
+ data.tar.gz: a68643928b9578e298b665d8f576b3a51f95e3b8635aa6231501f886e57a5eb1d866c915d604d64c4a691d535b1b654a6fd30757e78bba5fb871f83994d5c683
@@ -98,7 +98,12 @@ module Charta
98
98
  end.join(', ') + ')'
99
99
  end
100
100
 
101
- alias geometry_collection_to_ewkt feature_collection_to_ewkt
101
+ def geometry_collection_to_ewkt(hash)
102
+ return 'GEOMETRYCOLLECTION EMPTY' if hash['geometries'].nil?
103
+ 'GEOMETRYCOLLECTION(' + hash['geometries'].collect do |feature|
104
+ object_to_ewkt(feature)
105
+ end.join(', ') + ')'
106
+ end
102
107
 
103
108
  def feature_to_ewkt(hash)
104
109
  object_to_ewkt(hash['geometry'])
@@ -129,7 +129,7 @@ module Charta
129
129
  # Computes the geometric center of a geometry, or equivalently, the center
130
130
  # of mass of the geometry as a POINT.
131
131
  def centroid
132
- return nil unless surface?
132
+ return nil unless surface? && !@feature.is_empty?
133
133
  point = @feature.centroid
134
134
  [point.y, point.x]
135
135
  end
@@ -155,7 +155,7 @@ module Charta
155
155
  as_multi_type = "multi_#{as_type}".to_sym
156
156
  if type == as_type
157
157
  items << @feature
158
- elsif as_type == :geometry_collection
158
+ elsif type == :geometry_collection
159
159
  @feature.each do |geom|
160
160
  type_name = Charta.underscore(geom.geometry_type.type_name).to_sym
161
161
  if type_name == as_type
@@ -72,7 +72,7 @@ module Charta
72
72
 
73
73
  def document_to_ewkt(gml, srid)
74
74
  # whole document
75
- if gml.css("#{OGR_PREFIX}|FeatureCollection").nil? || gml.css("#{GML_PREFIX}|featureMember").nil?
75
+ if gml.css("#{OGR_PREFIX}|FeatureCollection").empty? || gml.css("#{GML_PREFIX}|featureMember").empty?
76
76
  # fragment
77
77
  if gml.root.name && TAGS.include?(gml.root.name)
78
78
  object_to_ewkt(gml.root, srid)
@@ -1,3 +1,3 @@
1
1
  module Charta
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice TEXIER
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri