Closest Facility Arcgis online javascript not returning data - arcgis

I am trying to use the Closest Facility (CF) function in ArcGIS API for Javascript. I need to be able to pass a shape coming from a feature service as an incident, and use a feature service with multiple points as the facilities.
Currently when I use the Closest Facility task, nothing happens. No calls are made at all if I look at the network activity.
CFTask.solve(CFParams).then(function (solveResult) {
array.forEach(solveResult.routes, function (route, index) {
console.log(route);
});
});
I understand that i may be passing it incorrect data, but would expect an error message, rather than the nothing I get now.
2 questions:
Does the above code snippet actually run the Closest Facility
function?
How do add data from a feature service to a feature set correctly?

First, verify if an error is triggered inside the promise when you run the code snippet by using catch method:
CFTask.solve(CFParams).then(function (solveResult) {
solveResult.routes.forEach(function(route, index) {
console.log(route);
});
}).catch(console.error);
If you see an error message printed in the console, add it to your question.
Also there is a syntax error in your forEach function

Related

Getting RapidAPI to work with GoogleSheets to extract IMDB data

Google Sheets with RapidAPI
First time trying to get APIs to work! I thought a simple project would be to get a Googlesheet to retrieve movie information based on the title.
Googling around I happened upon RapidAPI which has a Googlesheets add-on. Unfortunately I haven't found much useful documentation so have hit a dead end.
What I've learned so far
There only seems to be one example for how to implement it... by using the =GET() command like so (in this case for pulling finance info):
=GET(”https://investors-exchange-iex-trading.p.rapidapi.com/stock/{symbol}/book”,”quote.companyName”,”YOUR_API_KEY_HERE”,”symbol”,”AAPL”)
I couldn't get this example to work, and the IMDB Code Snippet seems a little different, so I'm not sure how that works at all. Not the curly bracers around {symbol}.
var axios = require("axios").default;
var options = {
method: 'GET',
url: 'https://imdb8.p.rapidapi.com/title/find',
params: {q: 'Dredd'},
headers: {
'x-rapidapi-host': 'imdb8.p.rapidapi.com',
'x-rapidapi-key': '5840855726msh193dee7e1600046p145eddjsnc66aff778896'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
When I run a typical search on IMDB, I get a URL that looks like this:
https://www.imdb.com/find?q=dredd&ref_=nv_sr_sm
I notice this q parameter there, which seems important...
I'm not sure how I am meant to format this =GET() command for IMDB data. The example suggests one thing, but Googlesheets suggests another: "GET(url, selectPaths, rapidApiKey)"
I'm not sure what the curly bracers are doing in the example URL.
Whatever I try seems to give the same error message:
Error
Request failed for https://imdb8.p.rapidapi.com returned code 400. Truncated server response: 400 - Bad Request (use muteHttpExceptions option to examine full response) (line 98).
Send Help
Does anyone have a better, working tutorial for using this setup? Or could you direct me to some useful reading material that a layperson could understand?
I found a good resource for you. Check out this well-written article on RapidAPI's official blog.
https://rapidapi.com/blog/api-google-sheets/

How to retrieve omniture using omniture developer api

We have programmed in android to track omniture using page name using the code
Analytics.trackState(pageName, params);
The params contains lot if data like s.channel, s.prop, Prop, s.eVar
Now: We want get all the params which got recorded in omniture by hitting this link
I am trying to use the nomniture module to call Report, but it is very difficult to understand the parameters to choose a particular page
My Node.js Code
var Client = require('omniture').Client, c = new Client(username,
sharedSecret, 'sanJose'), reportData = {
"rsid_list" : [ reportSuiteId ]
}
How to use s.pageName in a request to retrieve the recorded variables for a particular custom page name
I tried to use Report.QueueTrended, Report.QueueOvertime, Report.QueueRanked followed by Report.Get but I am not getting anything
I always ended up getting errorCode 5003, The report may contain imcomplete data. Please try again later

KeystoneJS: where are callHook hooks defined?

I want to add logic to the pre:signin and post:signin hooks, but can't find where they are defined. In admin/server/api/session/signin.js, I find the callHook()s for both, but can't find the actual hooks. Help greatly appreciated!
KeystoneJS is using grappling-hook . and thats why you can use callHook.
in node_modules/keystone/index.js you can see this code
var grappling = require('grappling-hook');
grappling.mixin(this).allowHooks('pre:static', 'pre:bodyparser', 'pre:session', 'pre:routes', 'pre:render', 'updates', 'signout', 'signin', 'pre:logger');
I am not sure but you are not finding the actual hooks because they really don't exist.
The methods are defined in keystone and grapple simply makes them hoockable. e.g signin is the method defined in keystone instance and grapple made it hoockable.
And here is the way you will just tell what to do after signing is completed.
keystone.callHook(user, 'post:signin', function (err) {
if (err) return res.json({ error: 'post:signin error', detail: err });
res.json({ success: true, user: user });
});
So in layman term you r saying.. Hay keystone, call my function after This user is signed in. and for that there is really no code inside keystone.
MY knowledge is limited here how the user is passed and how it happens that only when this user logged in. I think, we still need some experts light here.
I had a use-case that required a function be called every time a specific model was added to the database. I found out that you can use the Mongoose middleware specifically the post middleware to achieve such results. So in my case I had a Product schema in which I wanted a function to run everytime a new product was added or updated. It was as easy as adding the following:
keystone.lists.Product.schema.post('save',function(){
console.log('called after new item saved');});

Why won't the Google Maps Directions API example in the 'Google Maps' book work for me?

I'm using the Petrousos 'Google Maps' book, and trying to run the example in the CHAPTER17/HTML/Directions Service.html downloaded from the book's website at www.mhprofessional.com at item 0071823026.
I had to adjust the table dimensions to get it to display properly, but otherwise made no changes. I'm running it through Firefox.
I set the origin and destination and clicked "Show Directions", at which point nothing happened.
The event called the following function:
function showDirections() {
var start = document.getElementById("origin").value;
var end = document.getElementById("destination").value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
printDirections(result);
}
});
}
I get as far as the directionsService.route call, but it is apparently not being executed, and status and result are not defined.
I have no idea how to debug this further, not having access to the API code..
Could the syntax of the call in the example be outdated?
I don't have an API key, but I understand it is not necessary, and I have run other examples without one.
Do you old examples still work? If not, then it's because you don't have an API key. Google will shut you down after you surpassed the quota. I believe the quota is at 50 requests per hours.
Google has the most recent documentation (and it's impressively well documented)
https://developers.google.com/maps/documentation/directions/intro#Audience
Also, can you look at what the object returns? If so, that will usually indicate the quote being surpassed. You can do this by setting a breakpoint at the link
if (status == google.maps.DirectionsStatus.OK) {
If you're using Chrome, you can get to the debugger by right-clicking on the page adn choosing 'Inspect Element', then go to sources, find your line of code and click the link number to set a breakpoint.

Make multiple attempts to call the ajax web service in case of error

I am calling a web service using jquery $.ajax() function. In case of error in the web service call i need to call the web service 2 more time.
How should be the best way to do it ?
In a past project I just used Settimeout to check for empty returned results fromthe Ajax call.... so for instance
var failcounter = 0;
if (CHECK SOME CONDITION HERE FOR RESULTS && failcounter < 4){
//IF FOUND TO BE EMPTY THEN WE ADD ONE TO THE 'COUNTER' THEN USE SETTIMEOUT TO RE-TRY...
setTimeout(function () {
failcounter++;
yourajaxFunctioncall();
}, 5000);
};
this is really rough and just tossed together - not all all meant to work from cut/paste since I haven't seen your code - but hopefully you get the idea, use a 'counter' to keep track of an limit the number of times its re-tried... if NO RESULTS are found use settimeout to re-try it again. I've also used Ajax 'error:' (similar to 'success:') to hold specific functions to try upon fail - so that may be easier -- just depends on how you want to handle I guess. good luck