Do you have a code sample that you would care to share? Thanks!
while(feature !=null) { /* * reproject feature to web mercator */ feature.project(webMercator); // webMercator is a SR defined as class property if (getGeometryType()=="esriGeometryPoint") geometryStr=ServerUtilities.getJSONFromPoint((Point)feature.getShape()).toString(); else if (getGeometryType()=="esriGeometryMultipoint") geometryStr=ServerUtilities.getJSONFromMultipoint((Multipoint)feature.getShape()).toString(); else if (getGeometryType()=="esriGeometryPolyline") { polyline=(Polyline)feature.getShape(); polyline.generalize(1); geometryStr=ServerUtilities.getJSONFromPolyline(polyline).toString(); } else if (getGeometryType()=="esriGeometryPolygon") { polygon =(Polygon)feature.getShape(); polygon.generalize(1); geometryStr=ServerUtilities.getJSONFromPolygon(polygon).toString(); } else geometryStr =JSONObject.NULL.toString(); attributesStr ="{"; /* * create a JSON text of feature attributes */ for (int i=0; i<fldCount; i++) { field = fields.getField(i); //SHAPE.LENGTH and SHPAE.AREA if (field.getType()!=esriFieldType.esriFieldTypeGeometry && field.getType()!=esriFieldType.esriFieldTypeRaster && field.getType()!=esriFieldType.esriFieldTypeBlob && field.getName().indexOf("SHAPE.")==-1) { if (feature.getValue(i)==null) attributesStr +="\""+field.getName()+"\":"+ JSONObject.NULL.toString()+","; else if (field.getType()==esriFieldType.esriFieldTypeString ||field.getType()==esriFieldType.esriFieldTypeDate) attributesStr +="\""+field.getName()+"\":\""+ feature.getValue(i).toString()+"\","; else attributesStr +="\""+field.getName()+"\":"+ feature.getValue(i).toString()+","; } } /* * add change type to the attributes */ attributesStr +="\"changeType\":"+ changeType +"}"; /* * put geometry and attribute key/value pair together * and form a JSON representation of feature */ featureJSON =new JSONObject(); featureJSON.put("attributes", new JSONObject(attributesStr)); featureJSON.put("geometry", new JSONObject(geometryStr)); //featuresArray is a JSONArray featuresArray.put(featureJSON); feature =(Feature)pCursor.nextFeature(); }
Just want to share with developers what i have learned on maxAllowableOffset. I recently have a project where I need write an ArcObject routine to retrieve a collection of features from a polyline feature class. And then convert them into a featurecollection JSON text (layerdefinition, featureSet etc) so that I can create a feature layer dynamically using this featurecollection. Initially it took around 315 seconds to converting 8 polylines to JSON text. So I added the method Polyline.generalize(double maxAllowableOffset) before the conversion. Now it only takes 18 seconds to convert (5.7% of the previous time!). I am not 100% sure whether the method is what Javascript API maxAllowableOffset internally implemented. However it is amazing how geometry generalization make a huge difference. The method uses widely accepted Douglas-Poiker algorithm for linear simplification. It basically treat the two points within maxAllowableOffset as the same, thus dramatically reduce the number of points in a polyline�??s pointcollection. In my case it reduced the lenght of featurecollection JSON text from 630,681 to 13, 161 and still well preserve the integrity of geometry shape. So I strongly recommend using maxAllowableOffset whenever you can.
maxAllowableOffset isn't specific to feature layers, query and identify tasks can also use it. It's a best practice to use it and I'm pretty sure it'll stop this error from appearing.
Are you displaying the whole layer as a dynamic map service or a feature layer?Are you sure you need to send a 1.5MB geometry to the client? I would guess that you could generalize the feature and this error would go away. Plus, your app would be faster. Both the queryTask and the identifyTask support maxAllowableOffset. Here's a blog post I did on the details of how to calculate a suitable value for maxAllowableOffset: http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2011/06/13/Feature-layers-can-generalize-geometries-on-the-fly.aspxOnce you have a value for maxOffset, set it on your query object or your identifyParameters object.
Do you have a proxy set up for your app?
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.