SymbolixAU / googleway

R Package for accessing and plotting Google Maps
http://symbolixau.github.io/googleway/
Other
234 stars 46 forks source link

Backslashes #221

Closed sethsamuels closed 4 years ago

sethsamuels commented 4 years ago

The function seems to fail when there is a backslash in the encoded polyline. The following polyline can be converted manually, but fails when run through the function (presumably because it wants to treat it as two slashes instead of four):

ayanGfiq_LbDWlCk@dAQfASl@IfAUf@Sd@[f@[VWXc@Nw@TgB|@sIb@gBhAeD??rDf@xCoPfEwJTaBxAmNv@kCrByB~HoD`GeExK{FbCqB`BiBfE}FlEoHrCyFrBqClDi@rARbCr@rEZbCBnCbAvE~CxAl@rANlAGdBs@h@_@|AcCrB_FtAcBhAeA|Ae@lDCxAt@~AdBlBnG`@jC`A`D~@|AvBhBxATf@CpBN`G|@dCb@L@tCvAhFbCxBd@nEr@lBb@TFTBB?J?B?HCHK??oEoCuFwBmAcAsAcEIsCNgDnAwGpAwCxCeF~BgCtFyBrGmB|As@dBkDNaB_@yCs@kB_CcAwBF{C|@yAPwAO_Bw@y@_AsAiFCgB\\\\wBhB{C~A}AzDyBnF_E|CaDlEoK|AmCnAyC^aLr@cE~CeIp@cAP_AZg@vBgFj@eAfAaAbA]dAIdCCvBUpGuBhCFvBb@hC`AnBN~AOhA]t@Y??{EcG{AyCiB}EcBmDcA}AiCuCuAgAgAe@wA[oAGwA?wAN_Db@S@}@Hi@Bk@EkCo@kBa@EEyBc@k@KcAO}@A{BTyCbAiEbBeAl@iB~@uAp@oCfAuD`BeE~DiB`CsEtDsB`@mCZgCp@q@JeEv@mD|@gAN]NcAToAXmNjB?D

I realize this issue may be on the Rcpp end, but it seems fairly common for encoded polylines to have backslashes, so I think this is a non-trivial problem.

Also, sorry if you're already aware of this--I tried searching your repo and couldn't find anything about it.

dcooley commented 4 years ago

Thanks for reporting this - it's definitely a bug that needs to be handled.

sethsamuels commented 4 years ago

Glad I can help! I tried using stringi to wrap it with the stri_escape_unicode function, and I tried adding extra backslashes to escape them, and neither approach seems to have worked for me, just fyi.

dcooley commented 4 years ago

How did you generate this polyline?

sethsamuels commented 4 years ago

Sorry, just saw this. I scraped the polylines from this page: https://trips.furkot.com/widget/byway/13791.

After fidgeting with it a bit, I think the four backslashes are maybe actually supposed to be two, and R is rendering it as 4, but I'm not sure (and it doesn't seem to make much of a difference in the resulting coordinates).

FWIW, I ended up using the @mapbox/polyline package and routing it all through the command line.

dcooley commented 4 years ago

yeah I don't think this is actually a bug, and given you've scraped the polyline, rather than generated it from coordinates, I think you've also scraped the escape \ too.

sethsamuels commented 4 years ago

Ohhhh, huh. Sorry about that!