mil.nga.geopackage.tiles.TileUtils Java Examples
The following examples show how to use
mil.nga.geopackage.tiles.TileUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeatureTiles.java From geopackage-android with MIT License | 4 votes |
/** * Constructor, auto creates the index manager for indexed tables and feature styles for styled tables * * @param context context * @param geoPackage GeoPackage * @param featureDao feature dao * @param density display density: {@link android.util.DisplayMetrics#density} * @param width drawn tile width * @param height drawn tile height * @since 3.2.0 */ public FeatureTiles(Context context, GeoPackage geoPackage, FeatureDao featureDao, float density, int width, int height) { this.context = context; this.featureDao = featureDao; if (featureDao != null) { this.projection = featureDao.getProjection(); } this.density = TileUtils.tileDensity(density, width, height); tileWidth = width; tileHeight = height; createEmptyImage(); compressFormat = CompressFormat.valueOf(context.getString(R.string.feature_tiles_compress_format)); pointPaint.setAntiAlias(true); pointRadius = Float.valueOf(context.getString(R.string.feature_tiles_point_radius)); linePaint.setAntiAlias(true); lineStrokeWidth = Float.valueOf(context.getString(R.string.feature_tiles_line_stroke_width)); linePaint.setStrokeWidth(this.density * lineStrokeWidth); linePaint.setStyle(Style.STROKE); polygonPaint.setAntiAlias(true); polygonStrokeWidth = Float.valueOf(context.getString(R.string.feature_tiles_polygon_stroke_width)); polygonPaint.setStrokeWidth(this.density * polygonStrokeWidth); polygonPaint.setStyle(Style.STROKE); Resources resources = context.getResources(); fillPolygon = resources.getBoolean(R.bool.feature_tiles_polygon_fill); polygonFillPaint.setAntiAlias(true); polygonFillPaint.setStyle(Style.FILL); polygonFillPaint.setAlpha(resources.getInteger(R.integer.feature_tiles_polygon_fill_alpha)); if (geoPackage != null) { indexManager = new FeatureIndexManager(context, geoPackage, featureDao); if (!indexManager.isIndexed()) { indexManager.close(); indexManager = null; } featureTableStyles = new FeatureTableStyles(geoPackage, featureDao.getTable()); if (!featureTableStyles.has()) { featureTableStyles = null; } } calculateDrawOverlap(); }
Example #2
Source File: FeaturePreviewUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test the GeoPackage draw feature preview * * @param activity activity * @param geoPackage GeoPackage * @throws IOException upon error */ public static void testDraw(Activity activity, GeoPackage geoPackage) throws IOException { for (String featureTable : geoPackage.getFeatureTables()) { FeatureDao featureDao = geoPackage.getFeatureDao(featureTable); int count = featureDao.count( CoreSQLUtils.quoteWrap(featureDao.getGeometryColumnName()) + " IS NOT NULL"); BoundingBox contentsBoundingBox = geoPackage .getContentsBoundingBox(featureTable); BoundingBox indexedBoundingBox = geoPackage .getBoundingBox(featureTable); boolean expectImage = (contentsBoundingBox != null || indexedBoundingBox != null) && count > 0; boolean epsg = featureDao.getProjection().getAuthority() .equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG); FeaturePreview preview = new FeaturePreview(activity, geoPackage, featureDao); Bitmap image = preview.draw(); if (epsg) { assertEquals(expectImage, image != null); } preview.setBufferPercentage(0.4); preview.setLimit((int) Math.ceil(count / 2.0)); Bitmap imageLimit = preview.draw(); if (epsg) { assertEquals(expectImage, imageLimit != null); } preview.setManual(true); preview.setBufferPercentage(0.05); preview.setLimit(null); FeatureTiles featureTiles = preview.getFeatureTiles(); featureTiles.setTileWidth(TileUtils.TILE_PIXELS_DEFAULT); featureTiles.setTileHeight(TileUtils.TILE_PIXELS_DEFAULT); featureTiles.setDensity( TileUtils.density(TileUtils.TILE_PIXELS_DEFAULT)); featureTiles.clearIconCache(); Bitmap imageManual = preview.draw(); if (epsg) { assertNotNull(imageManual); } preview.setBufferPercentage(0.35); preview.setLimit(Math.max(count - 1, 1)); Bitmap imageManualLimit = preview.draw(); if (epsg) { assertNotNull(imageManualLimit); } preview.setBufferPercentage(0.15); preview.setLimit(null); preview.appendWhere( CoreSQLUtils.quoteWrap(featureDao.getIdColumnName()) + " > " + ((int) Math.floor(count / 2.0))); Bitmap imageManualWhere = preview.draw(); if (epsg) { assertNotNull(imageManualWhere); } if(image != null) { image.recycle(); } if(imageLimit != null) { imageLimit.recycle(); } if(imageManual != null) { imageManual.recycle(); } if(imageManualLimit != null) { imageManualLimit.recycle(); } if(imageManualWhere != null) { imageManualWhere.recycle(); } preview.close(); } }
Example #3
Source File: FeaturePreviewUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test the GeoPackage draw feature preview * * @param geoPackage * GeoPackage * @throws IOException * upon error */ public static void testDraw(GeoPackage geoPackage) throws IOException { for (String featureTable : geoPackage.getFeatureTables()) { FeatureDao featureDao = geoPackage.getFeatureDao(featureTable); int count = featureDao.count( CoreSQLUtils.quoteWrap(featureDao.getGeometryColumnName()) + " IS NOT NULL"); BoundingBox contentsBoundingBox = geoPackage .getContentsBoundingBox(featureTable); BoundingBox indexedBoundingBox = geoPackage .getBoundingBox(featureTable); boolean expectImage = (contentsBoundingBox != null || indexedBoundingBox != null) && count > 0; boolean epsg = featureDao.getProjection().getAuthority() .equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG); FeaturePreview preview = new FeaturePreview(geoPackage, featureDao); BufferedImage image = preview.draw(); if (epsg) { assertEquals(expectImage, image != null); } if (writeImages) { ImageIO.write(image, "png", new File("image.png")); } preview.setBufferPercentage(0.4); preview.setLimit((int) Math.ceil(count / 2.0)); BufferedImage imageLimit = preview.draw(); if (epsg) { assertEquals(expectImage, imageLimit != null); } if (writeImages) { ImageIO.write(imageLimit, "png", new File("image_limit.png")); } preview.setManual(true); preview.setBufferPercentage(0.05); preview.setLimit(null); FeatureTiles featureTiles = preview.getFeatureTiles(); featureTiles.setTileWidth(TileUtils.TILE_PIXELS_DEFAULT); featureTiles.setTileHeight(TileUtils.TILE_PIXELS_DEFAULT); featureTiles.setScale( TileUtils.tileScale(TileUtils.TILE_PIXELS_DEFAULT)); featureTiles.clearIconCache(); BufferedImage imageManual = preview.draw(); if (epsg) { assertNotNull(imageManual); } if (writeImages) { ImageIO.write(imageManual, "png", new File("image_manual.png")); } preview.setBufferPercentage(0.35); preview.setLimit(Math.max(count - 1, 1)); BufferedImage imageManualLimit = preview.draw(); if (epsg) { assertNotNull(imageManualLimit); } if (writeImages) { ImageIO.write(imageManualLimit, "png", new File("image_manual_limit.png")); } preview.setBufferPercentage(0.15); preview.setLimit(null); preview.appendWhere( CoreSQLUtils.quoteWrap(featureDao.getIdColumnName()) + " > " + ((int) Math.floor(count / 2.0))); BufferedImage imageManualWhere = preview.draw(); if (epsg) { assertNotNull(imageManualWhere); } if (writeImages) { ImageIO.write(imageManualWhere, "png", new File("image_manual_where.png")); System.out.println("Breakpoint here"); } } }
Example #4
Source File: GeoPackageOverlay.java From geopackage-android-map with MIT License | 2 votes |
/** * Constructor using the density to determine tile size and with tile scaling options * * @param tileDao tile dao * @param density display density: {@link android.util.DisplayMetrics#density} * @param scaling tile scaling options * @since 3.2.0 */ public GeoPackageOverlay(TileDao tileDao, float density, TileScaling scaling) { this(tileDao, TileUtils.tileLength(density), TileUtils.tileLength(density), scaling); }
Example #5
Source File: FeatureTiles.java From geopackage-android with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and feature styles for styled tables * * @param context context * @param geoPackage GeoPackage * @param featureDao feature dao * @since 3.2.0 */ public FeatureTiles(Context context, GeoPackage geoPackage, FeatureDao featureDao) { this(context, geoPackage, featureDao, TileUtils.TILE_PIXELS_HIGH, TileUtils.TILE_PIXELS_HIGH); }
Example #6
Source File: FeatureTiles.java From geopackage-android with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and feature styles for styled tables * * @param context context * @param geoPackage GeoPackage * @param featureDao feature dao * @param density display density: {@link android.util.DisplayMetrics#density} * @since 3.2.0 */ public FeatureTiles(Context context, GeoPackage geoPackage, FeatureDao featureDao, float density) { this(context, geoPackage, featureDao, density, TileUtils.tileLength(density), TileUtils.tileLength(density)); }
Example #7
Source File: FeatureTiles.java From geopackage-android with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and feature styles for styled tables * * @param context context * @param geoPackage GeoPackage * @param featureDao feature dao * @param width drawn tile width * @param height drawn tile height * @since 3.2.0 */ public FeatureTiles(Context context, GeoPackage geoPackage, FeatureDao featureDao, int width, int height) { this(context, geoPackage, featureDao, TileUtils.density(width, height), width, height); }
Example #8
Source File: FeatureTiles.java From geopackage-java with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and * feature styles for styled tables * * @param geoPackage * GeoPackage * @param featureDao * feature dao * @since 3.2.0 */ public FeatureTiles(GeoPackage geoPackage, FeatureDao featureDao) { this(geoPackage, featureDao, TileUtils.TILE_PIXELS_HIGH, TileUtils.TILE_PIXELS_HIGH); }
Example #9
Source File: FeatureTiles.java From geopackage-java with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and * feature styles for styled tables * * @param geoPackage * GeoPackage * @param featureDao * feature dao * @param scale * scale factor * @since 3.2.0 */ public FeatureTiles(GeoPackage geoPackage, FeatureDao featureDao, float scale) { this(geoPackage, featureDao, scale, TileUtils.tileLength(scale), TileUtils.tileLength(scale)); }
Example #10
Source File: FeatureTiles.java From geopackage-java with MIT License | 2 votes |
/** * Constructor, auto creates the index manager for indexed tables and * feature styles for styled tables * * @param geoPackage * GeoPackage * @param featureDao * feature dao * @param width * drawn tile width * @param height * drawn tile height * @since 3.2.0 */ public FeatureTiles(GeoPackage geoPackage, FeatureDao featureDao, int width, int height) { this(geoPackage, featureDao, TileUtils.tileScale(width, height), width, height); }