WebService call using R - r

I have a list of Port origin and destination location for marine transportation.I want to estimate the average time taken to travel from one port to another. I just came across the webservice request provided by Vesseldistance.com
How to call this web service from R and Is it possible to send bulk of port origin and destination locations to estimate the avg time taken to travel?

Yes, for example using httr you can wrap their sample GET request into a call form R:
httr::GET("http://vesseltracker.com/FILE?user=foo&pass=bar&fromLon=9.9&fromLat=53.54&toLon=47&toLat=11&speed=20&startTime=1&numOfRoutes=ALL")
Unfortunately their API is not documented very well.

Related

Can I get\download the traffic flow data of a specific date and time?

Is there a way to get the traffic flow data of a specific date and time?
For example, the below request gives real-time traffic data.
https://traffic.ls.hereapi.com/traffic/6.1/flow.json?bbox=29.6890%2C-95.4008%3B29.7165%2C-95.5007&apiKey={API_KEY}
How can I specify date-time here? Thanks.
HERE provides several ways to get the historical traffic information:
Get the Traffic Pattern from HERE Map Content catalog
https://developer.here.com/documentation/here-map-content/dev_guide/topics-attributes/traffic-pattern-attributes.html
Get the Traffic Pattern from Mobile SDK
https://developer.here.com/documentation/android-premium/3.19/dev_guide/topics/traffic-history.html
Get the Traffic Pattern and Speed from HERE Map Attributes API with TRAFFIC_PATTERN_FC* layers and TRAFFIC_SPEED_RECORD_FC* layers.
https://developer.here.com/documentation/content-map-attributes/dev_guide/topics/here-map-content.html

is there a batch request api for HERE maps routing?

The documentation shows how to submit a batch request to the geocoder api. Is there also a documentation for sending batch requests to the routing api so that I can send several start/destination waypoints at once?
The Matrix routing API is exactly what you want. In this example the matrix routing calculates all combinations between 3 start points and 5 destination points. Here is the request taken from the example:
https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json?start0=52.5139%2C13.3576&start1=52.5214%2C13.4155&start2=52.5253%2C13.3693&destination0=52.5411%2C13.2127&destination1=52.5163%2C13.3780&destination2=52.4920%2C13.2849&destination3=52.4987%2C13.5228&destination4=52.5547%2C13.4578&mode=fastest%3Bcar&summaryattributes=all&apiKey=YOUR_API_KEY
The response contains 15 route summaries which contain distance, travelTime, costFactor and routeId. RouteId can be later used for getting directions or/and route shape for the selected route.

AGOL hosted feature service returns more features than maxRecordCount

I'm doing some experiments with ArcGIS Online hosted feature services in R using the sf package.
I cannot figure out why the response of this request contains more than 60k features:
https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Rijksmonumenten/FeatureServer/0/query?where=1%3D1&outFields=%2A&returnCountOnly=false&f=geojson
According to the service parameters maxRecordCount is 10000:
https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Rijksmonumenten/FeatureServer/0?f=json
I thought I had to use pagination, but that does not seem to be the case. Thus I'm supprised. Can somebody please explain.
This is a link to my gist containing the R code:
https://gist.github.com/FrieseWoudloper/47f4dcf68be39bff9dfaf2cd57610db3
Regards,
Willy
Using the wireshark network packet inspector, and changing the protocol scheme to http from https, you can see that st_read is doing the pagination for you, and doing 7 requests to the server to get all the data. Each request has a different request offset and then the resulting sets of 10,000 records plus the last few are concatenated.
The GeoJSON driver of OGR is doing this so sf gets it for free. I suspect its controlled by the FEATURE_SERVER_PAGING option documented here:
https://www.gdal.org/drv_geojson.html#
(Note I switched to http since its clearer to see what's going on with an unencrypted channel, the same thing happens with https)

Passing user name as variable and returning the results of r script using deployR

Consider a r script implementing a simple function which returns histogram plot from dataframe in r consisting of three columns say username, monthname and monthly salary. Now how to integrate to deployR where a simple http call can pass the parameter of username and get histogram related to that user? As I am not a application developer and used to integrate BI Applications using simple http calls with passing username as one of the URL parameters, I want to implement same here. Any possibility? say http://url/username=XYZ which returns me the plot for that user.
Without writing a specific application or a web service acting as a proxy, I don't think it would be possible.
The reason is that in order to run an R script in DeployR, you need more than one call to the API. This is regardless of the client library you want to use.
You will have to :
Setup the DeployR session and context execution
Set the parameters
Launch the R script
Get the results
As far as I know, it can't be done in one HTTP shot.

In Mate, Sending two or more requests to the server simultaneously?

I'm using Mate's RemoteObjectInvoker to call methods in my FluorineFX based API. However, all requests seem to be sent to the server sequentiality. That is, if I dispatch a group of messages at the same time, the 2nd one isn't sent until the first returns. Is there anyway to change this behavior? I don't want my app to be unresponsive while a long request is processing.
This thread will help you to understand what happens (it talks about blazeds/livecylce but I assume that Fluorine is using the same approach). In a few words what happens is:
a)Flash player is grouping all your calls in one HTTP post.
b)The server(BlazeDs,Fluorine etc) receives the request and starts to execute the methods serially, one after another.
Solutions
a)Have one HTTP post per method, instead of one HTTP post containing all the AMF messages. For that you can use HTTPChannel instead of AMFChannels (internally it is using flash.net.URLLoader instead of flash.net.NetConnection). You will be limited to the maximum number of parallel connection defined by your browser.
b)Have only one HTTP post but implement a clever solution on the server (it will cost you a lot of development time). Basically you can write your own parallel processor and use message consumers/publishers in order to send the result of your methods to the client.
c)There is a workaround similar to a) on https://bugs.adobe.com/jira/browse/BLZ-184 - create your remoteobject by hand and append a random id at the end of the endpoint.

Resources