Where did the .uncompressed files go in 3.2?

838
2
Jump to solution
09-28-2012 08:15 AM
CoreyAlix
Occasional Contributor
I was very excited to discover I have the .uncompressed js/esri files for 3.0 only to discover they are no longer available in 3.2?  Do I have to wait a little longer or is this no longer happening?  It makes sense to exclude the uncompressed dojo files since we can pick those up elsewhere...but why the short life of esri uncompressed?
0 Kudos
1 Solution
2 Replies
CoreyAlix
Occasional Contributor
Thank you for that.   For ESRI -- About once a week I wish ESRI would release the source code.  Here my latest  issue where having the source helped me:

Suppose I want to use a WMS service that does not support the 102100 projection but does support 3857.  How do I override the SRS value in the getImageUrl request?  We'll, let's take a look at the source code for the WMS layer:

   // spatial reference
    var extentWKID = wkid ? wkid : NaN;
    if (!isNaN(extentWKID)) {
      if (this.version == "1.3.0") {
        urlVariables.CRS = "EPSG:" + extentWKID;
      } else {
        urlVariables.SRS = "EPSG:" + extentWKID;
      }
    }


Okay...where does wkid come from?

var wkid = extent.spatialReference.wkid;

Okay, where does the extent (a parameter) come from?  Let's grep the esri folder...it comes from the _onExtentChangeHandler of the dynamic layer.

Okay, another grep later and I can see that it connects to the map onExtentChange...so I need to set the map extent to use 3857.  But I already did that so why is it back to 102100? 

Let's jump into the API (http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#spatialReference) and have a look.  Okay, am I setting the 'spatialReference' in the constructor?  No, I'm setting it after the constructor:

{
 "wkid": 3857
}


so...let's watch the onExtentChange (initial extent also uses this same spatial ref):

Everything is still good...spatialReference on the first parameter is 3857:

{
 "0": {
  "type": "extent",
  "xmin": 16891811.836705152,
  "ymin": -3887243.796387848,
  "xmax": 16902188.163294848,
  "ymax": -3880756.203612152,
  "spatialReference": {
   "wkid": 3857
  }
 },
 "1": null,
 "2": false,
 "3": {
  "level": 2,
  "resolution": 9.55462853563415,
  "scale": 36111.909643
 }
}


Lets take another look at that source by stepping through the code...ah man..I'm in wms.js which is not compressed!  No problem...just rename my js files.  But wait..before I even do that what is this thing with _2.some(this._WEB_MERCATOR?  Better look closer at that next time.

Okay, step through the WMS layer constructor...options looks good:

{
 "id": "Parcels",
 "resourceInfo": {
  "extent": {
   "type": "extent",
   "xmin": 16894000,
   "ymin": -3886000,
   "xmax": 16900000,
   "ymax": -3882000,
   "spatialReference": {
    "wkid": 3857
   }
  },
  "layerInfos": [
   {
    "name": "PARCELS",
    "title": "Parcels",
    "subLayers": [],
    "allExtents": [],
    "spatialReferences": []
   }
  ],
  "version": "1.1.1"
 },
 "visibleLayers": [
  "PARCELS"
 ]
}


Stepping through I see I missed an opportunity to specify "spatialReferences" in the resourceInfo but no matter...3857 is making it's way to getImageUrl so what is going on?

Back at getImageUrl for the first time with uncompressed source I find that since _WEB_MERCATOR contains 3857 I end up here:

      // extent is in Web Mercator
      var common = dojo.filter(this.spatialReferences, function(el){
        return (dojo.some(this._WEB_MERCATOR, function(el2){
          return el2 == el;
        }));
      }, this);


But this.spatialReferences is []!  That's my problem.  Let's go back to the WMS docs to see where I went wrong.

No mention of spatialReferences...that's okay, let's go through the code one more time after putting a break-point here:

    this.spatialReferences = resourceInfo.spatialReferences ? resourceInfo.spatialReferences : [];

And let's manually set resourceInfo.spatialReferences = [3857]

Yes!  I have imagery!  I have the great job in my office!  Make this little change and my problem is resolved:

 resourceInfo: {
  extent: pseudoConfig.fullExtent,
  layerInfos: layerInfos,
  version: params.VERSION,
  spatialReferences: [pseudoConfig.wkid]
 }


Could I have figured this out without the source code?  Not sure, but http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/wmslayer.htm#WMSLayerC... would not have helped me.

UPDATE: In my particular test case I found that if I remove the resourceInfo altogether to force a GetCapabilities request things work fine after adding this "xml" test to my proxy.ah.cs file:

 if (serverResponse.ContentType.Contains("text") ||
     serverResponse.ContentType.Contains("json") ||
            serverResponse.ContentType.Contains("xml"))
0 Kudos