GeometryService Generalize tool

883
8
02-14-2014 06:31 AM
JatinPatel
Occasional Contributor
I am running a query that results into a set of very complex geometries. I am trying to use the generalize tool from geometryservice
https://developers.arcgis.com/javascript/jsapi/geometryservice-amd.html#generalize to generalize each of the geometries.

Here is my partial code:
$.each(results.features, function (_key, _val) {{
     var generalizeParams = esri.tasks.GeneralizeParameters();
     generalizeParams.geometries = [_val.geometry];
     generalizeParams.maxDeviation = 0.05;
     getGeomService().generalize(generalizeParams, function (geometries) {
          _val.geometry = geometries;
     }, function (err) {
                        
     });
}

getGeomService() basically goes and gets the geometry service: return esri.config.defaults.geometryService;

When I run this, my FireBug goes to the error function and says:
SyntaxError: syntax error
The resource from this URL is not text: https://js.arcgis.com/3.8/

Any idea what I am doing wrong?
0 Kudos
8 Replies
RobertoPepato
Occasional Contributor II
I am running a query that results into a set of very complex geometries. I am trying to use the generalize tool from geometryservice 
https://developers.arcgis.com/javascript/jsapi/geometryservice-amd.html#generalize to generalize each of the geometries. 

Here is my partial code: 
$.each(results.features, function (_key, _val) {{
     var generalizeParams = esri.tasks.GeneralizeParameters();
     generalizeParams.geometries = [_val.geometry];
     generalizeParams.maxDeviation = 0.05;
     getGeomService().generalize(generalizeParams, function (geometries) {
          _val.geometry = geometries;
     }, function (err) {
                        
     });
}

getGeomService() basically goes and gets the geometry service: return esri.config.defaults.geometryService; 

When I run this, my FireBug goes to the error function and says:  
SyntaxError: syntax error
The resource from this URL is not text: https://js.arcgis.com/3.8/

Any idea what I am doing wrong?


Could you paste your full code or provide a JSFiddle so we can better understand what's happenin
0 Kudos
JatinPatel
Occasional Contributor
Could you paste your full code or provide a JSFiddle so we can better understand what's happenin


Sorry, but it is huge app with more than 6000 lines of code. No way I can paste the full code. But the one I provided is the only "new code" I added. Rest has been tested and has been working fine.
Do you think I have a syntax error causing it?
0 Kudos
RobertoPepato
Occasional Contributor II
Sorry, but it is huge app with more than 6000 lines of code. No way I can paste the full code. But the one I provided is the only "new code" I added. Rest has been tested and has been working fine.
Do you think I have a syntax error causing it?


I don't think so. I think that this is a issue with a resource content type. Which browser and version are you using?
0 Kudos
JatinPatel
Occasional Contributor
I don't think so. I think that this is a issue with a resource content type. Which browser and version are you using?


IE10, FF & Chrome latest.
0 Kudos
RobertoPepato
Occasional Contributor II
IE10, FF & Chrome latest.


Could you double check if your web server is returning the correct mime types for the resources (.js and .css) requested by your app?

This thread explains what I suspect.
0 Kudos
JatinPatel
Occasional Contributor
Could you double check if your web server is returning the correct mime types for the resources (.js and .css) requested by your app?

This thread explains what I suspect.


all my css tags are like this:
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.8/js/dojo/dijit/themes/claro/claro.css">

All js are:
<script type="text/javascript" src="https://js.arcgis.com/3.8/"></script>


Only other thing I have in my header is:
<meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.02, maximum-scale=1.0, user-scalable = no">
0 Kudos
JatinPatel
Occasional Contributor
Could you double check if your web server is returning the correct mime types for the resources (.js and .css) requested by your app?

This thread explains what I suspect.


LiveHeader--- Contect-type info seems correct too.
JS are: application/x-javascript
CSS are: text/css
0 Kudos
JatinPatel
Occasional Contributor
Apparently, it seems that it errors out on super-complex boundaries like Canada and Russia. I tired running it on simpler boundaries like some european and african countries and it seems to work fine!
So basically it can generalize simple geometries but fails to do so on complex. Does that not defeats the purpose of the tool? lol 😛
0 Kudos