Java Code Examples for mil.nga.sf.GeometryType

The following examples show how to use mil.nga.sf.GeometryType. These examples are extracted from open source projects. 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 Project: geopackage-java   Author: ngageoint   File: GeoPackageTestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Test create feature table with metadata, id column, and additional
 * columns
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreateFeatureTableWithMetadataIdColumnAdditionalColumns(
		GeoPackage geoPackage) throws SQLException {

	GeometryColumns geometryColumns = new GeometryColumns();
	geometryColumns.setId(new TableColumnKey("feature_metadata", "geom"));
	geometryColumns.setGeometryType(GeometryType.POINT);
	geometryColumns.setZ((byte) 1);
	geometryColumns.setM((byte) 0);

	BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45);

	List<FeatureColumn> additionalColumns = getFeatureColumns();

	SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao()
			.getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG,
					ProjectionConstants.EPSG_WEB_MERCATOR);
	String idColumn = "my_other_id";
	geometryColumns = geoPackage.createFeatureTableWithMetadata(
			geometryColumns, idColumn, additionalColumns, boundingBox,
			srs.getId());

	validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn,
			additionalColumns);
}
 
Example #2
Source Project: geopackage-core-java   Author: ngageoint   File: GeometryExtensions.java    License: MIT License 6 votes vote down vote up
/**
 * Get the extension name of a GeoPackage extension Geometry
 * 
 * @param geometryType
 *            geometry type
 * @return extension name
 */
public static String getExtensionName(GeometryType geometryType) {

	if (!isExtension(geometryType)) {
		throw new GeoPackageException(GeometryType.class.getSimpleName()
				+ " is not an extension: " + geometryType.getName());
	}

	if (!isGeoPackageExtension(geometryType)) {
		throw new GeoPackageException(
				GeometryType.class.getSimpleName()
						+ " is not a GeoPackage extension, User-Defined requires an author: "
						+ geometryType.getName());
	}

	String extensionName = GeoPackageConstants.EXTENSION_AUTHOR
			+ Extensions.EXTENSION_NAME_DIVIDER
			+ GeoPackageConstants.GEOMETRY_EXTENSION_PREFIX
			+ Extensions.EXTENSION_NAME_DIVIDER + geometryType.getName();

	return extensionName;
}
 
Example #3
Source Project: geopackage-java   Author: ngageoint   File: GeoPackageTestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Test create feature table with metadata
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreateFeatureTableWithMetadata(GeoPackage geoPackage)
		throws SQLException {

	GeometryColumns geometryColumns = new GeometryColumns();
	geometryColumns.setId(new TableColumnKey("feature_metadata", "geom"));
	geometryColumns.setGeometryType(GeometryType.POINT);
	geometryColumns.setZ((byte) 1);
	geometryColumns.setM((byte) 0);

	BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45);

	SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao()
			.getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG,
					ProjectionConstants.EPSG_WEB_MERCATOR);
	geometryColumns = geoPackage.createFeatureTableWithMetadata(
			geometryColumns, boundingBox, srs.getId());

	validateFeatureTableWithMetadata(geoPackage, geometryColumns, null,
			null);
}
 
Example #4
Source Project: geopackage-java   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #5
Source Project: geopackage-android   Author: ngageoint   File: FeatureRowData.java    License: MIT License 6 votes vote down vote up
/**
 * Build a JSON compatible object
 *
 * @param includePoints     true to include point geometries, ignored if includeGeometries is true
 * @param includeGeometries true to include all geometry types
 * @return JSON compatible object
 */
public Object jsonCompatible(boolean includePoints, boolean includeGeometries) {

    Map<String, Object> jsonValues = new HashMap<>();

    for (String key : values.keySet()) {
        Object jsonValue = null;
        Object value = values.get(key);
        if (key.equals(geometryColumn)) {
            GeoPackageGeometryData geometryData = (GeoPackageGeometryData) value;
            if (geometryData.getGeometry() != null) {
                if (includeGeometries || (includePoints && geometryData.getGeometry().getGeometryType() == GeometryType.POINT)) {
                    jsonValue = FeatureConverter.toMap(geometryData.getGeometry());
                }
            } else {
                jsonValue = value;
            }
            if (jsonValue != null) {
                jsonValues.put(key, jsonValue);
            }
        }
    }

    return jsonValues;
}
 
Example #6
Source Project: geopackage-java   Author: ngageoint   File: FeatureTableStyles.java    License: MIT License 6 votes vote down vote up
/**
 * Get the style of the feature, searching in order: feature geometry type
 * style, feature default style, table geometry type style, table default
 * style
 * 
 * @param featureId
 *            feature id
 * @param geometryType
 *            geometry type
 * @return style row
 */
public StyleRow getStyle(long featureId, GeometryType geometryType) {

	StyleRow styleRow = featureStyleExtension.getStyle(tableName, featureId,
			geometryType, false);

	if (styleRow == null) {

		// Table Style
		Styles styles = getCachedTableStyles();
		if (styles != null) {
			styleRow = styles.getStyle(geometryType);
		}

	}

	return styleRow;
}
 
Example #7
Source Project: geopackage-android   Author: ngageoint   File: FeatureTableStyles.java    License: MIT License 6 votes vote down vote up
/**
 * Get the style of the feature, searching in order: feature geometry type
 * style, feature default style, table geometry type style, table default
 * style
 *
 * @param featureId    feature id
 * @param geometryType geometry type
 * @return style row
 */
public StyleRow getStyle(long featureId, GeometryType geometryType) {

    StyleRow styleRow = featureStyleExtension.getStyle(tableName,
            featureId, geometryType, false);

    if (styleRow == null) {

        // Table Style
        Styles styles = getCachedTableStyles();
        if (styles != null) {
            styleRow = styles.getStyle(geometryType);
        }

    }

    return styleRow;
}
 
Example #8
Source Project: geopackage-java   Author: ngageoint   File: GeoPackageTestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Test create feature table with metadata and additional columns
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreateFeatureTableWithMetadataAdditionalColumns(
		GeoPackage geoPackage) throws SQLException {

	GeometryColumns geometryColumns = new GeometryColumns();
	geometryColumns.setId(new TableColumnKey("feature_metadata", "geom"));
	geometryColumns.setGeometryType(GeometryType.POINT);
	geometryColumns.setZ((byte) 1);
	geometryColumns.setM((byte) 0);

	BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45);

	List<FeatureColumn> additionalColumns = getFeatureColumns();

	SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao()
			.getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG,
					ProjectionConstants.EPSG_WEB_MERCATOR);
	geometryColumns = geoPackage.createFeatureTableWithMetadata(
			geometryColumns, additionalColumns, boundingBox, srs.getId());

	validateFeatureTableWithMetadata(geoPackage, geometryColumns, null,
			additionalColumns);
}
 
Example #9
Source Project: geopackage-java   Author: ngageoint   File: FeatureTableStyles.java    License: MIT License 6 votes vote down vote up
/**
 * Get the icon of the feature, searching in order: feature geometry type
 * icon, feature default icon, table geometry type icon, table default icon
 * 
 * @param featureId
 *            feature id
 * @param geometryType
 *            geometry type
 * @return icon row
 */
public IconRow getIcon(long featureId, GeometryType geometryType) {

	IconRow iconRow = featureStyleExtension.getIcon(tableName, featureId,
			geometryType, false);

	if (iconRow == null) {

		// Table Icon
		Icons icons = getCachedTableIcons();
		if (icons != null) {
			iconRow = icons.getIcon(geometryType);
		}

	}

	return iconRow;
}
 
Example #10
Source Project: geopackage-android   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #11
Source Project: geopackage-android   Author: ngageoint   File: StyleMappingDao.java    License: MIT License 6 votes vote down vote up
/**
 * Delete by base is and geometry type
 *
 * @param id           base id
 * @param geometryType geometry type
 * @return rows deleted
 */
public int deleteByBaseId(long id, GeometryType geometryType) {

    String geometryTypeName = null;
    if (geometryType != null) {
        geometryTypeName = geometryType.getName();
    }

    StringBuilder where = new StringBuilder();
    where.append(buildWhere(StyleMappingTable.COLUMN_BASE_ID, id));
    where.append(" AND ");
    where.append(buildWhere(StyleMappingTable.COLUMN_GEOMETRY_TYPE_NAME,
            geometryTypeName));

    List<Object> whereArguments = new ArrayList<>();
    whereArguments.add(id);
    if (geometryTypeName != null) {
        whereArguments.add(geometryTypeName);
    }

    String[] whereArgs = buildWhereArgs(whereArguments);

    int deleted = delete(where.toString(), whereArgs);

    return deleted;
}
 
Example #12
Source Project: geopackage-java   Author: ngageoint   File: StyleMappingDao.java    License: MIT License 6 votes vote down vote up
/**
 * Delete by base is and geometry type
 * 
 * @param id
 *            base id
 * @param geometryType
 *            geometry type
 * @return rows deleted
 */
public int deleteByBaseId(long id, GeometryType geometryType) {

	String geometryTypeName = null;
	if (geometryType != null) {
		geometryTypeName = geometryType.getName();
	}

	StringBuilder where = new StringBuilder();
	where.append(buildWhere(StyleMappingTable.COLUMN_BASE_ID, id));
	where.append(" AND ");
	where.append(buildWhere(StyleMappingTable.COLUMN_GEOMETRY_TYPE_NAME,
			geometryTypeName));

	List<Object> whereArguments = new ArrayList<>();
	whereArguments.add(id);
	if (geometryTypeName != null) {
		whereArguments.add(geometryTypeName);
	}

	String[] whereArgs = buildWhereArgs(whereArguments);

	int deleted = delete(where.toString(), whereArgs);

	return deleted;
}
 
Example #13
Source Project: geopackage-android-map   Author: ngageoint   File: TestUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Create the feature table with data columns entry
 *
 * @param geoPackage
 * @param contents
 * @param geometryColumn
 * @param geometryType
 * @return
 * @throws SQLException
 */
public static FeatureTable createFeatureTable(GeoPackage geoPackage,
                                              Contents contents, String geometryColumn, GeometryType geometryType)
        throws SQLException {

    FeatureTable table = buildFeatureTable(contents.getTableName(),
            geometryColumn, geometryType);
    geoPackage.createFeatureTable(table);

    double random = Math.random();

    DataColumnsDao dataColumnsDao = geoPackage.getDataColumnsDao();
    DataColumns dataColumns = new DataColumns();
    dataColumns.setContents(contents);
    dataColumns.setColumnName(TEST_INTEGER_COLUMN);
    dataColumns.setName(contents.getTableName());
    dataColumns.setTitle("TEST_TITLE");
    dataColumns.setDescription("TEST_DESCRIPTION");
    dataColumns.setMimeType("TEST_MIME_TYPE");

    if (random < (1.0 / 3.0)) {
        dataColumns.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
    } else if (random < (2.0 / 3.0)) {
        dataColumns.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
    } else {
        dataColumns.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
    }

    dataColumnsDao.create(dataColumns);

    return table;
}
 
Example #14
Source Project: geopackage-android   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #15
Source Project: geopackage-core-java   Author: ngageoint   File: TableInfo.java    License: MIT License 5 votes vote down vote up
/**
 * Get the data type from the type value
 * 
 * @param type
 *            type value
 * @return data type or null
 */
public static GeoPackageDataType getDataType(String type) {

	GeoPackageDataType dataType = GeoPackageDataType.findName(type);

	if (dataType == null) {

		// Check if a geometry and set as a blob
		if (GeometryType.findName(type) != null) {
			dataType = GeoPackageDataType.BLOB;
		}

	}
	return dataType;
}
 
Example #16
Source Project: geopackage-java   Author: ngageoint   File: Icons.java    License: MIT License 5 votes vote down vote up
/**
 * Get the icon for the geometry type
 * 
 * @param geometryType
 *            geometry type
 * @return icon
 */
public IconRow getIcon(GeometryType geometryType) {

	IconRow iconRow = null;

	if (geometryType != null && !icons.isEmpty()) {
		List<GeometryType> geometryTypes = GeometryUtils
				.parentHierarchy(geometryType);
		geometryTypes.add(0, geometryType);
		for (GeometryType type : geometryTypes) {
			iconRow = icons.get(type);
			if (iconRow != null) {
				break;
			}
		}
	}

	if (iconRow == null) {
		iconRow = defaultIcon;
	}

	if (iconRow == null && geometryType == null && icons.size() == 1) {
		iconRow = icons.values().iterator().next();
	}

	return iconRow;
}
 
Example #17
Source Project: geopackage-android   Author: ngageoint   File: Styles.java    License: MIT License 5 votes vote down vote up
/**
 * Set the style for the geometry type
 *
 * @param styleRow     style row
 * @param geometryType geometry type
 */
public void setStyle(StyleRow styleRow, GeometryType geometryType) {
    if (styleRow != null) {
        styleRow.setTableStyle(tableStyles);
    }
    if (geometryType != null) {
        if (styleRow != null) {
            styles.put(geometryType, styleRow);
        } else {
            styles.remove(geometryType);
        }
    } else {
        defaultStyle = styleRow;
    }
}
 
Example #18
Source Project: geopackage-android   Author: ngageoint   File: FeatureStyleExtension.java    License: MIT License 5 votes vote down vote up
/**
 * Get the style of the feature table and geometry type
 *
 * @param featureTable feature table
 * @param geometryType geometry type
 * @return style row
 */
public StyleRow getTableStyle(String featureTable, GeometryType geometryType) {
    StyleRow styleRow = null;
    Styles tableStyles = getTableStyles(featureTable);
    if (tableStyles != null) {
        styleRow = tableStyles.getStyle(geometryType);
    }
    return styleRow;
}
 
Example #19
Source Project: geopackage-android   Author: ngageoint   File: FeatureStyleExtension.java    License: MIT License 5 votes vote down vote up
/**
 * Get the feature style (style and icon) of the feature, searching in
 * order: feature geometry type style or icon, feature default style or
 * icon, table geometry type style or icon, table default style or icon
 *
 * @param featureTable feature table
 * @param featureId    feature id
 * @param geometryType geometry type
 * @return feature style
 */
public FeatureStyle getFeatureStyle(String featureTable, long featureId,
                                    GeometryType geometryType) {

    FeatureStyle featureStyle = null;

    StyleRow style = getStyle(featureTable, featureId, geometryType);
    IconRow icon = getIcon(featureTable, featureId, geometryType);

    if (style != null || icon != null) {
        featureStyle = new FeatureStyle(style, icon);
    }

    return featureStyle;
}
 
Example #20
Source Project: geopackage-java   Author: ngageoint   File: FeatureStyleExtension.java    License: MIT License 5 votes vote down vote up
/**
 * Get the icon of the feature, searching in order: feature geometry type
 * icon, feature default icon, table geometry type icon, table default icon
 * 
 * @param featureTable
 *            feature table
 * @param featureId
 *            feature id
 * @param geometryType
 *            geometry type
 * @param icon
 *            icon row
 */
public void setIcon(String featureTable, long featureId,
		GeometryType geometryType, IconRow icon) {
	deleteIcon(featureTable, featureId, geometryType);
	if (icon != null) {

		createIconRelationship(featureTable);

		long iconId = getOrInsertIcon(icon);

		StyleMappingDao mappingDao = getIconMappingDao(featureTable);
		insertStyleMapping(mappingDao, featureId, iconId, geometryType);

	}
}
 
Example #21
Source Project: geopackage-android   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #22
Source Project: geopackage-mapcache-android   Author: ngageoint   File: GeoPackageViewModel.java    License: MIT License 5 votes vote down vote up
/**
 * Create feature table in the given geopackage
 */
public boolean createFeatureTable(String gpName, BoundingBox boundingBox, GeometryType geometryType, String tableName){
    if(repository.createFeatureTable(gpName, boundingBox, geometryType, tableName)){
        regenerateGeoPackageTableList();
        return true;
    }
    return false;
}
 
Example #23
Source Project: geopackage-java   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #24
Source Project: geopackage-java   Author: ngageoint   File: FeatureStylesUtils.java    License: 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 #25
Source Project: geopackage-java   Author: ngageoint   File: FeatureStylesUtils.java    License: MIT License 5 votes vote down vote up
private static List<GeometryType> getAllChildTypes(
		GeometryType geometryType) {

	List<GeometryType> allChildTypes = new ArrayList<>();

	List<GeometryType> childTypes = GeometryUtils.childTypes(geometryType);
	allChildTypes.addAll(childTypes);

	for (GeometryType childType : childTypes) {
		allChildTypes.addAll(getAllChildTypes(childType));
	}

	return allChildTypes;
}
 
Example #26
Source Project: geopackage-java   Author: ngageoint   File: TestUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Build an example feature table
 * 
 * @param tableName
 * @param geometryColumn
 * @param geometryType
 * @return feature table
 */
public static FeatureTable buildFeatureTable(String tableName,
		String geometryColumn, GeometryType geometryType) {

	List<FeatureColumn> columns = new ArrayList<FeatureColumn>();

	columns.add(FeatureColumn.createPrimaryKeyColumn(0, "id"));
	columns.add(FeatureColumn.createColumn(7, "test_text_limited",
			GeoPackageDataType.TEXT, 5L));
	columns.add(FeatureColumn.createColumn(8, "test_blob_limited",
			GeoPackageDataType.BLOB, 7L));
	columns.add(FeatureColumn.createColumn(9, "test_date",
			GeoPackageDataType.DATE));
	columns.add(FeatureColumn.createColumn(10, "test_datetime",
			GeoPackageDataType.DATETIME));
	columns.add(FeatureColumn.createGeometryColumn(1, geometryColumn,
			geometryType));
	columns.add(FeatureColumn.createColumn(2, "test_text",
			GeoPackageDataType.TEXT, false, ""));
	columns.add(FeatureColumn.createColumn(3, "test_real",
			GeoPackageDataType.REAL));
	columns.add(FeatureColumn.createColumn(4, "test_boolean",
			GeoPackageDataType.BOOLEAN));
	columns.add(FeatureColumn.createColumn(5, "test_blob",
			GeoPackageDataType.BLOB));
	columns.add(FeatureColumn.createColumn(6, TEST_INTEGER_COLUMN,
			GeoPackageDataType.INTEGER));

	FeatureTable table = new FeatureTable(tableName, geometryColumn,
			columns);

	return table;
}
 
Example #27
Source Project: geopackage-android   Author: ngageoint   File: FeatureUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Validate Multi Point
 *
 * @param topGeometry
 * @param multiPoint
 */
private static void validateMultiPoint(Geometry topGeometry,
                                       MultiPoint multiPoint) {

    TestCase.assertEquals(GeometryType.MULTIPOINT,
            multiPoint.getGeometryType());

    validateZAndM(topGeometry, multiPoint);

    for (Point point : multiPoint.getPoints()) {
        validatePoint(topGeometry, point);
    }

}
 
Example #28
Source Project: geopackage-android   Author: ngageoint   File: GeoPackageExample.java    License: MIT License 5 votes vote down vote up
private static void createFeatures(GeoPackage geoPackage,
                                   SpatialReferenceSystem srs, String tableName, GeometryType type,
                                   Geometry geometry, String name) throws SQLException {

    List<Geometry> geometries = new ArrayList<>();
    geometries.add(geometry);
    List<String> names = new ArrayList<>();
    names.add(name);

    createFeatures(geoPackage, srs, tableName, type, geometries, names);
}
 
Example #29
Source Project: geopackage-android   Author: ngageoint   File: GeoPackageExample.java    License: 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 #30
Source Project: geopackage-android   Author: ngageoint   File: FeatureIndexManagerUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Test large index
 *
 * @param activity    activity
 * @param geoPackage  GeoPackage
 * @param numFeatures num features
 * @param verbose     verbose printing
 * @throws SQLException upon error
 */
public static void testLargeIndex(Activity activity, GeoPackage geoPackage, int numFeatures,
                                  boolean verbose) throws SQLException {

    String featureTable = "large_index";

    GeometryColumns geometryColumns = new GeometryColumns();
    geometryColumns.setId(new TableColumnKey(featureTable, "geom"));
    geometryColumns.setGeometryType(GeometryType.POLYGON);
    geometryColumns.setZ((byte) 0);
    geometryColumns.setM((byte) 0);

    BoundingBox boundingBox = new BoundingBox(-180, -90, 180, 90);

    SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao()
            .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG,
                    ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
    List<FeatureColumn> additionalColumns = GeoPackageTestUtils
            .getFeatureColumns();
    geometryColumns = geoPackage.createFeatureTableWithMetadata(
            geometryColumns, additionalColumns, boundingBox, srs.getId());

    FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns);

    System.out.println();
    System.out.println("Inserting Feature Rows: " + numFeatures);
    TestUtils.addRowsToFeatureTable(geoPackage, geometryColumns,
            featureDao.getTable(), numFeatures, false, false, false);

    testTimedIndex(activity, geoPackage, featureTable, true, verbose);
}