logstash-filter-wkt_to_geojson 0.1.3 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b35ab5f9f037982a00e0296078306f2d830bb94
|
4
|
+
data.tar.gz: 800854194658a6c92a53de5b0740a6c9358ffb2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2424616f539b337041648155c2b4e03e27dae61eca4771dd2894e319fc4919c7a43d4519a2489be541a5a6a62b0a3c90551f744afa3cdf39826f0a35b659e32f
|
7
|
+
data.tar.gz: 6ce88ae0c6b9258ecb66b80b7d9efd0686797d0bd58ca097a3c8d1aff44599b835367666fed7714eb14bd9be2b0d750d5b7d51e98cde2b98311ff19143f25242
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/filters/base"
|
3
3
|
require "logstash/namespace"
|
4
|
+
require 'json'
|
4
5
|
require 'geo_ruby'
|
5
6
|
require 'geo_ruby/ewk'
|
6
7
|
require 'geo_ruby/geojson'
|
@@ -11,6 +12,7 @@ class LogStash::Filters::WktToGeojson < LogStash::Filters::Base
|
|
11
12
|
|
12
13
|
config :source, :validate => :string, :required => true
|
13
14
|
config :target, :validate => :string, :default => 'geo_json'
|
15
|
+
config :bbox, :validate => :string
|
14
16
|
config :tag_on_failure, :validate => :array, :default => [ '_wkt_parse_failure' ]
|
15
17
|
|
16
18
|
public
|
@@ -31,8 +33,13 @@ class LogStash::Filters::WktToGeojson < LogStash::Filters::Base
|
|
31
33
|
raise "Failed to parse to SimpleFeature"
|
32
34
|
end
|
33
35
|
|
36
|
+
if (! @bbox.nil?)
|
37
|
+
bbox = factory.geometry.bounding_box
|
38
|
+
event.set(@bbox, ([ bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y ]).to_json)
|
39
|
+
end
|
40
|
+
|
34
41
|
event.set(@target, factory.geometry.to_json)
|
35
|
-
|
42
|
+
|
36
43
|
rescue Exception => e
|
37
44
|
@logger.error('WKT Parse Error',
|
38
45
|
:wkt => wkt, :exception => e)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-wkt_to_geojson'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.4'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Logstash filter to convert WKT geography shapes to GeoJSON.'
|
6
6
|
s.homepage = 'https://github.com/kalmas/logstash-filter-wkt_to_geojson'
|
@@ -7,7 +7,7 @@ describe LogStash::Filters::WktToGeojson do
|
|
7
7
|
let(:config) do <<-CONFIG
|
8
8
|
filter {
|
9
9
|
wkt_to_geojson {
|
10
|
-
|
10
|
+
source => "geometry"
|
11
11
|
}
|
12
12
|
}
|
13
13
|
CONFIG
|
@@ -15,6 +15,23 @@ describe LogStash::Filters::WktToGeojson do
|
|
15
15
|
|
16
16
|
sample("geometry" => "POLYGON ((0.0 0.0, 5.0 0.0, 5.0 5.0, 0.0 5.0, 0.0 0.0), (2.0 2.0, 2.0 3.0, 3.0 3.0, 3.0 2.0, 2.0 2.0))") do
|
17
17
|
expect(subject.get('geo_json')).to eq("{\"type\":\"Polygon\",\"coordinates\":[[[0.0,0.0],[5.0,0.0],[5.0,5.0],[0.0,5.0],[0.0,0.0]],[[2.0,2.0],[2.0,3.0],[3.0,3.0],[3.0,2.0],[2.0,2.0]]]}")
|
18
|
+
expect(subject).to_not include("bbox")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Calculate Bounding Box" do
|
23
|
+
let(:config) do <<-CONFIG
|
24
|
+
filter {
|
25
|
+
wkt_to_geojson {
|
26
|
+
source => "geometry"
|
27
|
+
bbox => "bbox"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
CONFIG
|
31
|
+
end
|
32
|
+
|
33
|
+
sample("geometry" => "LINESTRING(10 40, 40 30, 20 20, 30 10)") do
|
34
|
+
expect(subject.get('bbox')).to eq("[10.0,10.0,40.0,40.0]")
|
18
35
|
end
|
19
36
|
end
|
20
37
|
|
@@ -40,6 +57,7 @@ describe LogStash::Filters::WktToGeojson do
|
|
40
57
|
filter {
|
41
58
|
wkt_to_geojson {
|
42
59
|
source => "geometry"
|
60
|
+
bbox => "bbox"
|
43
61
|
}
|
44
62
|
}
|
45
63
|
CONFIG
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-wkt_to_geojson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kalmas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|