Select to view content in your preferred language

Get Pixel index of a clicked point from a tile in WMTS layer

523
0
07-11-2013 05:47 AM
ShirlyStephen
Deactivated User
How do I get the index of a clicked point from a tile in WMTS layer? I also want the tile row and column number corresponding to the clicked location. So I tried to set the extent of my WMTS layer to the clicked point. So my code was something like this

        dojo.declare("ogc.WMTSLayer", esri.layers.TiledMapServiceLayer, {
        constructor: function() {
          this.spatialReference = new esri.SpatialReference({
           wkid: 3857
       });
        
          this.initialExtent = new esri.geometry.Extent(point.x, point.y,- point.x,- point.y, this.spatialReference);
          this.fullExtent = new esri.geometry.Extent(point.x, point.y, - point.x, -point.y, this.spatialReference);
        
          this.tileInfo = new esri.layers.TileInfo({
               "dpi": "90.71428571427429",
               "format": "image/png",
               "compressionQuality": 0,
               "spatialReference": {
                 "wkid": "3857"
               },
               "rows": 256,
               "cols": 256,
               "origin": {
                 "x": -20037508.342789,
                 "y": 20037508.342789
               },
               "lods": [{
                 .............
                 .............
 
               }
               ]
               });
             this.loaded = true;
             this.onLoad(this);
           },
 
           getTileUrl: function(level, row, col) {

            return "http://wmts.scalgo.com/public/wmts" + "?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile" + "&LAYER=denmark%3Adhm%3Apublic%3Asealevels" + "&STYLE=_null" + "&FORMAT=image/png" + "&TILEMATRIXSET=3857" + "&TILEMATRIX=" + level + "&TILEROW=" + row + "&TILECOL=" + col + "&Threshold = 200";
           }
         });


In this case I am able to get the row and column of the tile corresponding to my clicked point. But the extent of my rendered tile has my clicked point coordinates as I had used them to create my WMTS layer. So I am unable to use the WMTS tile extent co-ordinates to find my pixel coordinates mathematically. I would appreciate any suggestions as to how to work on this. Should I use the scale and resolution of the loaded tile in any way?
0 Kudos
0 Replies