mil.nga.geopackage.extension.style.IconRow Java Examples
The following examples show how to use
mil.nga.geopackage.extension.style.IconRow.
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: StyleUtils.java From geopackage-android-map with MIT License | 6 votes |
/** * Set the icon into the marker options * * @param markerOptions marker options * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @param iconCache icon cache * @return true if icon was set into the marker options */ public static boolean setIcon(MarkerOptions markerOptions, IconRow icon, float density, IconCache iconCache) { boolean iconSet = false; if (icon != null) { Bitmap iconImage = createIcon(icon, density, iconCache); markerOptions.icon(BitmapDescriptorFactory .fromBitmap(iconImage)); iconSet = true; double anchorU = icon.getAnchorUOrDefault(); double anchorV = icon.getAnchorVOrDefault(); markerOptions.anchor((float) anchorU, (float) anchorV); } return iconSet; }
Example #2
Source File: FeatureStylesUtils.java From geopackage-android with MIT License | 5 votes |
private static IconRow randomIcon(GeoPackage geoPackage) throws IOException, NameNotFoundException { IconRow iconRow = new IconRow(); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), TestConstants.ICON_POINT_IMAGE); String iconImage = TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), TestConstants.ICON_POINT_IMAGE); Bitmap iconBitmap = BitmapFactory.decodeFile(iconImage); iconRow.setData(iconBitmap, Bitmap.CompressFormat.PNG); iconRow.setContentType("image/" + TestConstants.ICON_POINT_IMAGE_EXTENSION); if (Math.random() < .5) { iconRow.setName("Icon Name"); } if (Math.random() < .5) { iconRow.setDescription("Icon Description"); } if (Math.random() < .5) { iconRow.setWidth(Math.random() * iconBitmap.getWidth()); } if (Math.random() < .5) { iconRow.setHeight(Math.random() * iconBitmap.getHeight()); } if (Math.random() < .5) { iconRow.setAnchorU(Math.random()); } if (Math.random() < .5) { iconRow.setAnchorV(Math.random()); } return iconRow; }
Example #3
Source File: GeoPackageExample.java From geopackage-java with MIT License | 5 votes |
private static void createFeatureStylesGeometry2(GeoPackage geoPackage, List<StyleRow> styles, List<IconRow> icons) throws IOException { FeatureDao featureDao = geoPackage.getFeatureDao("geometry2"); FeatureTableStyles geometry2Styles = new FeatureTableStyles(geoPackage, featureDao.getTable()); geometry2Styles.setTableStyle(GeometryType.POINT, styles.get(0)); geometry2Styles.setTableStyle(GeometryType.LINESTRING, styles.get(1)); geometry2Styles.setTableStyle(GeometryType.POLYGON, styles.get(0)); geometry2Styles.setTableStyle(GeometryType.GEOMETRY, styles.get(2)); geometry2Styles.createStyleRelationship(); geometry2Styles.createIconRelationship(); FeatureResultSet features = featureDao.queryForAll(); while (features.moveToNext()) { FeatureRow featureRow = features.getRow(); switch (featureRow.getGeometryType()) { case POINT: geometry2Styles.setIcon(featureRow, icons.get(0)); break; case LINESTRING: geometry2Styles.setStyle(featureRow, styles.get(0)); break; case POLYGON: geometry2Styles.setStyle(featureRow, styles.get(1)); break; default: } } features.close(); }
Example #4
Source File: FeatureStylesUtils.java From geopackage-java with MIT License | 5 votes |
private static IconRow randomIcon() throws IOException { IconRow iconRow = new IconRow(); File iconImageFile = TestUtils .getTestFile(TestConstants.ICON_POINT_IMAGE); byte[] iconBytes = GeoPackageIOUtils.fileBytes(iconImageFile); BufferedImage iconImage = ImageUtils.getImage(iconBytes); iconRow.setData(iconBytes); iconRow.setContentType( "image/" + TestConstants.ICON_POINT_IMAGE_EXTENSION); if (Math.random() < .5) { iconRow.setName("Icon Name"); } if (Math.random() < .5) { iconRow.setDescription("Icon Description"); } if (Math.random() < .5) { iconRow.setWidth(Math.random() * iconImage.getWidth()); } if (Math.random() < .5) { iconRow.setHeight(Math.random() * iconImage.getHeight()); } if (Math.random() < .5) { iconRow.setAnchorU(Math.random()); } if (Math.random() < .5) { iconRow.setAnchorV(Math.random()); } return iconRow; }
Example #5
Source File: FeatureStylesUtils.java From geopackage-java with MIT License | 5 votes |
private static void validateRowIcons(FeatureTableStyles featureTableStyles, FeatureRow featureRow, GeometryType geometryType, IconRow tableIconDefault, Map<GeometryType, IconRow> geometryTypeTableIcons, Map<Long, Map<GeometryType, IconRow>> featureResultsIcons) { IconRow iconRow = null; if (geometryType == null) { iconRow = featureTableStyles.getIcon(featureRow); geometryType = featureRow.getGeometryType(); } else { iconRow = featureTableStyles.getIcon(featureRow, geometryType); } IconRow expectedIconRow = getExpectedRowIcon(featureRow, geometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); if (expectedIconRow != null) { TestCase.assertEquals(expectedIconRow.getId(), iconRow.getId()); TestCase.assertNotNull(iconRow.getTable()); TestCase.assertTrue(iconRow.getId() >= 0); iconRow.getName(); iconRow.getDescription(); iconRow.getWidth(); iconRow.getHeight(); iconRow.getAnchorU(); iconRow.getAnchorV(); } else { TestCase.assertNull(iconRow); } }
Example #6
Source File: FeatureStylesUtils.java From geopackage-java with MIT License | 5 votes |
private static void validateRowIcons(FeatureTableStyles featureTableStyles, FeatureRow featureRow, IconRow tableIconDefault, Map<GeometryType, IconRow> geometryTypeTableIcons, Map<Long, Map<GeometryType, IconRow>> featureResultsIcons) { GeometryType geometryType = featureRow.getGeometryType(); validateRowIcons(featureTableStyles, featureRow, null, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); if (geometryType != null) { List<GeometryType> geometryTypes = GeometryUtils .parentHierarchy(geometryType); for (GeometryType parentGeometryType : geometryTypes) { validateRowIcons(featureTableStyles, featureRow, parentGeometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); } List<GeometryType> childTypes = getAllChildTypes(geometryType); for (GeometryType childGeometryType : childTypes) { validateRowIcons(featureTableStyles, featureRow, childGeometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); } } }
Example #7
Source File: FeatureStylesUtils.java From geopackage-java with MIT License | 5 votes |
private static void validateTableIcons( FeatureTableStyles featureTableStyles, IconRow iconRow, Map<GeometryType, IconRow> geometryTypeIcons, Map<GeometryType, Map<GeometryType, ?>> geometryTypes) throws IOException { if (geometryTypes != null) { for (Entry<GeometryType, Map<GeometryType, ?>> type : geometryTypes .entrySet()) { IconRow typeIconRow = iconRow; if (geometryTypeIcons.containsKey(type.getKey())) { typeIconRow = geometryTypeIcons.get(type.getKey()); TestCase.assertTrue(typeIconRow.getId() >= 0); TestCase.assertNotNull(typeIconRow.getData()); TestCase.assertEquals( "image/" + TestConstants.ICON_POINT_IMAGE_EXTENSION, typeIconRow.getContentType()); BufferedImage iconImage = typeIconRow.getDataImage(); TestCase.assertNotNull(iconImage); TestCase.assertTrue(iconImage.getWidth() > 0); TestCase.assertTrue(iconImage.getHeight() > 0); } TestCase.assertEquals(typeIconRow.getId(), featureTableStyles.getTableIcon(type.getKey()).getId()); @SuppressWarnings("unchecked") Map<GeometryType, Map<GeometryType, ?>> childGeometryTypes = (Map<GeometryType, Map<GeometryType, ?>>) type .getValue(); validateTableIcons(featureTableStyles, typeIconRow, geometryTypeIcons, childGeometryTypes); } } }
Example #8
Source File: GeoPackageExample.java From geopackage-android with MIT License | 5 votes |
private static void createFeatureStylesGeometry2(GeoPackage geoPackage, List<StyleRow> styles, List<IconRow> icons) throws IOException { FeatureDao featureDao = geoPackage.getFeatureDao("geometry2"); FeatureTableStyles geometry2Styles = new FeatureTableStyles(geoPackage, featureDao.getTable()); geometry2Styles.setTableStyle(GeometryType.POINT, styles.get(0)); geometry2Styles.setTableStyle(GeometryType.LINESTRING, styles.get(1)); geometry2Styles.setTableStyle(GeometryType.POLYGON, styles.get(0)); geometry2Styles.setTableStyle(GeometryType.GEOMETRY, styles.get(2)); geometry2Styles.createStyleRelationship(); geometry2Styles.createIconRelationship(); FeatureCursor features = featureDao.queryForAll(); while (features.moveToNext()) { FeatureRow featureRow = features.getRow(); switch (featureRow.getGeometryType()) { case POINT: geometry2Styles.setIcon(featureRow, icons.get(0)); break; case LINESTRING: geometry2Styles.setStyle(featureRow, styles.get(0)); break; case POLYGON: geometry2Styles.setStyle(featureRow, styles.get(1)); break; default: } } features.close(); }
Example #9
Source File: FeatureStylesUtils.java From geopackage-android with MIT License | 5 votes |
private static void validateRowIcons(FeatureTableStyles featureTableStyles, FeatureRow featureRow, GeometryType geometryType, IconRow tableIconDefault, Map<GeometryType, IconRow> geometryTypeTableIcons, Map<Long, Map<GeometryType, IconRow>> featureResultsIcons) { IconRow iconRow = null; if (geometryType == null) { iconRow = featureTableStyles.getIcon(featureRow); geometryType = featureRow.getGeometryType(); } else { iconRow = featureTableStyles.getIcon(featureRow, geometryType); } IconRow expectedIconRow = getExpectedRowIcon(featureRow, geometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); if (expectedIconRow != null) { TestCase.assertEquals(expectedIconRow.getId(), iconRow.getId()); TestCase.assertNotNull(iconRow.getTable()); TestCase.assertTrue(iconRow.getId() >= 0); iconRow.getName(); iconRow.getDescription(); iconRow.getWidth(); iconRow.getHeight(); iconRow.getAnchorU(); iconRow.getAnchorV(); } else { TestCase.assertNull(iconRow); } }
Example #10
Source File: FeatureStylesUtils.java From geopackage-android with MIT License | 5 votes |
private static void validateRowIcons(FeatureTableStyles featureTableStyles, FeatureRow featureRow, IconRow tableIconDefault, Map<GeometryType, IconRow> geometryTypeTableIcons, Map<Long, Map<GeometryType, IconRow>> featureResultsIcons) { GeometryType geometryType = featureRow.getGeometryType(); validateRowIcons(featureTableStyles, featureRow, null, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); if (geometryType != null) { List<GeometryType> geometryTypes = GeometryUtils .parentHierarchy(geometryType); for (GeometryType parentGeometryType : geometryTypes) { validateRowIcons(featureTableStyles, featureRow, parentGeometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); } List<GeometryType> childTypes = getAllChildTypes(geometryType); for (GeometryType childGeometryType : childTypes) { validateRowIcons(featureTableStyles, featureRow, childGeometryType, tableIconDefault, geometryTypeTableIcons, featureResultsIcons); } } }
Example #11
Source File: FeatureStylesUtils.java From geopackage-android with MIT License | 5 votes |
private static void validateTableIcons( FeatureTableStyles featureTableStyles, IconRow iconRow, Map<GeometryType, IconRow> geometryTypeIcons, Map<GeometryType, Map<GeometryType, ?>> geometryTypes) throws IOException { if (geometryTypes != null) { for (Entry<GeometryType, Map<GeometryType, ?>> type : geometryTypes .entrySet()) { IconRow typeIconRow = iconRow; if (geometryTypeIcons.containsKey(type.getKey())) { typeIconRow = geometryTypeIcons.get(type.getKey()); TestCase.assertTrue(typeIconRow.getId() >= 0); TestCase.assertNotNull(typeIconRow.getData()); TestCase.assertEquals("image/" + TestConstants.ICON_POINT_IMAGE_EXTENSION, typeIconRow.getContentType()); Bitmap iconImage = typeIconRow.getDataBitmap(); TestCase.assertNotNull(iconImage); TestCase.assertTrue(iconImage.getWidth() > 0); TestCase.assertTrue(iconImage.getHeight() > 0); } TestCase.assertEquals(typeIconRow.getId(), featureTableStyles .getTableIcon(type.getKey()).getId()); @SuppressWarnings("unchecked") Map<GeometryType, Map<GeometryType, ?>> childGeometryTypes = (Map<GeometryType, Map<GeometryType, ?>>) type .getValue(); validateTableIcons(featureTableStyles, typeIconRow, geometryTypeIcons, childGeometryTypes); } } }
Example #12
Source File: FeatureTiles.java From geopackage-android with MIT License | 4 votes |
/** * Call after making changes to the point icon, point radius, or paint stroke widths. * Determines the pixel overlap between tiles */ public void calculateDrawOverlap() { if (pointIcon != null) { heightOverlap = this.density * pointIcon.getHeight(); widthOverlap = this.density * pointIcon.getWidth(); } else { heightOverlap = this.density * pointRadius; widthOverlap = this.density * pointRadius; } float linePaintHalfStroke = this.density * lineStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, linePaintHalfStroke); widthOverlap = Math.max(widthOverlap, linePaintHalfStroke); float polygonPaintHalfStroke = this.density * polygonStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, polygonPaintHalfStroke); widthOverlap = Math.max(widthOverlap, polygonPaintHalfStroke); if (featureTableStyles != null && featureTableStyles.has()) { // Style Rows Set<Long> styleRowIds = new HashSet<>(); List<Long> tableStyleIds = featureTableStyles.getAllTableStyleIds(); if (tableStyleIds != null) { styleRowIds.addAll(tableStyleIds); } List<Long> styleIds = featureTableStyles.getAllStyleIds(); if (styleIds != null) { styleRowIds.addAll(styleIds); } StyleDao styleDao = featureTableStyles.getStyleDao(); for (long styleRowId : styleRowIds) { StyleRow styleRow = styleDao.getRow(styleDao.queryForIdRow(styleRowId)); float styleHalfWidth = this.density * (float) (styleRow.getWidthOrDefault() / 2.0f); widthOverlap = Math.max(widthOverlap, styleHalfWidth); heightOverlap = Math.max(heightOverlap, styleHalfWidth); } // Icon Rows Set<Long> iconRowIds = new HashSet<>(); List<Long> tableIconIds = featureTableStyles.getAllTableIconIds(); if (tableIconIds != null) { iconRowIds.addAll(tableIconIds); } List<Long> iconIds = featureTableStyles.getAllIconIds(); if (iconIds != null) { iconRowIds.addAll(iconIds); } IconDao iconDao = featureTableStyles.getIconDao(); for (long iconRowId : iconRowIds) { IconRow iconRow = iconDao.getRow(iconDao.queryForIdRow(iconRowId)); double[] iconDimensions = iconRow.getDerivedDimensions(); float iconWidth = this.density * (float) Math.ceil(iconDimensions[0]); float iconHeight = this.density * (float) Math.ceil(iconDimensions[1]); widthOverlap = Math.max(widthOverlap, iconWidth); heightOverlap = Math.max(heightOverlap, iconHeight); } } }
Example #13
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createFeatureStylesGeometry1(GeoPackage geoPackage, List<StyleRow> styles, List<IconRow> icons) throws IOException { FeatureDao featureDao = geoPackage.getFeatureDao("geometry1"); FeatureTableStyles geometry1Styles = new FeatureTableStyles(geoPackage, featureDao.getTable()); geometry1Styles.setTableStyleDefault(styles.get(0)); geometry1Styles.setTableStyle(GeometryType.POLYGON, styles.get(1)); geometry1Styles.setTableStyle(GeometryType.POINT, styles.get(2)); geometry1Styles.createStyleRelationship(); geometry1Styles.createIconRelationship(); int pointCount = 0; int lineCount = 0; int polygonCount = 0; FeatureResultSet features = featureDao.queryForAll(); while (features.moveToNext()) { FeatureRow featureRow = features.getRow(); switch (featureRow.getGeometryType()) { case POINT: pointCount++; switch (pointCount) { case 1: geometry1Styles.setIcon(featureRow, icons.get(0)); break; case 2: geometry1Styles.setIcon(featureRow, icons.get(1)); break; case 3: geometry1Styles.setIcon(featureRow, icons.get(2)); break; } break; case LINESTRING: lineCount++; switch (lineCount) { case 2: geometry1Styles.setStyle(featureRow, styles.get(1)); break; case 3: geometry1Styles.setStyle(featureRow, styles.get(2)); break; } break; case POLYGON: polygonCount++; switch (polygonCount) { case 2: geometry1Styles.setStyle(featureRow, styles.get(3)); break; case 3: geometry1Styles.setStyle(featureRow, styles.get(2)); break; } break; default: } } features.close(); }
Example #14
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createFeatureStyleExtension(GeoPackage geoPackage) throws IOException { List<StyleRow> styles = new ArrayList<>(); StyleRow style1 = new StyleRow(); style1.setName("Green"); style1.setDescription("Green Style"); style1.setColor(ColorConstants.GREEN); style1.setWidth(2.0); styles.add(style1); StyleRow style2 = new StyleRow(); style2.setName("Blue with Red Fill"); style2.setDescription("Blue with Red Fill Style"); style2.setColor(new Color(ColorConstants.BLUE)); style2.setFillColor(new Color(255, 0, 0, .4f)); styles.add(style2); StyleRow style3 = new StyleRow(); style3.setName("Orange"); style3.setDescription("Orange Style"); style3.setColor(new Color(0xFFA500)); style3.setWidth(6.5); styles.add(style3); StyleRow style4 = new StyleRow(); style4.setName("Violet with Yellow Fill"); style4.setDescription("Violet with Yellow Fill Style"); style4.setColor(new Color(138, 43, 226)); style4.setWidth(4.1); style4.setFillColor(new Color(new float[] { 61, .89f, .72f }, .3f)); styles.add(style4); List<IconRow> icons = new ArrayList<>(); IconRow icon1 = new IconRow(); icon1.setName("Building"); icon1.setDescription("Building Icon"); icon1.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("building.png"))); icon1.setContentType("image/png"); icon1.setWidth(32.0); icon1.setAnchorU(0.5); icon1.setAnchorV(1.0); icons.add(icon1); IconRow icon2 = new IconRow(); icon2.setName("College"); icon2.setDescription("College Icon"); icon2.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("college.png"))); icon2.setContentType("image/png"); icon2.setWidth(32.0); icon2.setHeight(44.0); icons.add(icon2); IconRow icon3 = new IconRow(); icon3.setName("Tractor"); icon3.setDescription("Tractor Icon"); icon3.setData(GeoPackageIOUtils .fileBytes(TestUtils.getTestFile("tractor.png"))); icon3.setContentType("image/png"); icon3.setAnchorV(1.0); icons.add(icon3); createFeatureStylesGeometry1(geoPackage, styles, icons); createFeatureStylesGeometry2(geoPackage, styles, icons); }
Example #15
Source File: FeatureStylesUtils.java From geopackage-java with MIT License | 4 votes |
private static Map<GeometryType, IconRow> randomIcons( Map<GeometryType, Map<GeometryType, ?>> geometryTypes) throws IOException { return randomIcons(geometryTypes, null); }
Example #16
Source File: FeatureTiles.java From geopackage-java with MIT License | 4 votes |
/** * Call after making changes to the point icon, point radius, or paint * stroke widths. Determines the pixel overlap between tiles */ public void calculateDrawOverlap() { if (pointIcon != null) { heightOverlap = this.scale * pointIcon.getHeight(); widthOverlap = this.scale * pointIcon.getWidth(); } else { heightOverlap = this.scale * pointRadius; widthOverlap = this.scale * pointRadius; } float linePaintHalfStroke = this.scale * lineStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, linePaintHalfStroke); widthOverlap = Math.max(widthOverlap, linePaintHalfStroke); float polygonPaintHalfStroke = this.scale * polygonStrokeWidth / 2.0f; heightOverlap = Math.max(heightOverlap, polygonPaintHalfStroke); widthOverlap = Math.max(widthOverlap, polygonPaintHalfStroke); if (featureTableStyles != null && featureTableStyles.has()) { // Style Rows Set<Long> styleRowIds = new HashSet<>(); List<Long> tableStyleIds = featureTableStyles.getAllTableStyleIds(); if (tableStyleIds != null) { styleRowIds.addAll(tableStyleIds); } List<Long> styleIds = featureTableStyles.getAllStyleIds(); if (styleIds != null) { styleRowIds.addAll(styleIds); } StyleDao styleDao = featureTableStyles.getStyleDao(); for (long styleRowId : styleRowIds) { StyleRow styleRow = styleDao .getRow(styleDao.queryForIdRow(styleRowId)); float styleHalfWidth = this.scale * (float) (styleRow.getWidthOrDefault() / 2.0f); widthOverlap = Math.max(widthOverlap, styleHalfWidth); heightOverlap = Math.max(heightOverlap, styleHalfWidth); } // Icon Rows Set<Long> iconRowIds = new HashSet<>(); List<Long> tableIconIds = featureTableStyles.getAllTableIconIds(); if (tableIconIds != null) { iconRowIds.addAll(tableIconIds); } List<Long> iconIds = featureTableStyles.getAllIconIds(); if (iconIds != null) { iconRowIds.addAll(iconIds); } IconDao iconDao = featureTableStyles.getIconDao(); for (long iconRowId : iconRowIds) { IconRow iconRow = iconDao .getRow(iconDao.queryForIdRow(iconRowId)); double[] iconDimensions = iconRow.getDerivedDimensions(); float iconWidth = this.scale * (float) Math.ceil(iconDimensions[0]); float iconHeight = this.scale * (float) Math.ceil(iconDimensions[1]); widthOverlap = Math.max(widthOverlap, iconWidth); heightOverlap = Math.max(heightOverlap, iconHeight); } } }
Example #17
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createFeatureStylesGeometry1(GeoPackage geoPackage, List<StyleRow> styles, List<IconRow> icons) throws IOException { FeatureDao featureDao = geoPackage.getFeatureDao("geometry1"); FeatureTableStyles geometry1Styles = new FeatureTableStyles(geoPackage, featureDao.getTable()); geometry1Styles.setTableStyleDefault(styles.get(0)); geometry1Styles.setTableStyle(GeometryType.POLYGON, styles.get(1)); geometry1Styles.setTableStyle(GeometryType.POINT, styles.get(2)); geometry1Styles.createStyleRelationship(); geometry1Styles.createIconRelationship(); int pointCount = 0; int lineCount = 0; int polygonCount = 0; FeatureCursor features = featureDao.queryForAll(); while (features.moveToNext()) { FeatureRow featureRow = features.getRow(); switch (featureRow.getGeometryType()) { case POINT: pointCount++; switch (pointCount) { case 1: geometry1Styles.setIcon(featureRow, icons.get(0)); break; case 2: geometry1Styles.setIcon(featureRow, icons.get(1)); break; case 3: geometry1Styles.setIcon(featureRow, icons.get(2)); break; } break; case LINESTRING: lineCount++; switch (lineCount) { case 2: geometry1Styles.setStyle(featureRow, styles.get(1)); break; case 3: geometry1Styles.setStyle(featureRow, styles.get(2)); break; } break; case POLYGON: polygonCount++; switch (polygonCount) { case 2: geometry1Styles.setStyle(featureRow, styles.get(3)); break; case 3: geometry1Styles.setStyle(featureRow, styles.get(2)); break; } break; default: } } features.close(); }
Example #18
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createFeatureStyleExtension(GeoPackage geoPackage) throws IOException, NameNotFoundException { List<StyleRow> styles = new ArrayList<>(); StyleRow style1 = new StyleRow(); style1.setName("Green"); style1.setDescription("Green Style"); style1.setColor(ColorConstants.GREEN); style1.setWidth(2.0); styles.add(style1); StyleRow style2 = new StyleRow(); style2.setName("Blue with Red Fill"); style2.setDescription("Blue with Red Fill Style"); style2.setColor(new Color(ColorConstants.BLUE)); style2.setFillColor(new Color(255, 0, 0, .4f)); styles.add(style2); StyleRow style3 = new StyleRow(); style3.setName("Orange"); style3.setDescription("Orange Style"); style3.setColor(new Color(0xFFA500)); style3.setWidth(6.5); styles.add(style3); StyleRow style4 = new StyleRow(); style4.setName("Violet with Yellow Fill"); style4.setDescription("Violet with Yellow Fill Style"); style4.setColor(new Color(138, 43, 226)); style4.setWidth(4.1); style4.setFillColor(new Color(new float[]{61, .89f, .72f}, .3f)); styles.add(style4); List<IconRow> icons = new ArrayList<>(); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "building.png"); IconRow icon1 = new IconRow(); icon1.setName("Building"); icon1.setDescription("Building Icon"); icon1.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "building.png")), Bitmap.CompressFormat.PNG); icon1.setContentType("image/png"); icon1.setWidth(32.0); icon1.setAnchorU(0.5); icon1.setAnchorV(1.0); icons.add(icon1); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "college.png"); IconRow icon2 = new IconRow(); icon2.setName("College"); icon2.setDescription("College Icon"); icon2.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "college.png")), Bitmap.CompressFormat.PNG); icon2.setContentType("image/png"); icon2.setWidth(32.0); icon2.setHeight(44.0); icons.add(icon2); TestUtils.copyAssetFileToInternalStorage(geoPackage.getContext(), TestUtils.getTestContext(geoPackage.getContext()), "tractor.png"); IconRow icon3 = new IconRow(); icon3.setName("Tractor"); icon3.setDescription("Tractor Icon"); icon3.setData(BitmapFactory.decodeFile( TestUtils.getAssetFileInternalStorageLocation(geoPackage.getContext(), "tractor.png")), Bitmap.CompressFormat.PNG); icon3.setContentType("image/png"); icon3.setAnchorV(1.0); icons.add(icon3); createFeatureStylesGeometry1(geoPackage, styles, icons); createFeatureStylesGeometry2(geoPackage, styles, icons); }
Example #19
Source File: FeatureStylesUtils.java From geopackage-android with MIT License | 4 votes |
private static Map<GeometryType, IconRow> randomIcons(GeoPackage geoPackage, Map<GeometryType, Map<GeometryType, ?>> geometryTypes) throws IOException, NameNotFoundException { return randomIcons(geoPackage, geometryTypes, null); }
Example #20
Source File: StyleUtilsTest.java From geopackage-android-map with MIT License | 4 votes |
private void testSetIcon(float density, int imageWidth, int imageHeight, Double iconWidth, Double iconHeight) throws Exception { Bitmap bitmap = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888); byte[] bytes = BitmapConverter.toBytes(bitmap, Bitmap.CompressFormat.PNG); IconRow icon = new IconRow(); icon.setData(bytes); icon.setWidth(iconWidth); icon.setHeight(iconHeight); double styleWidth; double styleHeight; if (iconWidth == null && iconHeight == null) { styleWidth = imageWidth; styleHeight = imageHeight; } else if (iconWidth != null && iconHeight != null) { styleWidth = iconWidth; styleHeight = iconHeight; } else if (iconWidth != null) { styleWidth = iconWidth; styleHeight = (iconWidth / imageWidth) * imageHeight; } else { styleHeight = iconHeight; styleWidth = (iconHeight / imageHeight) * imageWidth; } Bitmap iconImage = StyleUtils.createIcon(icon, density); TestCase.assertNotNull(iconImage); double expectedWidth = density * styleWidth; double expectedHeight = density * styleHeight; int lowerWidth = (int) Math.floor(expectedWidth - 0.5); int upperWidth = (int) Math.ceil(expectedWidth + 0.5); int lowerHeight = (int) Math.floor(expectedHeight - 0.5); int upperHeight = (int) Math.ceil(expectedHeight + 0.5); TestCase.assertTrue(iconImage.getWidth() + " not between " + lowerWidth + " and " + upperWidth, iconImage.getWidth() >= lowerWidth && iconImage.getWidth() <= upperWidth); TestCase.assertTrue(iconImage.getHeight() + " not between " + lowerHeight + " and " + upperHeight, iconImage.getHeight() >= lowerHeight && iconImage.getHeight() <= upperHeight); }
Example #21
Source File: StyleUtils.java From geopackage-android-map with MIT License | 3 votes |
/** * Create new marker options populated with the icon * * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @param iconCache icon cache * @return marker options populated with the icon */ public static MarkerOptions createMarkerOptions(IconRow icon, float density, IconCache iconCache) { MarkerOptions markerOptions = new MarkerOptions(); setIcon(markerOptions, icon, density, iconCache); return markerOptions; }
Example #22
Source File: StyleCache.java From geopackage-android-map with MIT License | 2 votes |
/** * Set the icon into the marker options * * @param markerOptions marker options * @param icon icon row * @return true if icon was set into the marker options */ public boolean setIcon(MarkerOptions markerOptions, IconRow icon) { return StyleUtils.setIcon(markerOptions, icon, density, iconCache); }
Example #23
Source File: StyleUtils.java From geopackage-android-map with MIT License | 2 votes |
/** * Create new marker options populated with the icon * * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @return marker options populated with the icon */ public static MarkerOptions createMarkerOptions(IconRow icon, float density) { return createMarkerOptions(icon, density, null); }
Example #24
Source File: FeatureTiles.java From geopackage-java with MIT License | 2 votes |
/** * Get the icon image from the icon row * * @param iconRow * icon row * @return icon image */ protected BufferedImage getIcon(IconRow iconRow) { return iconCache.createIcon(iconRow, scale); }
Example #25
Source File: StyleCache.java From geopackage-android-map with MIT License | 2 votes |
/** * Create new marker options populated with the icon * * @param icon icon row * @return marker options populated with the icon */ public MarkerOptions createMarkerOptions(IconRow icon) { return StyleUtils.createMarkerOptions(icon, density, iconCache); }
Example #26
Source File: StyleUtils.java From geopackage-android-map with MIT License | 2 votes |
/** * Create the icon bitmap * * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @param iconCache icon cache * @return icon bitmap */ public static Bitmap createIcon(IconRow icon, float density, IconCache iconCache) { return iconCache.createIcon(icon, density); }
Example #27
Source File: StyleUtils.java From geopackage-android-map with MIT License | 2 votes |
/** * Create the icon bitmap * * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @return icon bitmap */ public static Bitmap createIcon(IconRow icon, float density) { return IconCache.createIconNoCache(icon, density); }
Example #28
Source File: StyleUtils.java From geopackage-android-map with MIT License | 2 votes |
/** * Set the icon into the marker options * * @param markerOptions marker options * @param icon icon row * @param density display density: {@link android.util.DisplayMetrics#density} * @return true if icon was set into the marker options */ public static boolean setIcon(MarkerOptions markerOptions, IconRow icon, float density) { return setIcon(markerOptions, icon, density, null); }
Example #29
Source File: StyleCache.java From geopackage-android-map with MIT License | 2 votes |
/** * Create the icon bitmap * * @param icon icon row * @return icon bitmap */ public Bitmap createIcon(IconRow icon) { return StyleUtils.createIcon(icon, density, iconCache); }
Example #30
Source File: FeatureTiles.java From geopackage-android with MIT License | 2 votes |
/** * Get the icon bitmap from the icon row * * @param iconRow icon row * @return icon bitmap */ protected Bitmap getIcon(IconRow iconRow) { return iconCache.createIcon(iconRow, density); }