Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am facing a strange issue when trying to execute GP service when my map's spatial-reference is Web Mercator. I appreciate all help.

I have a JavaScript API application. Initially I only had my map service used in this application. The Map Service I am using is in NAD27. I execute a GP service from JavaScript API and it works fine. In fiddler I can see the request being send to the server. Now I need to add ESRI image layer to map. So I now have my map's spatial reference as web mercarter. Now if I execute the GP Service nothing happens. No request being send to server, because nothing gets recorded in fiddler.

If I test the same request from ArcGIS Server rest end point it works fine.

Here is the request string in NAD27 and web mercarter. Only difference is wikid.

{"features":[{"geometry":{"type":"polygon","rings":[],"_ring":0,"spatialReference":{"wkid":4267,"latestWkid":4267}},"symbol":null,"attributes":{"id":1,"legalParams":"MT:TR|CNTY:051|STC:OH|PAR:|QQ:NW|LN:|PGUID:{3A15DFEB-9868-4588-9A08-737C033EDF2D}|MSC:1|STN:34|MER:01|TWSP:6|TDIR:N|RNG:5|RDIR:E|SEC:13|RW:|RUOM:AC"},"infoTemplate":null}],"spatialReference":{"wkid":4267,"latestWkid":4267},"geometryType":"esriGeometryPolygon","fields":[{"name":"Id","type":"esriFieldTypeOID"},{"name":"legalParams","type":"esriFieldTypeString"}]}

Web Mercator request

{"features":[{"geometry":{"type":"polygon","rings":[],"_ring":0,"spatialReference":{"wkid":102100,"latestWkid":3857}},"symbol":null,"attributes":{"id":1,"legalParams":"MT:TR|CNTY:051|STC:OH|PAR:|QQ:NW|LN:|PGUID:{3A15DFEB-9868-4588-9A08-737C033EDF2D}|MSC:1|STN:34|MER:01|TWSP:6|TDIR:N|RNG:5|RDIR:E|SEC:13|RW:|RUOM:AC"},"infoTemplate":null}],"spatialReference":{"wkid":102100,"latestWkid":3857},"geometryType":"esriGeometryPolygon","fields":[{"name":"Id","type":"esriFieldTypeOID"},{"name":"legalParams","type":"esriFieldTypeString"}]}
share|improve this question
    
What does your Geo-processing Service do? have you tested on different browsers, including Google Chrome & Firefox? –  Devdatta Tengshe May 17 '13 at 17:42
    
Hi Devadatta, Thanks for the fast response. MY GP Service returns one polygon. As I said, if I use this same request from REST end point, it works. If REST end point request is web mercarter, I can see the coordinates of the polygon in meters. If the REST endpoint request is NAD27, the result polygon's coordinates are in degrees. So there is no issue with the GP service itslef. I tested on IE and chrome. I doubt this is a browser issue. –  Cyril May 17 '13 at 19:19
    
I noticed that gp.execute() method is throwing the following error when I execute the GP tool in web Mercarter. TypeError: Cannot read property 'xmin' of undefined –  Cyril May 20 '13 at 15:23
add comment

1 Answer

I am able to find the reason for the above error. It looks like an ESRI bug to me.

One of the parameter that I pass to gp.Execute() method is a FeatureSet. This FeatureSet contain a polygon with empty geometry and few attributes. My output will add geometry to this FeatureSet. When map's spatial reference is GCS, the GP tool works fine. But when the spatial reference is PCS, the FeatureSet requires some geometry for the polygon. I am not sure why it is so. So I am adding few dummy rings to the polygon to get it working.

The line polygon.addRing ... below was added to fix the issue discussed above. I guess we can add any dummy ring values there.

If anybody can give a better reason why this is only required when the spatial reference is PCS, I appreciate it.

    .....
    ......
    var attr = {"id":1, "legalParams":legalParams };      
    var polygon = new esri.geometry.Polygon(map.spatialReference);
    polygon.addRing([[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]);//This line is added to fix the issue discussed above. This is not required for GCS
    var graphic = new esri.Graphic(polygon, null, attr, null);
    legalFeatureset = new esri.tasks.FeatureSet();
    legalFeatureset.spatialReference = map.spatialReference;
     .......
     ''''''
    var features = [];
    features.push(graphic);
    legalFeatureset.features = features;
    legalFeatureset.geometryType = "esriGeometryPolygon";

    .......
    ''''''' 
   gp.execute(params, drawGeoprocessingResult, getError);

Cyril

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.