Android Open Source - hellomap3d-android My Merged Raster Tile Data Source






From Project

Back to project page hellomap3d-android.

License

The source code is released under:

MIT License

If you think the Android project hellomap3d-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nutiteq.advancedmap3.datasource;
/*w  w w . j a v a  2 s.  co m*/
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

import com.nutiteq.core.MapTile;
import com.nutiteq.datasources.TileDataSource;
import com.nutiteq.core.TileData;
import com.nutiteq.utils.BitmapUtils;

public class MyMergedRasterTileDataSource extends TileDataSource {
  private TileDataSource dataSource1;
    private TileDataSource dataSource2;
    private Paint paint;

  public MyMergedRasterTileDataSource(TileDataSource dataSource1, TileDataSource dataSource2) {
    super(dataSource1.getMinZoom(), dataSource1.getMaxZoom());
      this.dataSource1 = dataSource1;
      this.dataSource2 = dataSource2;
  }

  public TileData loadTile(MapTile tile) {
    TileData tileData1 = dataSource1.loadTile(tile);
      TileData tileData2 = dataSource2.loadTile(tile);
      
      if (tileData1 == null) {
          return tileData2;
      }
      
      if (tileData2 == null) {
          return tileData1;
      }
      
      // Combine the bitmaps
      com.nutiteq.graphics.Bitmap tileBitmap1 = new com.nutiteq.graphics.Bitmap(tileData1.getData(), false);
      com.nutiteq.graphics.Bitmap tileBitmap2 = new com.nutiteq.graphics.Bitmap(tileData2.getData(), false);
      Bitmap bitmap1 = BitmapUtils.CreateAndroidBitmapFromBitmap(tileBitmap1);
      Bitmap bitmap2 = BitmapUtils.CreateAndroidBitmapFromBitmap(tileBitmap2);
      
      if (paint == null) {
        paint = new Paint(Paint.FILTER_BITMAP_FLAG);
      }
      
      Canvas canvas = new Canvas(bitmap1);
      canvas.drawBitmap(bitmap2, null, new Rect(0, 0, bitmap1.getWidth(), bitmap1.getHeight()), paint);
      
      return new TileData(BitmapUtils.CreateBitmapFromAndroidBitmap(bitmap1).compressToInternal());
  }
  
}




Java Source Code List

com.nutiteq.advancedmap3.AerialMapActivity.java
com.nutiteq.advancedmap3.AnimatedRasterMapActivity.java
com.nutiteq.advancedmap3.Const.java
com.nutiteq.advancedmap3.CustomRasterDataSourceActivity.java
com.nutiteq.advancedmap3.GraphhopperRouteActivity.java
com.nutiteq.advancedmap3.LauncherList.java
com.nutiteq.advancedmap3.MapListenerActivity.java
com.nutiteq.advancedmap3.MapSampleBaseActivity.java
com.nutiteq.advancedmap3.MbtilesActivity.java
com.nutiteq.advancedmap3.OfflineVectorMapActivity.java
com.nutiteq.advancedmap3.Overlays2DActivity.java
com.nutiteq.advancedmap3.Overlays3DActivity.java
com.nutiteq.advancedmap3.PinMapActivity.java
com.nutiteq.advancedmap3.RasterOverlayActivity.java
com.nutiteq.advancedmap3.VectorMapSampleBaseActivity.java
com.nutiteq.advancedmap3.datasource.MyAnimatedTileDataSource.java
com.nutiteq.advancedmap3.datasource.MyMergedRasterTileDataSource.java
com.nutiteq.advancedmap3.listener.MyMapEventListener.java
com.nutiteq.advancedmap3.listener.RouteMapEventListener.java
com.nutiteq.filepicker.FilePickerActivity.java
com.nutiteq.filepicker.FilePickerIconAdapter.java
com.nutiteq.filepicker.FilePicker.java
com.nutiteq.hellomap3.MainActivity.java
com.nutiteq.hellomap3.util.AssetCopy.java