Java Code Examples for mil.nga.geopackage.extension.style.IconRow#getDerivedDimensions()

The following examples show how to use mil.nga.geopackage.extension.style.IconRow#getDerivedDimensions() . 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 vote down vote up
/**
 * 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 2
Source File: FeatureTiles.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * 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);
		}

	}

}