0

I have tried

  • I am displaying raster images on map using this sample code is
const url = imagurl;
    const extent = [0, 0, imageData.width, imageData.height];
    const projection = new Projection({
      code: 'xkcd-image',
      units: 'pixels',
      extent,
    });

    const imageLayer = new ImageLayer({
      source: new Static({
        url,
        projection,
        imageExtent: extent,
      }),
    });
  • and i am using affine transformation lib and returns scaling, rotation and transformation..
  • its giving the values
scaling : 327.805670381418,327.805670381418
rotation : -0.1310210334156003
transformation : 7179251.8557908312,6022627.228704552

i need to add this code into ol-6 static image source

source: new ol.source.GeoImage(
                {   image,
                    imageCenter: transformation,
                    imageScale: scaling,
                    imageRotate: rotation,
                    //projection: pixelProjectio
                })
  • suggest or help on this.. thanks in advance.. and save my days..
  • The image size is automatically scaled to fit the specified image extent. You can handle rotation by defining a rotated projection https://codesandbox.io/s/static-image-forked-5q3e9?file=/main.js The alternative is to preload the image, draw it rotated onto an oversized canvas big enough to fit the rotated image then use the oversized canvas as a data url. – Mike Sep 07 '21 at 15:05
  • @Mike thanks mike for replay, if i am adding OSM layer then its not working.. i.e view projection changed to **EPSG:4326**, – developer g Sep 07 '21 at 23:33
  • sample code code : ```const map = new Map({ layers: [ new TileLayer({ source: new OSM(), }), ], target: "map", view: new View({ projection: "EPSG:4326", }) }); map.addLayer(new ImageLayer({ source: new Static({ attributions: '© xkcd', url: "https://imgs.xkcd.com/comics/online_communities.png", projection: imageProjection, imageExtent: extent }) }));``` – developer g Sep 07 '21 at 23:33
  • For support of EPSG:3857, EPSG:4326 and projections defined in proj4 see https://codesandbox.io/s/reprojection-image-z0uit If you have EPSG:4326 coordinates the image may not be intended for that projection - KML ground overlays are rotated at their latitude of true scale in an equidistant cylindrical projection as in https://github.com/openlayers/openlayers/issues/4949#issuecomment-495940972 – Mike Sep 08 '21 at 09:27
  • thanks @Mike, here small question, what is my extent in openlayer 6... here GeoImage have **imageCenter: transformation** but in openlayers 6 i have added as ``extent = transformExtent([translationX, translationY, translationX + (xScale * this.imageData.width), translationY + (yScale * this.imageData.height)], get('EPSG:3857'), get('EPSG:4326'));`` image displays on map taken starting point as a center point (its shuld image selected center point)... – developer g Sep 15 '21 at 16:25
  • If you have center, width and height the extent is `[translationX - (xScale * this.imageData.width / 2), translationY - (yScale * this.imageData.height / 2), translationX + (xScale * this.imageData.width / 2), translationY + (yScale * this.imageData.height / 2)]` – Mike Sep 15 '21 at 17:50
  • @Mike, i am facing one more issue, if the input has some 45/180 degrees rotating image then is issued then calculated extend and resolution image displaying very bad.. I think I need to calculate 4 extends then top-left, top-right, bottom-left & bottom-right of extend.. Version3 image source have centerOfImage and scalling and rotation. but V6 did not have that.. – developer g Nov 03 '21 at 17:55

0 Answers0