Is there any way to get the values from the attributes of an object??

0
Hello! I am looking for a way to get the decimal value of an attribute and pass it to a REST routing service that I’m using. The REST url is: https://graphhopper.com/api/1/route?point=51.131,12.414&point=48.224,3.867&vehicle=car&locale=de&calc_points=false&key=api_key, where the first point is the start and the second is the end of the route.  I was thinking of creating RouteStart and RouteFinish objects, in order to get the latitude, longitute of each and saving them. Is there a way of getting the decimal values of latitude and longitude from both objects and passing them to the URL? I tried using the attribute variables as arguments in the URL but I got an error. Any help is appreciated!
asked
3 answers
2

With an entity route available with the 2 attributes you need, create a string linke below:

https://graphhopper.com/api/1/route?point=’ +$route/lat+’&point=’+$route/long+’&vehicle=car&locale=de&calc_points=false&key=api_key

Assuming the route entity has the attributes long and lat.

Now pass this string as the argument to the REST call and you’ll end up with the call to the endpoint as described in the question. If this does not work, check what the content of the string is by using the debugger and a breakpoint in the microflow.

answered
0

Thank you for the answer, I didn’t think I had to place the attributes in such way in the REST string but I’ll try it out!

answered
0

These days I tried the idea you suggested. The issue with the route is that it doesn’t have 2 attributes only, it has 2 attributes for the route start coordinates and 2 for the route end, it’s like tuples [RouteStartLat,RouteStartLong], [RouteEndLat,RouteEndLong].

I had the idea of creating 2 entities, named RouteStart and RouteEnd, and each one of these has the corresponding tuples as mentioned above. They are related with the Route entity (the attributes in the Route entity were added last night just to test some issues). I’m not sure which idea is the best though, but if I can recall the process of creating a route in OpenStreetMaps, you first have to declare a start and then a finish for the route to be created. That’s where I based my idea of having 2 different entities for the start and the end of the route.

The REST service I’m using is working fine with decimal values instead of variables. I know this because the number of the API-key usage was increasing (Graphhopper offers that functionality through your profile). I also tried debugging this issue when I was using variables instead of numerical values as you suggested, but I wasn’t able to see the content of the string for some reason (it produced an error 400, which means that the contents of the URL string were not set up properly). The tutorial I followed for consuming REST services is this one: https://docs.mendix.com/howto/integration/consume-a-rest-service

Another issue I noticed is that I was able to successfully call the REST service but I have another issue, there is no line drawn between the points. I’m not that familiar with the MapView widget and I noticed that there is a tab named Routes. For the first selections, it was requested that I should have persistable entities and that’s why I changed all entities to persistable ones in the domain model (something that was in conflict with the tutorial, if you see it doesn’t require persistable entities). For the Coordinate source tab, I used the MapView entity. 

 

answered