Search in sources :

Example 1 with FeatureTable

use of mil.nga.geopackage.features.user.FeatureTable in project geopackage-android-map by ngageoint.

the class TestUtils method createFeatureTable.

/**
 * 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 = SchemaExtension.getDataColumnsDao(geoPackage);
    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;
}
Also used : FeatureTable(mil.nga.geopackage.features.user.FeatureTable) DataColumns(mil.nga.geopackage.extension.schema.columns.DataColumns) DataColumnsDao(mil.nga.geopackage.extension.schema.columns.DataColumnsDao)

Example 2 with FeatureTable

use of mil.nga.geopackage.features.user.FeatureTable in project geopackage-android-map by ngageoint.

the class TestSetupTeardown method setUpCreateFeatures.

/**
 * Set up create for features test
 *
 * @param geoPackage
 * @param allowEmptyFeatures
 * @throws SQLException
 */
private static void setUpCreateFeatures(GeoPackage geoPackage, boolean allowEmptyFeatures) throws SQLException {
    // Get existing SRS objects
    SpatialReferenceSystemDao srsDao = geoPackage.getSpatialReferenceSystemDao();
    SpatialReferenceSystem epsgSrs = srsDao.queryForId(4326l);
    SpatialReferenceSystem undefinedCartesianSrs = srsDao.queryForId(-1l);
    SpatialReferenceSystem undefinedGeographicSrs = srsDao.queryForId(0l);
    TestCase.assertNotNull(epsgSrs);
    TestCase.assertNotNull(undefinedCartesianSrs);
    TestCase.assertNotNull(undefinedGeographicSrs);
    // Create the Geometry Columns table
    geoPackage.createGeometryColumnsTable();
    // Create new Contents
    ContentsDao contentsDao = geoPackage.getContentsDao();
    Contents point2dContents = new Contents();
    point2dContents.setTableName("point2d");
    point2dContents.setDataType(ContentsDataType.FEATURES);
    point2dContents.setIdentifier("point2d");
    // point2dContents.setDescription("");
    // point2dContents.setLastChange(new Date());
    point2dContents.setMinX(-180.0);
    point2dContents.setMinY(-90.0);
    point2dContents.setMaxX(180.0);
    point2dContents.setMaxY(90.0);
    point2dContents.setSrs(epsgSrs);
    Contents polygon2dContents = new Contents();
    polygon2dContents.setTableName("polygon2d");
    polygon2dContents.setDataType(ContentsDataType.FEATURES);
    polygon2dContents.setIdentifier("polygon2d");
    // polygon2dContents.setDescription("");
    // polygon2dContents.setLastChange(new Date());
    polygon2dContents.setMinX(0.0);
    polygon2dContents.setMinY(0.0);
    polygon2dContents.setMaxX(10.0);
    polygon2dContents.setMaxY(10.0);
    polygon2dContents.setSrs(undefinedGeographicSrs);
    Contents point3dContents = new Contents();
    point3dContents.setTableName("point3d");
    point3dContents.setDataType(ContentsDataType.FEATURES);
    point3dContents.setIdentifier("point3d");
    // point3dContents.setDescription("");
    // point3dContents.setLastChange(new Date());
    point3dContents.setMinX(-180.0);
    point3dContents.setMinY(-90.0);
    point3dContents.setMaxX(180.0);
    point3dContents.setMaxY(90.0);
    point3dContents.setSrs(undefinedCartesianSrs);
    Contents lineString3dMContents = new Contents();
    lineString3dMContents.setTableName("lineString3dM");
    lineString3dMContents.setDataType(ContentsDataType.FEATURES);
    lineString3dMContents.setIdentifier("lineString3dM");
    // lineString3dMContents.setDescription("");
    // lineString3dMContents.setLastChange(new Date());
    lineString3dMContents.setMinX(-180.0);
    lineString3dMContents.setMinY(-90.0);
    lineString3dMContents.setMaxX(180.0);
    lineString3dMContents.setMaxY(90.0);
    lineString3dMContents.setSrs(undefinedCartesianSrs);
    // Create Data Column Constraints table and rows
    TestUtils.createConstraints(geoPackage);
    // Create data columns table
    (new SchemaExtension(geoPackage)).createDataColumnsTable();
    String geometryColumn = "geometry";
    // Create the feature tables
    FeatureTable point2dTable = TestUtils.createFeatureTable(geoPackage, point2dContents, geometryColumn, GeometryType.POINT);
    FeatureTable polygon2dTable = TestUtils.createFeatureTable(geoPackage, polygon2dContents, geometryColumn, GeometryType.POLYGON);
    FeatureTable point3dTable = TestUtils.createFeatureTable(geoPackage, point3dContents, geometryColumn, GeometryType.POINT);
    FeatureTable lineString3dMTable = TestUtils.createFeatureTable(geoPackage, lineString3dMContents, geometryColumn, GeometryType.LINESTRING);
    // Create the contents
    contentsDao.create(point2dContents);
    contentsDao.create(polygon2dContents);
    contentsDao.create(point3dContents);
    contentsDao.create(lineString3dMContents);
    // Create new Geometry Columns
    GeometryColumnsDao geometryColumnsDao = geoPackage.getGeometryColumnsDao();
    GeometryColumns point2dGeometryColumns = new GeometryColumns();
    point2dGeometryColumns.setContents(point2dContents);
    point2dGeometryColumns.setColumnName(geometryColumn);
    point2dGeometryColumns.setGeometryType(GeometryType.POINT);
    point2dGeometryColumns.setSrs(point2dContents.getSrs());
    point2dGeometryColumns.setZ((byte) 0);
    point2dGeometryColumns.setM((byte) 0);
    geometryColumnsDao.create(point2dGeometryColumns);
    GeometryColumns polygon2dGeometryColumns = new GeometryColumns();
    polygon2dGeometryColumns.setContents(polygon2dContents);
    polygon2dGeometryColumns.setColumnName(geometryColumn);
    polygon2dGeometryColumns.setGeometryType(GeometryType.POLYGON);
    polygon2dGeometryColumns.setSrs(polygon2dContents.getSrs());
    polygon2dGeometryColumns.setZ((byte) 0);
    polygon2dGeometryColumns.setM((byte) 0);
    geometryColumnsDao.create(polygon2dGeometryColumns);
    GeometryColumns point3dGeometryColumns = new GeometryColumns();
    point3dGeometryColumns.setContents(point3dContents);
    point3dGeometryColumns.setColumnName(geometryColumn);
    point3dGeometryColumns.setGeometryType(GeometryType.POINT);
    point3dGeometryColumns.setSrs(point3dContents.getSrs());
    point3dGeometryColumns.setZ((byte) 1);
    point3dGeometryColumns.setM((byte) 0);
    geometryColumnsDao.create(point3dGeometryColumns);
    GeometryColumns lineString3dMGeometryColumns = new GeometryColumns();
    lineString3dMGeometryColumns.setContents(lineString3dMContents);
    lineString3dMGeometryColumns.setColumnName(geometryColumn);
    lineString3dMGeometryColumns.setGeometryType(GeometryType.LINESTRING);
    lineString3dMGeometryColumns.setSrs(lineString3dMContents.getSrs());
    lineString3dMGeometryColumns.setZ((byte) 1);
    lineString3dMGeometryColumns.setM((byte) 1);
    geometryColumnsDao.create(lineString3dMGeometryColumns);
    // Populate the feature tables with rows
    TestUtils.addRowsToFeatureTable(geoPackage, point2dGeometryColumns, point2dTable, 3, false, false, allowEmptyFeatures);
    TestUtils.addRowsToFeatureTable(geoPackage, polygon2dGeometryColumns, polygon2dTable, 3, false, false, allowEmptyFeatures);
    TestUtils.addRowsToFeatureTable(geoPackage, point3dGeometryColumns, point3dTable, 3, true, false, allowEmptyFeatures);
    TestUtils.addRowsToFeatureTable(geoPackage, lineString3dMGeometryColumns, lineString3dMTable, 3, true, true, allowEmptyFeatures);
}
Also used : GeometryColumns(mil.nga.geopackage.features.columns.GeometryColumns) SpatialReferenceSystemDao(mil.nga.geopackage.srs.SpatialReferenceSystemDao) SchemaExtension(mil.nga.geopackage.extension.schema.SchemaExtension) FeatureTable(mil.nga.geopackage.features.user.FeatureTable) Contents(mil.nga.geopackage.contents.Contents) SpatialReferenceSystem(mil.nga.geopackage.srs.SpatialReferenceSystem) ContentsDao(mil.nga.geopackage.contents.ContentsDao) GeometryColumnsDao(mil.nga.geopackage.features.columns.GeometryColumnsDao)

Example 3 with FeatureTable

use of mil.nga.geopackage.features.user.FeatureTable in project geopackage-android-map by ngageoint.

the class TestUtils method buildFeatureTable.

/**
 * Build an example feature table
 *
 * @param tableName
 * @param geometryColumn
 * @param geometryType
 * @return
 */
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, false, null));
    columns.add(FeatureColumn.createColumn(8, "test_blob_limited", GeoPackageDataType.BLOB, 7L, false, null));
    columns.add(FeatureColumn.createGeometryColumn(1, geometryColumn, geometryType, false, null));
    columns.add(FeatureColumn.createColumn(2, "test_text", GeoPackageDataType.TEXT, false, ""));
    columns.add(FeatureColumn.createColumn(3, "test_real", GeoPackageDataType.REAL, false, null));
    columns.add(FeatureColumn.createColumn(4, "test_boolean", GeoPackageDataType.BOOLEAN, false, null));
    columns.add(FeatureColumn.createColumn(5, "test_blob", GeoPackageDataType.BLOB, false, null));
    columns.add(FeatureColumn.createColumn(6, TEST_INTEGER_COLUMN, GeoPackageDataType.INTEGER, false, null));
    FeatureTable table = new FeatureTable(tableName, columns);
    return table;
}
Also used : FeatureColumn(mil.nga.geopackage.features.user.FeatureColumn) FeatureTable(mil.nga.geopackage.features.user.FeatureTable) ArrayList(java.util.ArrayList)

Aggregations

FeatureTable (mil.nga.geopackage.features.user.FeatureTable)3 ArrayList (java.util.ArrayList)1 Contents (mil.nga.geopackage.contents.Contents)1 ContentsDao (mil.nga.geopackage.contents.ContentsDao)1 SchemaExtension (mil.nga.geopackage.extension.schema.SchemaExtension)1 DataColumns (mil.nga.geopackage.extension.schema.columns.DataColumns)1 DataColumnsDao (mil.nga.geopackage.extension.schema.columns.DataColumnsDao)1 GeometryColumns (mil.nga.geopackage.features.columns.GeometryColumns)1 GeometryColumnsDao (mil.nga.geopackage.features.columns.GeometryColumnsDao)1 FeatureColumn (mil.nga.geopackage.features.user.FeatureColumn)1 SpatialReferenceSystem (mil.nga.geopackage.srs.SpatialReferenceSystem)1 SpatialReferenceSystemDao (mil.nga.geopackage.srs.SpatialReferenceSystemDao)1