type sols3json.json | jq-win64.exe "[.[] | { "type": "FeatureCollection","features":[{ type: "Feature", "geometry": {"type": "LineString","coordinates": [ [.OpStartLongitude, .OpStartLatitude| tonumber], [ .OpEndLongitude, .OpEndLatitude | tonumber] ] }, properties: {name: .SolName}}]}" > sols3.geojson
我得到jq:错误:语法错误,意外的$ end(Windows cmd shell引用问题?) 我究竟做错了什么? 输出应如下所示:
{
"type": "FeatureCollection",
"features":
[
{
"properties": {
"ccaa": "CATALUNYA",
"prov": "LLEIDA",
"dir": "N-IIA/SOSES/TORRES DE SEGRE/ALCARRàS",
"roadnumber": "A-2",
"tmc": "E17+02413"
},
"geometry": {
"coordinates": [
[
0.4714937,
41.5420936
],
[
0.4891472,
41.5497014
]
],
"type": "LineString"
},
"type": "Feature"
}
]
}
答案 0 :(得分:0)
您的问题尚不清楚,但是我理解正确,这很可能是您想要的。
提供的输入文件是:
[
{
"TMC": "E17+02412",
"ROADNUMBER": "A-2",
"DIR": "E-90/AP-2/BARCELONA-ZARAGOZA (SOSES)",
"PROV": "LLEIDA",
"CCAA": "CATALUNYA",
"StartLatitude": "41.5368273",
"StartLongitude": "0.4387071",
"EndLatitude": "41.5388396",
"EndLongitude": "0.4638462"
}
]
您可以使用以下jq
过滤器过滤内容:
jq 'map({ type: "Feature", "geometry": {"type": "LineString","coordinates": [ [.StartLongitude, .StartLatitude| tonumber], [ .EndLongitude, .EndLatitude | tonumber] ] }, properties: {tmc: .TMC, roadnumber: .ROADNUMBER, dir: .DIR, prov: .PROV, ccaa: .CCAA}})' file
产生新的JSON数据:
[
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
0.4387071,
41.5368273
],
[
0.4638462,
41.5388396
]
]
},
"properties": {
"tmc": "E17+02412",
"roadnumber": "A-2",
"dir": "E-90/AP-2/BARCELONA-ZARAGOZA (SOSES)",
"prov": "LLEIDA",
"ccaa": "CATALUNYA"
}
}
]