points decodePath function, having geometry directly - graphhopper

in graphhopper the points are encoded then decoded in javascript
but i'd like to have the points not encoded, how is it possible ?
is there a php alternative of the decodePath(encoded, is3D) function ?
thanks

There is only a Javascript and Java version at the moment in GraphHopper but it shouldn't be hard to write one in PHP. Or see the docs on how to disable encoded polylines.

Related

Json Special Characters

I have a json object which contains some values that include some special chracter. For example {UserName":"UserTest","Password":"OImqNlK/tLwUzKnt1rA1OA=="}
I use it as an object parameter to call to web Api but I can't get it on Api server.
it works fine if I remove the special characters. For example:
{UserName":"UserTest","Password":"OImqNlKtLwUzKnt1rA1OA"}
Please help me fix it. Many thanks!
First page when I put "Json Special Characters" into google : here
To be concrete to your question, this is the way
{UserName":"UserTest","Password":"OImqNlK\/tLwUzKnt1rA1OA=="}

WSo2 API Manager 1.8.0 - JSON parsing issue

I am new to wso2 API Manager, trying to set it up expose my plain HTTP POST back end calls as a REST API. I am sure this is not a new pattern that I am trying to achieve here. The requirement is to convert the JSON data coming in (has array structures) into the HTTP URL query string parameters.
After some research through the documentation and other posts on this forum, decided to go with the script mediator that would parse the JSON data and convert it to a string that can be appended to the endpoint URL. Some how I am not able to achieve this.
I have followed the following post that seems to be very straight forward. As the original poster suggested, I am also not able to use getPayloadJSON() method. Even have trouble using the work around suggested there due to JSON.parse() not working.
Link
Also, this approach of editing the service bus configuration from source view does not sound like the correct option. Is there another elegant solution to achieve this? Thanks for the help in advance.
I was able to get both methods working by using an external script instead of the inline java script. Thanks

JSON parsing in NODE

I'm trying to figure out why my parsed request(a json from an jquery ajax, cross domain) is looking a bit strange.
GET /sendjsondata?callback=_testcb&{%22amount%22:1800,%22name%22:%22Vasy%20Jon%22,%22cnp%22:232323,%22coborrower%22:true,%22device%22:%22Desktop%22}&_=1415883870387 404 3.346 ms - 1303
I can create a function to retrieve the piece between braces and then applying a new polish to remove "%22", but I think that I'm dooing a mistake somewhere in my code and that's why I don't obtain a clean json object and maybe someone can tell me where is the issue.
Thank you.
URLs use a special encoding to represent special characters. %22 equals ". Whatever framework you are using should take care of decoding this. Otherwise look for urlencode()/urldecode() functions.

Passing an HTML parameter in routes (Play framework)

Good day! How are HTML parameters expressed in the routes file? I am trying to pass an HTML but I don't know how. All I know are passing integers ((id: Integer)) and some data types. I tried (content: Html)and (content: Html). I also tried javax.swing.text.html.HTML but it says something about QueryStringBindable. Please help me. Thanks a lot.
Remember that all you pass by route's params will be included in the URL so what is the advantage of using HTML in this place ? GET params should use only simple data types like numerical types, booleans and strings - so you can pass some HTML part as a String (preferably url-encoded or even beter with Base64 encoding).
Much better option is sending it via POST, your URLs won't be terrible long - you won't hit any limitation of URL length, also after common serialization it won't break at special HTML chars.

How to get Google Maps Public Transit Directions by HTTP server-side request

I use such urls like:
http://maps.google.com/?saddr=546%206th%20Avenue,%20New%20York,%20NY%2010011%20(Sixth%20Avenue,%20New%20York)&daddr=W%20103rd%20St,%20New%20York,%20NY%20&dirflg=r
But it returns full html page. Does anybody know how to get such info in json or xml or any parsable format?
I need public transit.
You just add &output=json to the end of the url.
I'd like to extend Mathias's answer a little bit.
There's no official Google Transit API at the momemnt. Transits are provided by agencies, and most of Transits are not public. So, Google is not allowed to open them as API.
You may try to consume the "unofficial" data using your link + "&output=json".
However, the result won't be a valid JSON. Instead, that's something, that can be easily converted to a JavaScript object. (The differences are: there is no quotes around property names,
the strings are not properly encoded etc.)
Imagine you got this JavaScript object. However, it won't allow you to easily get the structured route details. Object's properties contain the route points coordinates, but no descriptions. The only place where the descriptions may be found is 'panel' property, which contains a chunk of HTML text (you may find a link to the sample of HTML in my blog post)
So, you'll have to convert this HTML into XML (X-HTML) and then build the parser of this XML to get the essence data of a trip.
Seems like a bit of overkill to me. Having in mind, that "unofficial" API may change in the future, including slight changes in 'panel' HTML structure that will kill your parser.
#MathiasLin, how did you overcome this?
Google Maps Javascript v3 and the Directions Web Service now has this capability as per :
https://googlegeodevelopers.blogspot.in/2012/06/public-transit-routing-and-layer-now.html
Update:
Latest server side API docs:
https://developers.google.com/maps/documentation/directions/get-directions
Re choosing public transport - it seems that it defaults to public transport now (at least when I use it).
Changing the last URL parameter, dirflg=r, into dirflg=w switches the directions to walking mode.
Plus see:
Walking, bicycle and public transport directions with time required in each mode , iPhone
for more detail about the parameters.
Google direction API response is in HTML, JSON format please check https://developers.google.com/maps/documentation/javascript/directions?hl=lv
& section 'The DirectionsResult Object'