Logstash - Calculate a midpoint from a Geo polygon

Hello,

I want to calculate a midpoint from a geo-polygon. I know I should use the ruby filter but I don't know how.

My formula looks like this:

pmidlat = plat2 - ((plat2 - plat3) / 2)
pmidlong = plong4 - ((plong4 - plong3) / 2)

My geo polygon is an array with nested fields and looks like this:

"StageLocation": [

{"GPSHeight": 0, "GPSLatitude": 44.13380000000005, "GPSLongitude": 39.126500000000064},
{"GPSHeight": 0, "GPSLatitude": 44.13380000000005, "GPSLongitude": 39.06050000000006},
{"GPSHeight": 0, "GPSLatitude": 44.06780000000005, "GPSLongitude": 39.06050000000006},
{"GPSHeight": 0, "GPSLatitude": 44.06780000000005, "GPSLongitude": 39.126500000000064}

],

Could anybody help me or give me some advice? Thank you so much!

This is my *.conf file:

input {
kafka {
bootstrap_servers => "localhost:9092"
topics => ["flink_to_apama"]
client_id => "logstash_hub"
}
}
filter {
json {
source => "message"
}
split {
field => "Impacts"
}
mutate {
rename => { "[Impacts][Location]" => "[Ort]"}
}
split {
field => "[Ort][StageLocation]"
}
ruby{

}
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "itesa_risks"
document_type => "doc"
template => "/tmp/logstash_vol/itesa_mapping.json"
template_overwrite => true
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.