谷歌地图Android:将折线折叠到街道(Google Maps Android: snap polyline to street)
使用谷歌地图Android v2,我如何捕捉使用折线绘制的路线或只是连接到街道的点?
我从Google Play服务获取位置,但是通常情况下通常在5-10米左右,所以积分不是直接在街上,而是有点不对。
Using Google Maps Android v2, how can I snap a route drawn with a polyline or just the points that are getting connected to a street?
I am getting locations from Google Play Services, but accurency is usually around 5-10 meters, so points are not directly on the street, but a bit wrong.
原文:https://stackoverflow.com/questions/17419973
最满意答案
sed -n 's/\[\(.*\)\]/\1/p' file
说明:-n禁止将每行打印到STDOUT,但正则表达式末尾的
/p
重新启用此行为,从而导致打印所有匹配的行。 正则表达式本身匹配括号之间的所有内容,并用它替换整行。sed -n 's/\[\(.*\)\]/\1/p' file
Explanation: -n suppresses the printing of each line to STDOUT, but the
/p
at the end of the regex re-enables this behavior causing all matching lines to be printed. The regex itself matches everything between brackets and replaces the entire line with it.
相关问答
更多-
grep 与 awk 有什么区别?[2022-07-01]
grep基本是以行为单位处理文本的; 而awk可以做更细分的处理,通过指定分隔符将一行(一条记录)划分为多个字段,以字段为单位处理文本。awk中支持C语法,可以有分支条件判断、循环语句等,相当于一个小型编程语言。 二者都支持正则匹配。 -
awk和grep存在(awk and grep for existence)[2021-10-02]
如果你有GNU grep; grep -f - file 如果没有,你可以从awk打印出一个sed脚本,或者创建一个稍微复杂的awk脚本。 或者只是将输出加入一个大的egrep表达式; egrep "$(awk -F'"' '{ printf ("%s%s", j, $2); j="|" }' input)" If you have GNU grep; grep -f - file If not, you could print out a sed script from awk, or maybe ... -
简短定义: grep :搜索文件中的特定术语 #usage $ grep This file.txt Every line containing "This" Every line containing "This" Every line containing "This" Every line containing "This" $ cat file.txt Every line containing "This" Every line containing "This" Every line cont ...
-
使用grep或awk(Using grep or awk)[2022-09-28]
这是一个awk版本(你问awk) awk '/AM|PM/ && NF--; /a =/ {print "a = "$(NF-6),"b = "$(NF-3),"c = "$NF}' file Oct 07, 2014 7:39:10 AM a = 0 b = 0 c = 0 另一个版本: awk '/AM|PM/ && NF--; {n=split($0,a,"abcd");if (n==2) print "abcd"a[2]}' file Oct 07, 2014 7:39:10 AM abcd = ... -
你可以用这个: awk '/^Amount/ {amount+=$2} END {print amount+0}' file 使用+0技巧,如果未设置值,则使其打印0 。 说明 没有必要grep + awk。 awk一个人可以grep(以及更多的东西!): /^Amount/ {}以“金额”开头的行上的/^Amount/ {} ,执行{} 。 amount+=$2将字段2的值添加到计数器“金额”。 处理完整个文件后END {print amount+0} ,打印amount值。 如果之前未设置,则执行+0 ...
-
我在OP的评论中看到,也许问题不再是问题。 但是,下面的细微修改将处理空行情况。 只需添加一个检查以确保该行至少有一个字段: grep "$(awk '{if (NF > 0) print $1}' file1)" file2 如果带有模式的文件只是每行一组模式,那么它的简单版本就是: grep -f file1 file2 这会导致grep使用file1中的行作为模式。 I see in the OP's comment that maybe the question is no longer a q ...
-
问题与Awk&Grep(Problem with Awk & Grep)[2023-11-21]
wmctrl -lp | awk '/Firefox/ { print $1 }' 不需要grep。 Awk会这样做。 此外默认的字段分隔符是空格,所以不需要指定。 另外,围绕你的awk脚本使用单引号,这样shell不会扩展$ 1。 这就是你的脚本失败的原因。 $ 1变成了什么都没有,你的awk动作变成了“打印”,它打印出整条线。 wmctrl -lp | awk '/Firefox/ { print $1 }' No need for grep. Awk will do that. Also the ... -
Lars Fischer在评论中回答了这个问题。 这个社区wiki帖子正式化(并改进)它。 要仅为搜索词着色,可以使用带有这些颜色代码的全局替换( gsub ): awk 'BEGIN { RS=">"; FS="\n" } gsub(/GATTACA/, "\033[0;32m&\033[0m", $0)' file 这将记录分隔符( RS )设置为>而不是默认\n (换行符)和字段分隔符( FS )为\n而不是其他空白字符的默认值。 然后,它对该查询执行全局替换,将文本替换为正确颜色代码所包围的文本。 ...
-
如何通过awk使用grep?(How to use grep via awk?)[2021-11-23]
在Gnu Awk中,您可以使用\<和\>来匹配单词的开头和结尾,所以 gawk '/\/{++i} END{print i}' 会做同样的事情 grep -wc 'GOOD' file 如果你想计算GOOD这个词的出现总数(不仅是行数,还有给定行/记录中的出现次数),你可以在Gnu Awk版本4中使用FPAT , gawk 'BEGIN { FPAT="\\ "; RS="^$" } { print NF }' file 如果要计算给定记录中短语GOOD DI的完全匹配数, ... -
awk或grep问题(Awk or grep question)[2022-05-04]
sed -n 's/\[\(.*\)\]/\1/p' file 说明:-n禁止将每行打印到STDOUT,但正则表达式末尾的/p重新启用此行为,从而导致打印所有匹配的行。 正则表达式本身匹配括号之间的所有内容,并用它替换整行。 sed -n 's/\[\(.*\)\]/\1/p' file Explanation: -n suppresses the printing of each line to STDOUT, but the /p at the end of the regex re-enables ...