Skip to content

sibenye/logstash-filter-wkt_repair

Repository files navigation

WKT or GeoJson Repair Logstash Filter

Gem Version

Repairs WKT or GeoJson Polygons/Multipolygons on a Logstash event that are ambiguous or ill-defined and returns a coherent and clearly defined output.

Examples of ambigous or ill-defined polygons include, but not limited to:

  • A polygon with dangling edge
  • A polygon that is not closed
  • A polygon that self intersects

Config example

{
    ...
    filter {
        wkt_repair {
            source => "wkt"
            target => "wkt_repaired"
            type => "WKT|GeoJson"
            tag_on_failure => [ "_wkt_repair_failure" ]
        }
    }
    ...
}

Dependencies

Yeah, unfortunately, this plugin depends on your server/container having these installed;

Dependency installation

Run the following commands to install the dependencies;

Installing cmake:

wget https://cmake.org/files/v3.9/cmake-3.9.3.tar.gz
tar xzf cmake-3.9.3.tar.gz
cd cmake-2.8.3
./configure --prefix=/opt/cmake
make
make install

Add /opt/cmake/bin to your $PATH

Installing CGAL:

apt-get install libcgal-dev

Installing GDAL:

apt-get -y install libgdal-dev
apt-get -y install gdal-bin

Installing prepair:

wget https://github.com/ForRentCom/prepair/archive/master.zip
unzip prepair-master.zip -d /opt
mv /opt/prepair-master /opt/prepair
cd /opt/prepair
cmake .
make

Add /opt/prepair to your $PATH

Developing

1. Plugin Developement and Testing

Code

  • To get started, you'll need rvm, JRuby and the Bundler gem installed.
\curl -sSL https://get.rvm.io | bash -s stable
rvm install jruby
jruby -S gem install bundler
  • Install dependencies
bundle install

Test

  • Update your dependencies
bundle install
  • Run tests
bundle exec rspec

2. Installing and Running the plugin locally

  • Build the plugin gem
gem build logstash-filter-wkt_repair.gemspec
  • Install the plugin from the Logstash home
bin/logstash-plugin install /your/local/plugin/logstash-filter-wkt_repair.gem
  • Start Logstash and proceed to using/testing the plugin

3. Installing the plugin from rubyGems

  • To install the plugin from rubyGems
bin/logstash-plugin install logstash-filter-wkt_repair.gem

For walk through of developing Logstash filter plugin see https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html

About

Logstash filter to repair a WKT or GeoJson shape data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages