mil.nga.geopackage.extension.style.FeatureTableStyles Java Examples

The following examples show how to use mil.nga.geopackage.extension.style.FeatureTableStyles. 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: FeatureStylesUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
private static void validateTableStyles(
        FeatureTableStyles featureTableStyles, StyleRow styleRow,
        Map<GeometryType, StyleRow> geometryTypeStyles,
        Map<GeometryType, Map<GeometryType, ?>> geometryTypes) {

    if (geometryTypes != null) {
        for (Entry<GeometryType, Map<GeometryType, ?>> type : geometryTypes
                .entrySet()) {
            StyleRow typeStyleRow = styleRow;
            if (geometryTypeStyles.containsKey(type.getKey())) {
                typeStyleRow = geometryTypeStyles.get(type.getKey());
            }
            TestCase.assertEquals(typeStyleRow.getId(), featureTableStyles
                    .getTableStyle(type.getKey()).getId());
            @SuppressWarnings("unchecked")
            Map<GeometryType, Map<GeometryType, ?>> childGeometryTypes = (Map<GeometryType, Map<GeometryType, ?>>) type
                    .getValue();
            validateTableStyles(featureTableStyles, typeStyleRow,
                    geometryTypeStyles, childGeometryTypes);
        }
    }
}
 
Example #2
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 6 votes vote down vote up
private static void validateTableStyles(
		FeatureTableStyles featureTableStyles, StyleRow styleRow,
		Map<GeometryType, StyleRow> geometryTypeStyles,
		Map<GeometryType, Map<GeometryType, ?>> geometryTypes) {

	if (geometryTypes != null) {
		for (Entry<GeometryType, Map<GeometryType, ?>> type : geometryTypes
				.entrySet()) {
			StyleRow typeStyleRow = styleRow;
			if (geometryTypeStyles.containsKey(type.getKey())) {
				typeStyleRow = geometryTypeStyles.get(type.getKey());
			}
			TestCase.assertEquals(typeStyleRow.getId(), featureTableStyles
					.getTableStyle(type.getKey()).getId());
			@SuppressWarnings("unchecked")
			Map<GeometryType, Map<GeometryType, ?>> childGeometryTypes = (Map<GeometryType, Map<GeometryType, ?>>) type
					.getValue();
			validateTableStyles(featureTableStyles, typeStyleRow,
					geometryTypeStyles, childGeometryTypes);
		}
	}
}
 
Example #3
Source File: GeoPackageExample.java    From geopackage-java with MIT License 5 votes vote down vote up
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-android with MIT License 5 votes vote down vote up
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 #5
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void validateRowStyles(
        FeatureTableStyles featureTableStyles, FeatureRow featureRow,
        StyleRow tableStyleDefault,
        Map<GeometryType, StyleRow> geometryTypeTableStyles,
        Map<Long, Map<GeometryType, StyleRow>> featureResultsStyles) {

    GeometryType geometryType = featureRow.getGeometryType();

    validateRowStyles(featureTableStyles, featureRow, null,
            tableStyleDefault, geometryTypeTableStyles,
            featureResultsStyles);

    if (geometryType != null) {

        List<GeometryType> geometryTypes = GeometryUtils
                .parentHierarchy(geometryType);
        for (GeometryType parentGeometryType : geometryTypes) {
            validateRowStyles(featureTableStyles, featureRow,
                    parentGeometryType, tableStyleDefault,
                    geometryTypeTableStyles, featureResultsStyles);
        }

        List<GeometryType> childTypes = getAllChildTypes(geometryType);
        for (GeometryType childGeometryType : childTypes) {
            validateRowStyles(featureTableStyles, featureRow,
                    childGeometryType, tableStyleDefault,
                    geometryTypeTableStyles, featureResultsStyles);
        }
    }

}
 
Example #6
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void validateRowStyles(
        FeatureTableStyles featureTableStyles, FeatureRow featureRow,
        GeometryType geometryType, StyleRow tableStyleDefault,
        Map<GeometryType, StyleRow> geometryTypeTableStyles,
        Map<Long, Map<GeometryType, StyleRow>> featureResultsStyles) {

    StyleRow styleRow = null;
    if (geometryType == null) {
        styleRow = featureTableStyles.getStyle(featureRow);
        geometryType = featureRow.getGeometryType();
    } else {
        styleRow = featureTableStyles.getStyle(featureRow, geometryType);
    }

    StyleRow expectedStyleRow = getExpectedRowStyle(featureRow,
            geometryType, tableStyleDefault, geometryTypeTableStyles,
            featureResultsStyles);

    if (expectedStyleRow != null) {
        TestCase.assertEquals(expectedStyleRow.getId(), styleRow.getId());
        TestCase.assertNotNull(styleRow.getTable());
        TestCase.assertTrue(styleRow.getId() >= 0);
        styleRow.getName();
        styleRow.getDescription();
        styleRow.getColor();
        styleRow.getHexColor();
        styleRow.getOpacity();
        styleRow.getWidth();
        styleRow.getFillColor();
        styleRow.getFillHexColor();
        styleRow.getFillOpacity();
    } else {
        TestCase.assertNull(styleRow);
    }

}
 
Example #7
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
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 #8
Source File: FeatureStylesUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
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 #9
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
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: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
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 #11
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
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 #12
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void validateRowStyles(FeatureTableStyles featureTableStyles,
		FeatureRow featureRow, GeometryType geometryType,
		StyleRow tableStyleDefault,
		Map<GeometryType, StyleRow> geometryTypeTableStyles,
		Map<Long, Map<GeometryType, StyleRow>> featureResultsStyles) {

	StyleRow styleRow = null;
	if (geometryType == null) {
		styleRow = featureTableStyles.getStyle(featureRow);
		geometryType = featureRow.getGeometryType();
	} else {
		styleRow = featureTableStyles.getStyle(featureRow, geometryType);
	}

	StyleRow expectedStyleRow = getExpectedRowStyle(featureRow,
			geometryType, tableStyleDefault, geometryTypeTableStyles,
			featureResultsStyles);

	if (expectedStyleRow != null) {
		TestCase.assertEquals(expectedStyleRow.getId(), styleRow.getId());
		TestCase.assertNotNull(styleRow.getTable());
		TestCase.assertTrue(styleRow.getId() >= 0);
		styleRow.getName();
		styleRow.getDescription();
		styleRow.getColor();
		styleRow.getHexColor();
		styleRow.getOpacity();
		styleRow.getWidth();
		styleRow.getFillColor();
		styleRow.getFillHexColor();
		styleRow.getFillOpacity();
	} else {
		TestCase.assertNull(styleRow);
	}

}
 
Example #13
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void validateRowStyles(FeatureTableStyles featureTableStyles,
		FeatureRow featureRow, StyleRow tableStyleDefault,
		Map<GeometryType, StyleRow> geometryTypeTableStyles,
		Map<Long, Map<GeometryType, StyleRow>> featureResultsStyles) {

	GeometryType geometryType = featureRow.getGeometryType();

	validateRowStyles(featureTableStyles, featureRow, null,
			tableStyleDefault, geometryTypeTableStyles,
			featureResultsStyles);

	if (geometryType != null) {

		List<GeometryType> geometryTypes = GeometryUtils
				.parentHierarchy(geometryType);
		for (GeometryType parentGeometryType : geometryTypes) {
			validateRowStyles(featureTableStyles, featureRow,
					parentGeometryType, tableStyleDefault,
					geometryTypeTableStyles, featureResultsStyles);
		}

		List<GeometryType> childTypes = getAllChildTypes(geometryType);
		for (GeometryType childGeometryType : childTypes) {
			validateRowStyles(featureTableStyles, featureRow,
					childGeometryType, tableStyleDefault,
					geometryTypeTableStyles, featureResultsStyles);
		}
	}

}
 
Example #14
Source File: FeatureStylesUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
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 #15
Source File: GeoPackageUtils.java    From geopackage-mapcache-android with MIT License 4 votes vote down vote up
/**
 * Prepare the feature draw limits and defaults
 *
 * @param context
 * @param geoPackage
 * @param featureTable
 * @param pointAlpha
 * @param lineAlpha
 * @param polygonAlpha
 * @param polygonFillAlpha
 * @param pointColor
 * @param lineColor
 * @param pointRadius
 * @param lineStroke
 * @param polygonColor
 * @param polygonStroke
 * @param polygonFill
 * @param polygonFillColor
 */
public static void prepareFeatureDraw(Context context, GeoPackage geoPackage, String featureTable, EditText pointAlpha, EditText lineAlpha, EditText polygonAlpha, EditText polygonFillAlpha,
                                      EditText pointColor, EditText lineColor, EditText pointRadius, EditText lineStroke,
                                      EditText polygonColor, EditText polygonStroke, CheckBox polygonFill, EditText polygonFillColor) {

    FeatureTableStyles featureTableStyles = new FeatureTableStyles(geoPackage, featureTable);

    // Set feature limits
    pointAlpha.setFilters(new InputFilter[]{new InputFilterMinMax(
            0, 255)});
    lineAlpha.setFilters(new InputFilter[]{new InputFilterMinMax(
            0, 255)});
    polygonAlpha.setFilters(new InputFilter[]{new InputFilterMinMax(
            0, 255)});
    polygonFillAlpha.setFilters(new InputFilter[]{new InputFilterMinMax(
            0, 255)});

    // Set default feature attributes
    FeatureTiles featureTiles = new DefaultFeatureTiles(context);
    String defaultColor = "#000000";

    StyleRow pointStyle = featureTableStyles.getTableStyle(GeometryType.POINT);
    if(pointStyle != null){
        mil.nga.geopackage.style.Color pointStyleColor = pointStyle.getColorOrDefault();
        pointColor.setText(pointStyleColor.getColorHex());
        pointAlpha.setText(String.valueOf(pointStyleColor.getAlpha()));
        pointRadius.setText(new DecimalFormat("0.0#").format(pointStyle.getWidthOrDefault() / 2.0));
    }else{
        Paint pointPaint = featureTiles.getPointPaint();
        pointColor.setText(defaultColor);
        pointAlpha.setText(String.valueOf(pointPaint.getAlpha()));
        pointRadius.setText(String.valueOf(featureTiles.getPointRadius()));
    }

    StyleRow lineStyle = featureTableStyles.getTableStyle(GeometryType.LINESTRING);
    if(lineStyle != null){
        mil.nga.geopackage.style.Color lineStyleColor = lineStyle.getColorOrDefault();
        lineColor.setText(lineStyleColor.getColorHex());
        lineAlpha.setText(String.valueOf(lineStyleColor.getAlpha()));
        lineStroke.setText(new DecimalFormat("0.0#").format(lineStyle.getWidthOrDefault()));
    }else{
        Paint linePaint = featureTiles.getLinePaintCopy();
        lineColor.setText(defaultColor);
        lineAlpha.setText(String.valueOf(linePaint.getAlpha()));
        lineStroke.setText(String.valueOf(linePaint.getStrokeWidth()));
    }

    StyleRow polygonStyle = featureTableStyles.getTableStyle(GeometryType.POLYGON);
    if(polygonStyle != null){
        mil.nga.geopackage.style.Color polygonStyleColor = polygonStyle.getColorOrDefault();
        polygonColor.setText(polygonStyleColor.getColorHex());
        polygonAlpha.setText(String.valueOf(polygonStyleColor.getAlpha()));
        polygonStroke.setText(new DecimalFormat("0.0#").format(polygonStyle.getWidthOrDefault()));
        mil.nga.geopackage.style.Color polygonStyleFillColor = polygonStyle.getFillColor();
        polygonFill.setChecked(polygonStyleFillColor != null);
        if(polygonStyleFillColor != null){
            polygonFillColor.setText(polygonStyleFillColor.getColorHex());
            polygonFillAlpha.setText(String.valueOf(polygonStyleFillColor.getAlpha()));
        }else{
            polygonFillColor.setText(defaultColor);
            polygonFillAlpha.setText(String.valueOf(255));
        }
    }else{
        Paint polygonPaint = featureTiles.getPolygonPaintCopy();
        polygonColor.setText(defaultColor);
        polygonAlpha.setText(String.valueOf(polygonPaint.getAlpha()));
        polygonStroke.setText(String.valueOf(polygonPaint.getStrokeWidth()));

        polygonFill.setChecked(featureTiles.isFillPolygon());
        Paint polygonFillPaint = featureTiles.getPolygonFillPaintCopy();
        polygonFillColor.setText(defaultColor);
        polygonFillAlpha.setText(String.valueOf(polygonFillPaint.getAlpha()));
    }

}
 
Example #16
Source File: GeoPackageExample.java    From geopackage-java with MIT License 4 votes vote down vote up
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 #17
Source File: FeatureTiles.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * 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
 * @param width
 *            drawn tile width
 * @param height
 *            drawn tile height
 * @since 3.2.0
 */
public FeatureTiles(GeoPackage geoPackage, FeatureDao featureDao,
		float scale, int width, int height) {

	this.featureDao = featureDao;
	if (featureDao != null) {
		this.projection = featureDao.getProjection();
	}

	this.scale = scale;

	tileWidth = width;
	tileHeight = height;

	compressFormat = GeoPackageJavaProperties.getProperty(
			JavaPropertyConstants.FEATURE_TILES,
			JavaPropertyConstants.FEATURE_TILES_COMPRESS_FORMAT);

	pointRadius = GeoPackageJavaProperties.getFloatProperty(
			JavaPropertyConstants.FEATURE_TILES_POINT,
			JavaPropertyConstants.FEATURE_TILES_RADIUS);
	pointPaint.setColor(GeoPackageJavaProperties.getColorProperty(
			JavaPropertyConstants.FEATURE_TILES_POINT,
			JavaPropertyConstants.FEATURE_TILES_COLOR));

	lineStrokeWidth = GeoPackageJavaProperties.getFloatProperty(
			JavaPropertyConstants.FEATURE_TILES_LINE,
			JavaPropertyConstants.FEATURE_TILES_STROKE_WIDTH);
	linePaint.setStrokeWidth(this.scale * lineStrokeWidth);
	linePaint.setColor(GeoPackageJavaProperties.getColorProperty(
			JavaPropertyConstants.FEATURE_TILES_LINE,
			JavaPropertyConstants.FEATURE_TILES_COLOR));

	polygonStrokeWidth = GeoPackageJavaProperties.getFloatProperty(
			JavaPropertyConstants.FEATURE_TILES_POLYGON,
			JavaPropertyConstants.FEATURE_TILES_STROKE_WIDTH);
	polygonPaint.setStrokeWidth(this.scale * polygonStrokeWidth);
	polygonPaint.setColor(GeoPackageJavaProperties.getColorProperty(
			JavaPropertyConstants.FEATURE_TILES_POLYGON,
			JavaPropertyConstants.FEATURE_TILES_COLOR));

	fillPolygon = GeoPackageJavaProperties.getBooleanProperty(
			JavaPropertyConstants.FEATURE_TILES_POLYGON_FILL);
	polygonFillPaint.setColor(GeoPackageJavaProperties.getColorProperty(
			JavaPropertyConstants.FEATURE_TILES_POLYGON_FILL,
			JavaPropertyConstants.FEATURE_TILES_COLOR));

	if (geoPackage != null) {

		featureIndex = new FeatureTableIndex(geoPackage, featureDao);
		if (!featureIndex.isIndexed()) {
			featureIndex.close();
			featureIndex = null;
		}

		featureTableStyles = new FeatureTableStyles(geoPackage,
				featureDao.getTable());
		if (!featureTableStyles.has()) {
			featureTableStyles = null;
		}

	}

	calculateDrawOverlap();
}
 
Example #18
Source File: FeatureTiles.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * 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 #19
Source File: GeoPackageExample.java    From geopackage-android with MIT License 4 votes vote down vote up
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 #20
Source File: FeatureTiles.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Set the feature table styles
 *
 * @param featureTableStyles
 *            feature table styles
 * @since 3.2.0
 */
public void setFeatureTableStyles(FeatureTableStyles featureTableStyles) {
	this.featureTableStyles = featureTableStyles;
}
 
Example #21
Source File: FeatureTiles.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the feature table styles
 *
 * @return feature table styles
 * @since 3.2.0
 */
public FeatureTableStyles getFeatureTableStyles() {
	return featureTableStyles;
}
 
Example #22
Source File: FeatureTiles.java    From geopackage-android with MIT License 2 votes vote down vote up
/**
 * Set the feature table styles
 *
 * @param featureTableStyles feature table styles
 * @since 3.2.0
 */
public void setFeatureTableStyles(FeatureTableStyles featureTableStyles) {
    this.featureTableStyles = featureTableStyles;
}
 
Example #23
Source File: FeatureTiles.java    From geopackage-android with MIT License 2 votes vote down vote up
/**
 * Get the feature table styles
 *
 * @return feature table styles
 * @since 3.2.0
 */
public FeatureTableStyles getFeatureTableStyles() {
    return featureTableStyles;
}