geoq 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65f99517f2c00af9dadaaebb0648a1b74ef265b5
4
- data.tar.gz: c68af107652e020f66b2cb670f65bbc677d9f557
3
+ metadata.gz: 3a8fda162158377b2f584680d2b3039160b2aed5
4
+ data.tar.gz: 77028b68a15d7cce1581e9a97138a42e75491fb6
5
5
  SHA512:
6
- metadata.gz: a572ce5d989f3d7cbec851fc00a5e70646a357de19b44910cb892fc4bece21c1752abcb3bc3e1642b50c7a582ac0c167e21de97e16cc4d175f5a758c8b129976
7
- data.tar.gz: 47dbb2f5207155b763ee5832c24dc6257787de7e9e656ece19cbc16d9bc42d0cc6424170452a7b46415a168bfb3e978612179c838d28ca41eb2e95b6fb65e6d5
6
+ metadata.gz: 7346ed0ef0f70cd81c8f3e081622f4697f0db823f97ba994d09406713df4f0054ca60912ae5f7fad92fe65c4976d0586520d3c747af544fd2e1e23a31f4412f8
7
+ data.tar.gz: dc6fdfad9dd14d1eaf8192b9c7f204664136688c179a444225635f68eb5c2b7c4610521ce40c480cd6861e78277e75817255002f209348917f120d7fd390979b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geoq (0.0.2)
4
+ geoq (0.0.3)
5
5
  gli (~> 2.17)
6
6
  os (~> 1.0)
7
7
  pr_geohash (~> 1.0)
data/bin/geoq CHANGED
@@ -22,7 +22,7 @@ Geospatial utility belt
22
22
 
23
23
  Will output the geohash 9q5 as a geojson geometry.
24
24
 
25
- Most commands will accept a Lat/Lon (comma-separated), a Geohash
25
+ Most commands will accept a Lat/Lon (comma or tab-separated), a Geohash
26
26
  (base 32 encoded), a WKT, or a GeoJSON input.
27
27
 
28
28
  The tool should recognize the input type based on its format.
@@ -118,15 +118,13 @@ command :gh do |c|
118
118
  end
119
119
 
120
120
  GEOJSON_IO_URL_LIMIT = 27000 # crudely derived via experimentation
121
- map_desc = "
122
- Plot input on geojson.io.
123
121
 
122
+ desc "Plot input on geojson.io."
123
+ long_desc "
124
124
  Input will be converted to a GeoJSON FeatureCollection, similarly to 'geoq gj fc'
125
125
 
126
- We rely on url-encoding the desired GeoJSON to transfer it to geojson.io, so long inputs
127
- over 27k characters will be rejected."
128
-
129
- desc map_desc
126
+ We rely on url-encoding the desired GeoJSON to transfer it to geojson.io,
127
+ so long inputs over 27k characters will be rejected."
130
128
  command :map do |c|
131
129
  c.action do |global_options,options,args|
132
130
  entities = Geoq::GeomReader.new(STDIN)
@@ -42,7 +42,7 @@ module Geoq
42
42
  [GeoJson.new(decoded, line)]
43
43
  end
44
44
  elsif latlon?(line)
45
- [LatLon.new(factory.point(*strip_whitespace(line).split(",").map(&:to_f).reverse), line)]
45
+ [LatLon.new(factory.point(*(strip_whitespace(line.gsub("\t", ",")).split(",").map(&:to_f).reverse)), line)]
46
46
  else
47
47
  [Wkt.new(wkt.parse(line), line)]
48
48
  end
@@ -61,7 +61,7 @@ module Geoq
61
61
  end
62
62
 
63
63
  def latlon?(line)
64
- !!LAT_LON_REGEX.match(strip_whitespace(line))
64
+ !!LAT_LON_REGEX.match(strip_whitespace(line.gsub(/\t/, ",")))
65
65
  end
66
66
 
67
67
  private
@@ -1,3 +1,3 @@
1
1
  module Geoq
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -9,11 +9,11 @@ module Geoq
9
9
  assert_equal "FeatureCollection", json["type"]
10
10
  assert_equal ["type", "features"].sort, json.keys.sort
11
11
  features = json["features"]
12
- assert_equal 6, features.count
12
+ assert_equal 7, features.count
13
13
 
14
- assert_equal ["Polygon", "Point", "Point", "Point", "Point", "Point"], features.map { |f| f["geometry"]["type"] }
14
+ assert_equal ["Polygon", "Point", "Point", "Point", "Point", "Point", "Point"], features.map { |f| f["geometry"]["type"] }
15
15
  # encodes properties
16
- assert_equal [{}, {}, {}, {"a" => "b"}, {}, {"a" => "b"}], features.map { |f| f["properties"] }
16
+ assert_equal [{}, {}, {}, {"a" => "b"}, {}, {}, {"a" => "b"}], features.map { |f| f["properties"] }
17
17
  assert_equal Hash.new, features[0]["properties"]
18
18
  assert_equal Hash.new, features[1]["properties"]
19
19
  assert_equal Hash.new, features[2]["properties"]
@@ -21,7 +21,7 @@ module Geoq
21
21
 
22
22
 
23
23
  gh = [[[-119.53125, 33.75], [-118.125, 33.75], [-118.125, 35.15625], [-119.53125, 35.15625], [-119.53125, 33.75]]]
24
- assert_equal [gh, [0.0,1.0], [1.0, 2.0], [3.0, 4.0], [-118.3, 34.52], [3.0, 4.0]], features.map { |f| f["geometry"]["coordinates"] }
24
+ assert_equal [gh, [0.0,1.0], [1.0, 2.0], [3.0, 4.0], [-118.3, 34.52], [-45.3, 18.3], [3.0, 4.0]], features.map { |f| f["geometry"]["coordinates"] }
25
25
  end
26
26
 
27
27
  def test_feature_collection_given_feature_collection
@@ -38,6 +38,9 @@ module Geoq
38
38
  assert reader.latlon?("0, 0")
39
39
  assert reader.latlon?("123.456,98.2")
40
40
  assert reader.latlon?(" -123.456,-98.2 ")
41
+ assert reader.latlon?("123.456 98.2")
42
+ assert reader.latlon?("123.456\t98.2")
43
+ assert reader.decode("34\t-118").first.is_a?(LatLon)
41
44
  end
42
45
 
43
46
  def test_correct_lat_lon_ordering
@@ -28,6 +28,7 @@ module Geoq::TestData
28
28
  "POINT (1.0 2.0)",
29
29
  {type: "Feature", properties: {a: "b"}, geometry: {type: "Point", coordinates: [3,4]}}.to_json,
30
30
  "34.52,-118.3",
31
+ "18.3\t-45.3",
31
32
  {type: "FeatureCollection", features: [{type: "Feature", properties: {a: "b"}, geometry: {type: "Point", coordinates: [3,4]}}]}.to_json]
32
33
  stream(inputs)
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Horace Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.6.14.1
205
+ rubygems_version: 2.5.1
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: geoq is a command-line utility for GIS format conversion and common GIS operations