[OSRM-talk] (no subject)
Romain NKONGO
romain.rnk49 at gmail.com
Wed Feb 25 10:14:02 UTC 2015
Hello again,
I didin't manage to handle leaflet-routing-machine in my JS code. I
installed the modules leaflet-routing-machine, corslite and polyline with
NodeJS (npm install <module>) but some errors pop up about
L.Routing.OSRM.route not being defined. If I manage to use this library, I
could start my automated tests and go on withmy project. Any help or
example of how you used it personnally?
Thanks.
2015-02-17 9:15 GMT+01:00 Romain NKONGO <romain.rnk49 at gmail.com>:
> Another topic for you : in addition of the time criterion, I would like to
> add a second criterion regarding the cyclability of the ways (an index
> between 1 and 5, 5 being the best cyclability).
>
> Until now, I've been looking in the code for classes that take the speed
> weight for ways as an attribute, considering that this second could fit in
> these classes too. Until I found it in the classes : ExtractionContainers,
> Contractor, ImportEdge, NodeBasedGraph, EdgeBasedGraph, QueryEdge and
> EdgeBasedNode.
>
> Any clue on another class to look into or a better way to integrate a new
> criterion for routing into OSRM?
>
> 2015-02-12 16:38 GMT+01:00 Romain NKONGO <romain.rnk49 at gmail.com>:
>
>> Ok, so after reading the Leaflet file, it seems to be an appropriate way
>> to send a HTTP request to the server and get the response back as variables
>> I could process in my script. Now I wonder how I could take this
>> interesting piece of code and adapt it to my AngularJS implementation.
>>
>> 2015-02-12 15:00 GMT+01:00 Romain NKONGO <romain.rnk49 at gmail.com>:
>>
>>> Thanks to all for your suggestions.
>>>
>>> To Guillaume : I searched about the $http.get function and I wrote this
>>> function to test if all goes well (I think I've tried it before) :
>>> var getItinerary2=function(){
>>> $http.get("
>>> http://localhost:5000/viaroute?loc=47.3654647,0.6822917&loc=47.3905003,0.6920979&compression=false
>>> "
>>> .success(function(data, status, headers, config) {
>>> console.log(data);
>>> }).
>>> error(function(data, status, headers, config) {
>>> console.log("error");
>>> });
>>> };
>>>
>>> Then I call it when I press Submit but the error function is triggered
>>> (the browser console prints "error").
>>> Am I doing something wrong?
>>>
>>> To Patrick : I will take a look at the JS file to find what could be
>>> helpful. But, to be clear, what I'm trying to do is send a query to the
>>> OSRM server and get back the response in the backend, in my script, not
>>> directly in frontend, as I want to extract some information from the output.
>>>
>>> To Emil : I saw the Cucumber Suite in the OSRM project but those are
>>> precomputed tests, with known responses to the requests. In my case, I will
>>> run tests on a large map (OSM file size : 122 Mo) with random locations
>>> pairs inside the area.
>>>
>>> 2015-02-12 13:47 GMT+01:00 Emil Tin <emil at tin.dk>:
>>>
>>>>
>>>> The OSRM project includes a set of cucumber tests that does a lot of
>>>> testing of binaries, including preparing data and querying the server. It’s
>>>> ruby based but maybe it can help you. Look in the folder features/. The
>>>> various support files that queries osrm are in features/support/
>>>>
>>>> See
>>>> https://github.com/Project-OSRM/osrm-backend/wiki/Cucumber-Test-Suite for
>>>> more.
>>>>
>>>>
>>>> Emil
>>>>
>>>>
>>>>
>>>> On 12 Feb 2015, at 10:46 , Romain NKONGO <romain.rnk49 at gmail.com>
>>>> wrote:
>>>>
>>>> Hello to all the OSRM community.
>>>>
>>>> I'm a french student who works on a university project, along with my
>>>> supervisor and uses the open source project OSRM to achieve it.
>>>>
>>>> At some point, I have to run some tests (like thousands of tests) to
>>>> extract some values from the JSON outputs (e.g. the total time). Now our
>>>> problem is we tried several ways to do this, by sending HTTP GET requests
>>>> to the running server and treat the returned response as JSON. But we tried
>>>> with Javascript, jQuery and AngularJS, with functions like $resource.get,
>>>> jQuery.getJSON $http.get or $http.jsonp and we never managed to get the
>>>> returned response in a way that we could use it for further treatment in
>>>> our script. Actually, we were able to send the requests to the server but
>>>> the response is returned in the fom of an URL link which contains the JSON
>>>> output in its body, not in the form of a variable in our Javascript that we
>>>> could manipulate.
>>>>
>>>> As a matter of fact, we have two issues for this :
>>>> - some of the functions we used (which are based on jsonp) added a
>>>> callback parameter to the sent URL, so the request became invalid with
>>>> 'Query malformed at the position' errors
>>>> - I've seen in the OSRM documentation that the JSON output is encoded
>>>> with the Google polyline algorithm so it could be an invalid JSON for
>>>> Javascript (we also observed errors like SyntaxError: JSON.parse:
>>>> unexpected end of data at line 1 column 1 of the JSON data
>>>>
>>>> We essentially want to use the viaroute service, so our URL is
>>>> something like that : "htttp://localhost:5000/viaroute?loc=a,b&loc=c,d"
>>>> with a,b, c and d random float numbers.
>>>>
>>>> Has anyone ever tried to run some customized tests on OSRM, with any
>>>> Web language, and if so can he give me some tricks of how he succeeded to
>>>> get the JSON ouptut where he wanted?
>>>>
>>>> To be clearer of how I proceeded in AngularJS, here the code of my
>>>> app.js :
>>>> var app = angular.module('clientOSRM', ['ngResource']);
>>>>
>>>> app.controller('appController', ['$scope','$http', 'appServices',
>>>> function ($scope,$http, appServices) {
>>>> //Initialisation de notre input, sa valeur sera stockée en
>>>> instantané dans cette variable (ng-model)
>>>> $scope.valueInput1 = "47.3654647,0.6822917";
>>>> $scope.valueInput2 = "47.3905003,0.6920979";
>>>>
>>>>
>>>> var getItineraryParams = function () {
>>>> return {
>>>> start: $scope.valueInput1,
>>>> end: $scope.valueInput2
>>>> //start: "47.3654647,0.6822917",
>>>> //end: "47.3905003,0.6920979"
>>>> //start: "a,b",
>>>> //end: "c,d"
>>>> }
>>>> };
>>>>
>>>> //Une fonction accessible que dans ce controleur (mot clé var)
>>>> var getItinerary = function () {
>>>> appServices.osrm.get(getItineraryParams(),
>>>> function (itinerary) {
>>>> alert("Succes : "+typeof itinerary);
>>>> console.log(itinerary);
>>>> },
>>>> function (error) {
>>>> alert("erreur : "+typeof error+"; status : "+error.status);
>>>> console.log(error);
>>>> }
>>>> );
>>>> /*$http.jsonp("
>>>> http://localhost:5000/viaroute?loc=47.3654647,0.6822917&loc=47.3905003,0.6920979&alt=false&geometry=false&output=json
>>>> ")
>>>> .success(function(data, status, headers, config) {
>>>> console.log(data);
>>>> }).
>>>> error(function(data, status, headers, config) {
>>>> console.log(data);
>>>> });*/
>>>>
>>>> };
>>>>
>>>> //Une fonction accessible depuis la vue
>>>> //Fonction appelée à l'envoi du formulaire (balise ng-submit dans
>>>> <form>)
>>>> $scope.submit = function () {
>>>> //On peut récupérer la valeur de notre input !
>>>> //console.log($scope.valueInput1);
>>>> getItinerary();
>>>> };
>>>> }]);
>>>>
>>>> app.run(function ($rootScope) {
>>>>
>>>> $rootScope.safeApply = function (fn) {
>>>> var phase = $rootScope.$$phase;
>>>> if (phase === '$apply' || phase === '$digest') {
>>>> if (fn && (typeof(fn) === 'function')) {
>>>> fn();
>>>> }
>>>> } else {
>>>> this.$apply(fn);
>>>> }
>>>> };
>>>>
>>>> });
>>>>
>>>> and also the appServices.js code :
>>>> app.factory('appServices', function ($resource) {
>>>>
>>>> return {
>>>> osrm: $resource("", {}, {
>>>> 'get': {
>>>> method: 'GET',
>>>> params: {start: '@start', end: '@end'},
>>>> isArray:true,
>>>> url: "
>>>> http://localhost:5000/viaroute?loc=:start&loc=:end&alt=false&geometry=false
>>>> "
>>>> }
>>>> })
>>>> };
>>>> });
>>>>
>>>> In the getItinerary function in app.js, the error function (the 3rd
>>>> parameter) is always triggered even with a HTTP status code '200 OK' of the
>>>> request.
>>>>
>>>> Any ideas where it could go wrong?
>>>>
>>>> Thanks in advance.
>>>>
>>>>
>>>> _______________________________________________
>>>> OSRM-talk mailing list
>>>> OSRM-talk at openstreetmap.org
>>>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> OSRM-talk mailing list
>>>> OSRM-talk at openstreetmap.org
>>>> https://lists.openstreetmap.org/listinfo/osrm-talk
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20150225/63e206e9/attachment.html>
More information about the OSRM-talk
mailing list