mil.nga.sf.GeometryType Java Examples

The following examples show how to use mil.nga.sf.GeometryType. 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: GeoPackageTestUtils.java    From geopackage-java with 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 File: FeatureTableStyles.java    From geopackage-java with 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 #3
Source File: FeatureRowData.java    From geopackage-android with 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 #4
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 #5
Source File: GeoPackageTestUtils.java    From geopackage-java with 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 #6
Source File: GeometryExtensions.java    From geopackage-core-java with 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 #7
Source File: FeatureTableStyles.java    From geopackage-android with 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 File: GeoPackageTestUtils.java    From geopackage-java with 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 File: FeatureTableStyles.java    From geopackage-java with 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 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 #11
Source File: StyleMappingDao.java    From geopackage-android with 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 File: StyleMappingDao.java    From geopackage-java with 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 File: GeoPackageExample.java    From geopackage-android with 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 #14
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 #15
Source File: Styles.java    From geopackage-android with 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 #16
Source File: Icons.java    From geopackage-java with 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 File: TableInfo.java    From geopackage-core-java with 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 #18
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 #19
Source File: FeatureRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the simple features geometry type
 * 
 * @return geometry type
 * @since 3.2.0
 */
public GeometryType getGeometryType() {
	Geometry geometry = getGeometryValue();
	GeometryType geometryType = null;
	if (geometry != null) {
		geometryType = geometry.getGeometryType();
	}
	return geometryType;
}
 
Example #20
Source File: FeatureStylesUtils.java    From geopackage-java with 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 #21
Source File: StyleMappingRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Set the geometry type
 * 
 * @param geometryType
 *            geometry type
 */
public void setGeometryType(GeometryType geometryType) {
	String geometryTypeName = null;
	if (geometryType != null) {
		geometryTypeName = geometryType.getName();
	}
	setValue(getGeometryTypeNameColumnIndex(), geometryTypeName);
}
 
Example #22
Source File: TestUtils.java    From geopackage-java with 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 #23
Source File: FeatureUtils.java    From geopackage-android with 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 #24
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 #25
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 #26
Source File: FeatureIndexManagerUtils.java    From geopackage-android with 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);
}
 
Example #27
Source File: FeatureUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Validate Multi Polygon
 *
 * @param topGeometry
 * @param multiPolygon
 */
private static void validateMultiPolygon(Geometry topGeometry,
                                         MultiPolygon multiPolygon) {

    TestCase.assertEquals(GeometryType.MULTIPOLYGON,
            multiPolygon.getGeometryType());

    validateZAndM(topGeometry, multiPolygon);

    for (Polygon polygon : multiPolygon.getPolygons()) {
        validatePolygon(topGeometry, polygon);
    }

}
 
Example #28
Source File: FeatureTableStyles.java    From geopackage-android with 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 featureId    feature id
 * @param geometryType geometry type
 * @return feature style
 */
public FeatureStyle getFeatureStyle(long featureId,
                                    GeometryType geometryType) {

    FeatureStyle featureStyle = null;

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

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

    return featureStyle;
}
 
Example #29
Source File: Icons.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Set the icon for the geometry type
 * 
 * @param iconRow
 *            icon row
 * @param geometryType
 *            geometry type
 */
public void setIcon(IconRow iconRow, GeometryType geometryType) {
	if (iconRow != null) {
		iconRow.setTableIcon(tableIcons);
	}
	if (geometryType != null) {
		if (iconRow != null) {
			icons.put(geometryType, iconRow);
		} else {
			icons.remove(geometryType);
		}
	} else {
		defaultIcon = iconRow;
	}
}
 
Example #30
Source File: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
private void validateExtensions(GeoPackage geoPackage, boolean has)
        throws SQLException {

    ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();

    TestCase.assertEquals(has && RTREE_SPATIAL_INDEX,
            new RTreeIndexExtension(geoPackage).has());
    TestCase.assertEquals(
            has
                    && (RELATED_TABLES_FEATURES || RELATED_TABLES_MEDIA || RELATED_TABLES_SIMPLE_ATTRIBUTES),
            new RelatedTablesExtension(geoPackage).has());
    TestCase.assertEquals(
            has && COVERAGE_DATA,
            extensionsDao.isTableExists()
                    && !extensionsDao.queryByExtension(
                    CoverageData.EXTENSION_NAME).isEmpty());

    TestCase.assertEquals(has && SCHEMA,
            new SchemaExtension(geoPackage).has());
    TestCase.assertEquals(has && METADATA,
            new MetadataExtension(geoPackage).has());
    TestCase.assertEquals(
            has && NON_LINEAR_GEOMETRY_TYPES,
            extensionsDao.isTableExists()
                    && !extensionsDao
                    .queryByExtension(
                            GeometryExtensions
                                    .getExtensionName(GeometryType.CIRCULARSTRING))
                    .isEmpty());
    TestCase.assertEquals(has && WEBP, extensionsDao.isTableExists()
            && !extensionsDao
            .queryByExtension(WebPExtension.EXTENSION_NAME)
            .isEmpty());
    TestCase.assertEquals(has && CRS_WKT,
            new CrsWktExtension(geoPackage).has());

}