Class BaseTileExtractor

java.lang.Object
cn.mapway.common.geo.tools.BaseTileExtractor
Direct Known Subclasses:
NoCrsTileExtractor, NoGCSTileExtractor, WebMercatorTileExtractor, WGS84TileExtractor

public class BaseTileExtractor extends Object
BaseTileExtractor
Author:
zhangjianshe <zhangjianshe@gmail.com>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    getBand(boolean singleBand, cn.mapway.ui.client.mvc.Size canvasSize, cn.mapway.geo.shared.vector.Rect targetRect, cn.mapway.geo.shared.vector.Rect sourceRect, List<BandData> sourceBandList, List<org.gdal.gdal.Band> targetBandList)
    读取 三波段影像数据 并返回 Alpha波段数据
    byte[]
    getBlackBuffer(int size)
    每张图片只能调用一次
    getSourceBuffer(int w, int h)
     
    getTargetBuffer(int w, int h)
     
    static cn.mapway.geo.shared.vector.Point
    imageSpaceToSourceSpace(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Point pt)
    根据仿射变换 将经纬度坐标转换到 影像的像素坐标空间 利用下面的公式进行逆变换求解 已知(XP YP ) 求解 (P L) * Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; * Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];
    protected cn.mapway.geo.shared.vector.Box
    locationBoxPixelExtent(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Box tileLngLatExtent)
    根据仿射变换 将经纬度坐标转换到 影像的像素坐标空间 利用下面的公式进行逆变换求解 已知(XP YP ) 求解 (P L) * Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; * Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];
    cn.mapway.geo.shared.vector.Box
    locationBoxPixelExtentFromWgs84(org.gdal.gdal.Dataset sourceDataset, cn.mapway.geo.shared.vector.Box tileLngLatExtent)
    根据 wgs84坐标范围 转化为 影像 像素空间坐标
    static void
    main(String[] args)
     
    boolean
    preview(cn.mapway.geo.client.raster.ImageInfo imageInfo, org.gdal.gdal.Dataset sourceDataset, org.gdal.gdal.Dataset targetDataset, int targetWidth, int targetHeight)
     
    boolean
    processBands(cn.mapway.geo.client.raster.ImageInfo imageInfo, org.gdal.gdal.Dataset sourceDataset, org.gdal.gdal.Dataset targetDataset, List<BandData> sourceBandList, List<org.gdal.gdal.Band> targetBandList)
    处理波段数据
    static cn.mapway.geo.shared.vector.Point
    rasterSpaceToImageSpace(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Point pt)
    根据仿射变换 将像素空间 转化为影像所在参考系下的坐标 利用 放射变化6参数进行变换 Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2) Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5)
    readAndTranslateToBytes256(byte[] transparentBand, BandData sourceBandData, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY, int targetWidth, int targetHeight, int canvasWidth, int canvasHeight)
    读取元数据 转换为 RGB byte 格式
    readImageBandSourceData(String location, int left, int top, int width, int height, int[] bands, int[] outBandsType)
    直接读取目标影像中的数据 不进行采样
    readSourceDataNoTranslate(byte[] transparentBand, BandData sourceBandData, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY, int targetWidth, int targetHeight, int tileWidth)
    读取元数据 不进行格式转换 原始影像的一个举行区域 读取数据到 目标区域
    void
    setColorTable(cn.mapway.geo.shared.color.ColorTable table)
    设置颜色表
    int
    translateColor(double value)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseTileExtractor

      public BaseTileExtractor()
  • Method Details

    • imageSpaceToSourceSpace

      public static cn.mapway.geo.shared.vector.Point imageSpaceToSourceSpace(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Point pt)
      根据仿射变换 将经纬度坐标转换到 影像的像素坐标空间 利用下面的公式进行逆变换求解 已知(XP YP ) 求解 (P L) * Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; * Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

      L=(a1*a3-a4*a0+a4*Xp-a1*Yp)/(a2*a4-a1*a5) P=-(a2*a3-a5*a0+a5*Xp-a2*Yp)/(a2*a4-a1*a5)

      Parameters:
      adfGeoTransform -
      pt -
      Returns:
    • rasterSpaceToImageSpace

      public static cn.mapway.geo.shared.vector.Point rasterSpaceToImageSpace(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Point pt)
      根据仿射变换 将像素空间 转化为影像所在参考系下的坐标 利用 放射变化6参数进行变换 Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2) Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5)
      Parameters:
      adfGeoTransform -
      pt -
      Returns:
    • main

      public static void main(String[] args)
    • locationBoxPixelExtentFromWgs84

      public cn.mapway.geo.shared.vector.Box locationBoxPixelExtentFromWgs84(org.gdal.gdal.Dataset sourceDataset, cn.mapway.geo.shared.vector.Box tileLngLatExtent)
      根据 wgs84坐标范围 转化为 影像 像素空间坐标
      Parameters:
      sourceDataset - 影像
      tileLngLatExtent - 经纬度范围 wgs84
      Returns:
    • setColorTable

      public void setColorTable(cn.mapway.geo.shared.color.ColorTable table)
      设置颜色表
      Parameters:
      table -
    • getBlackBuffer

      public byte[] getBlackBuffer(int size)
      每张图片只能调用一次
      Returns:
    • getTargetBuffer

      public ByteBuffer getTargetBuffer(int w, int h)
    • getSourceBuffer

      public ByteBuffer getSourceBuffer(int w, int h)
    • processBands

      public boolean processBands(cn.mapway.geo.client.raster.ImageInfo imageInfo, org.gdal.gdal.Dataset sourceDataset, org.gdal.gdal.Dataset targetDataset, List<BandData> sourceBandList, List<org.gdal.gdal.Band> targetBandList)
      处理波段数据
      Parameters:
      imageInfo -
      sourceDataset -
      targetDataset -
      sourceBandList -
      targetBandList -
      Returns:
       如果用户要求的是单波段 就返回 true
    • readSourceDataNoTranslate

      public ByteBuffer readSourceDataNoTranslate(byte[] transparentBand, BandData sourceBandData, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY, int targetWidth, int targetHeight, int tileWidth)
      读取元数据 不进行格式转换 原始影像的一个举行区域 读取数据到 目标区域
      Parameters:
      transparentBand -
      sourceX -
      sourceY -
      sourceWidth -
      sourceHeight -
      targetX -
      targetY -
      targetWidth -
      targetHeight -
      tileWidth -
      Returns:
    • readAndTranslateToBytes256

      public ByteBuffer readAndTranslateToBytes256(byte[] transparentBand, BandData sourceBandData, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int targetX, int targetY, int targetWidth, int targetHeight, int canvasWidth, int canvasHeight)
      读取元数据 转换为 RGB byte 格式
      Parameters:
      transparentBand -
      sourceX -
      sourceY -
      sourceWidth -
      sourceHeight -
      targetX -
      targetY -
      targetWidth -
      targetHeight -
      canvasWidth -
      canvasHeight -
      Returns:
    • locationBoxPixelExtent

      protected cn.mapway.geo.shared.vector.Box locationBoxPixelExtent(double[] adfGeoTransform, cn.mapway.geo.shared.vector.Box tileLngLatExtent)
      根据仿射变换 将经纬度坐标转换到 影像的像素坐标空间 利用下面的公式进行逆变换求解 已知(XP YP ) 求解 (P L) * Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2]; * Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

      L=(a1*a3-a4*a0+a4*Xp-a1*Yp)/(a2*a4-a1*a5) P=-(a2*a3-a5*a0+a5*Xp-a2*Yp)/(a2*a4-a1*a5)

      Parameters:
      adfGeoTransform -
      tileLngLatExtent -
      Returns:
    • preview

      public boolean preview(cn.mapway.geo.client.raster.ImageInfo imageInfo, org.gdal.gdal.Dataset sourceDataset, org.gdal.gdal.Dataset targetDataset, int targetWidth, int targetHeight)
    • translateColor

      public int translateColor(double value)
      Parameters:
      value - 0xRRGGBBAA
      Returns:
    • getBand

      public byte[] getBand(boolean singleBand, cn.mapway.ui.client.mvc.Size canvasSize, cn.mapway.geo.shared.vector.Rect targetRect, cn.mapway.geo.shared.vector.Rect sourceRect, List<BandData> sourceBandList, List<org.gdal.gdal.Band> targetBandList)
      读取 三波段影像数据 并返回 Alpha波段数据
      Parameters:
      canvasSize -
      targetRect -
      sourceRect -
      sourceBandList -
      targetBandList -
      Returns:
    • readImageBandSourceData

      public ByteBuffer[] readImageBandSourceData(String location, int left, int top, int width, int height, int[] bands, int[] outBandsType)
      直接读取目标影像中的数据 不进行采样
      Parameters:
      left -
      top -
      width -
      height -
      bands - [1,2,3] start with 1
      Returns:
      byteBuffer save the float value