我已经解决了这个问题好几天了,但是找不到我做错的解释。我希望你能伸出援助之手。
我有一组UTM坐标filter {
grok {
match => { "message" => [
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} fd=%{NUMBER:file_descriptor} slot=%{NUMBER} %{WORD:connection_method} connection from %{IP:source} to %{IP:destination}$",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} %{NOTSPACE:ssl_version} (?<encryption_method>%{NOTSPACE} %{NOTSPACE})$",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} op=%{NUMBER:op_number} %{WORD:ldap_operation} dn=%{QUOTEDSTRING:user_dn} method=%{NOTSPACE:bind_method} version=%{NUMBER:ldap_version}($)?(mech=%{NOTSPACE:auth_mechanism}$)?",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} op=%{NUMBER:op_number} %{WORD:ldap_operation} err=%{NUMBER:error_code} tag=%{NUMBER:tag_number} nentries=%{NUMBER:number_of_entries} etime=%{NUMBER:operation_time}($)?(dn=%{QUOTEDSTRING}$)?",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} op=%{NUMBER:op_number} %{WORD:ldap_operation} base=%{QUOTEDSTRING:search_base} scope=%{NUMBER:search_scope} filter=%{QUOTEDSTRING:search_filter} attrs=%{QUOTEDSTRING:search_attributes}$",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} op=%{NUMBER:op_number} %{WORD:ldap_operation}$",
"^(\s)?\[%{HTTPDATE:timestamp}\] conn=%{NUMBER:connection_id} op=%{NUMBER:op_number} fd=%{NUMBER:file_descriptor} %{WORD:connection_result} - %{WORD:connection_code}$"
]
}
}
if "" in [connection_method] {
aggregate {
task_id => "%{connection_id}"
code => "
map['timestamp'] = event['@timestamp']
map['tags'] ||= ['aggregated']
map['source'] = event['source']
map['destination'] = event['destination']
map['file_descriptor'] = event['file_descriptor']
map['connection_method'] = event['connection_method']
"
map_action => "create"
}
}
else if "" in [connection_code] {
mutate {
add_tag => [ "map_finished" ]
}
aggregate {
task_id => "%{connection_id}"
code => "
map['operations'][event['op_number']]['connection_code'] = event['connection_code']
map['operations'][event['op_number']]['connection_result'] = event['connection_result']
"
map_action => "update"
}
}
else {
aggregate {
task_id => "%{connection_id}"
code => "
map['@timestamp'] = map['timestamp']
"
timeout => 0
push_map_as_event_on_timeout => true
}
}
}
,我希望通过使用适用于C ++ {0}的proj4库将其转换为LongLat坐标(epsg:23030)
。我的代码如下:
(epsg:4326)
我对函数(libproj-dev)
的调用:
#include "proj_api.h
#include <geos/geom/Coordinate.h>
geos::geom::Coordinate utm2longlat(double x, double y){
// Initialize LONGLAT projection with epsg:4326
if ( !( pj_longlat = pj_init_plus("+init=epsg:4326" ) ) ){
qDebug() << "pj_init_plus error: longlat";
}
// Initialize UTM projection with epsg:23030
if ( ! (pj_utm = pj_init_plus("+init=epsg:23030" ) ) ){
qDebug() << "pj_init_plus error: utm";
}
// Transform UTM projection into LONGLAT projection
int p = pj_transform( pj_utm, pj_longlat, 1, 1, &x, &y, NULL );
// Check for errors
qDebug() << "Error message" << pj_strerrno( p ) ;
// Return values as coordinate
return geos::geom::Coordinate(x, y)
}
在我的例子中:
utm2longlat
指的是 LongLat 坐标...
// UTM coordinates
double x = 585363.1;
double y = 4796767.1;
geos::geom::Coordinate coord = utm2longlat( x, y );
qDebug() << coord.x << coord.y;
/* Result is -0.0340087 0.756025 <-- WRONG */
。 (585363.1 4796767.1)
。 我想知道在初始化投影时是否有任何错误配置,所以我决定测试Proj4 Python绑定(-1.94725 43.3189)
,只是为了测试我是否得到了相同的错误坐标...而且奇怪的是,我得到了好的。
(-0.0340087 0.756025 )
据我所知,(pyproj)
是from pyproj import Proj, transform
// Initialize UTM projection
proj_utm = Proj(init='epsg:23030')
// Initialize LongLat projection
proj_lonlat = Proj(init='epsg:4326')
x_utm, y_utm = 585363.1, 4796767.1
x_longlat, y_longlat = transform(proj_utm, proj_lonlat, x_utm, y_utm)
// Print results
print "original", x_utm, y_utm
print "utm2lonlat", x_longlat, y_longlat
/* Result is -1.94725 43.3189 <-- CORRECT */
库上的一组Cython绑定,所以我在两种编程语言中使用相同的核心。
你有什么可能出错的线索吗?我在C ++函数中缺少某种类型的转换吗?
提前致谢。
答案 0 :(得分:2)
结果似乎对我来说是正确的,但它以弧度而不是度数返回。将结果转换为度数并再次检查。