I have a polygon provided by the user specifying up to six gps coordinates. I'm using relation to verify that the polygon is valid since it will eventually end up is SDE. I have a process that goes through the entire user's input checking values and completeness and calls a function to check the polygon. This process needs to get back a boolean so that it can continue or stop processing. I have not been able to a result back to the calling function. I hope the answer is a "I'm just missing something obvious" moment instead of a "that is not possible" moment. Here is an example of my code:
function processing()
{
if(!checkPolygon())
...stop processing...
else
...continue processing...
}
function checkPolygon(l)
{
...prepare to call relation...
geometryService.relation(relationParams, checkPolygonResults);
...needs to return boolean...
}
function checkPolygonResults(relations)
{
...check polygon...
...send result back somehow...
}
I've tried checkPolygonResults setting a global var and checkPolygon somehow waiting on the answer. However, I have not been able to get checkPolygon to wait without (apparently) preventing checkPolygonResults from running.
I've also tried getting something through the deferred value that relation returns, either getting the result directly or waiting on the result. I have not gotten that to work either, admitting that I'm not an expert with dojo.
Am I just missing something? Is there a better way to validate the polygon? I'm currently checking for a crossing relation for each of the lines in the polygon. I'm using javscript api 2.1.
Thanks