mil.nga.geopackage.attributes.AttributesTable Java Examples
The following examples show how to use
mil.nga.geopackage.attributes.AttributesTable.
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: GeoPackageImpl.java From geopackage-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public AttributesDao getAttributesDao(Contents contents) { if (contents == null) { throw new GeoPackageException("Non null " + Contents.class.getSimpleName() + " is required to create " + AttributesDao.class.getSimpleName()); } if (contents.getDataType() != ContentsDataType.ATTRIBUTES) { throw new GeoPackageException(Contents.class.getSimpleName() + " is required to be of type " + ContentsDataType.ATTRIBUTES + ". Actual: " + contents.getDataTypeString()); } // Read the existing table and create the dao AttributesTableReader tableReader = new AttributesTableReader( contents.getTableName()); final AttributesTable attributesTable = tableReader.readTable(database); attributesTable.setContents(contents); AttributesDao dao = new AttributesDao(getName(), database, attributesTable); return dao; }
Example #2
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public AttributesTable createAttributesTable(String tableName, String idColumnName, List<AttributesColumn> additionalColumns, Collection<Constraint> constraints) { if (idColumnName == null) { idColumnName = "id"; } List<AttributesColumn> columns = new ArrayList<AttributesColumn>(); columns.add(AttributesColumn.createPrimaryKeyColumn(idColumnName)); if (additionalColumns != null) { columns.addAll(additionalColumns); } return createAttributesTable(tableName, columns, constraints); }
Example #3
Source File: GeoPackageImpl.java From geopackage-android with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public AttributesDao getAttributesDao(Contents contents) { if (contents == null) { throw new GeoPackageException("Non null " + Contents.class.getSimpleName() + " is required to create " + AttributesDao.class.getSimpleName()); } if (contents.getDataType() != ContentsDataType.ATTRIBUTES) { throw new GeoPackageException(Contents.class.getSimpleName() + " is required to be of type " + ContentsDataType.ATTRIBUTES + ". Actual: " + contents.getDataTypeString()); } // Read the existing table and create the dao AttributesTableReader tableReader = new AttributesTableReader( contents.getTableName()); final AttributesTable attributesTable = tableReader.readTable(database); attributesTable.setContents(contents); AttributesDao dao = new AttributesDao(getName(), database, attributesTable); // Register the table name (with and without quotes) to wrap cursors with the attributes cursor registerCursorWrapper(attributesTable.getTableName(), new GeoPackageCursorWrapper() { @Override public Cursor wrapCursor(Cursor cursor) { return new AttributesCursor(attributesTable, cursor); } }); return dao; }
Example #4
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public AttributesTable createAttributesTable(String tableName, String idColumnName, List<AttributesColumn> additionalColumns) { return createAttributesTable(tableName, idColumnName, additionalColumns, null); }
Example #5
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public AttributesTable createAttributesTableWithId(String tableName, List<AttributesColumn> additionalColumns, Collection<Constraint> constraints) { return createAttributesTable(tableName, null, additionalColumns, constraints); }
Example #6
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public AttributesTable createAttributesTable(String tableName, List<AttributesColumn> columns) { return createAttributesTable(tableName, columns, null); }
Example #7
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createAttributes(GeoPackage geoPackage) { List<AttributesColumn> columns = new ArrayList<AttributesColumn>(); columns.add(AttributesColumn.createColumn(TEXT_COLUMN, GeoPackageDataType.TEXT, false, "")); columns.add(AttributesColumn.createColumn(REAL_COLUMN, GeoPackageDataType.REAL)); columns.add(AttributesColumn.createColumn(BOOLEAN_COLUMN, GeoPackageDataType.BOOLEAN)); columns.add(AttributesColumn.createColumn(BLOB_COLUMN, GeoPackageDataType.BLOB)); columns.add(AttributesColumn.createColumn(INTEGER_COLUMN, GeoPackageDataType.INTEGER)); columns.add(AttributesColumn.createColumn(TEXT_LIMITED_COLUMN, GeoPackageDataType.TEXT, (long) UUID.randomUUID().toString().length())); columns.add(AttributesColumn.createColumn(BLOB_LIMITED_COLUMN, GeoPackageDataType.BLOB, (long) UUID.randomUUID().toString().getBytes().length)); columns.add(AttributesColumn.createColumn(DATE_COLUMN, GeoPackageDataType.DATE)); columns.add(AttributesColumn.createColumn(DATETIME_COLUMN, GeoPackageDataType.DATETIME)); AttributesTable attributesTable = geoPackage .createAttributesTableWithId("attributes", columns); AttributesDao attributesDao = geoPackage .getAttributesDao(attributesTable.getTableName()); for (int i = 0; i < 10; i++) { AttributesRow newRow = attributesDao.newRow(); newRow.setValue(TEXT_COLUMN, UUID.randomUUID().toString()); newRow.setValue(REAL_COLUMN, Math.random() * 5000.0); newRow.setValue(BOOLEAN_COLUMN, Math.random() < .5 ? false : true); newRow.setValue(BLOB_COLUMN, UUID.randomUUID().toString().getBytes()); newRow.setValue(INTEGER_COLUMN, (int) (Math.random() * 500)); newRow.setValue(TEXT_LIMITED_COLUMN, UUID.randomUUID().toString()); newRow.setValue(BLOB_LIMITED_COLUMN, UUID.randomUUID().toString().getBytes()); newRow.setValue(DATE_COLUMN, new Date()); newRow.setValue(DATETIME_COLUMN, new Date()); attributesDao.create(newRow); } }
Example #8
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public AttributesTable createAttributesTableWithId(String tableName, List<AttributesColumn> additionalColumns) { return createAttributesTable(tableName, null, additionalColumns); }
Example #9
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public void createAttributesTable(AttributesTable table) { createUserTable(table); }
Example #10
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createAttributes(GeoPackage geoPackage) { List<AttributesColumn> columns = new ArrayList<AttributesColumn>(); columns.add(AttributesColumn.createColumn(TEXT_COLUMN, GeoPackageDataType.TEXT, false, "")); columns.add(AttributesColumn.createColumn(REAL_COLUMN, GeoPackageDataType.REAL)); columns.add(AttributesColumn.createColumn(BOOLEAN_COLUMN, GeoPackageDataType.BOOLEAN)); columns.add(AttributesColumn.createColumn(BLOB_COLUMN, GeoPackageDataType.BLOB)); columns.add(AttributesColumn.createColumn(INTEGER_COLUMN, GeoPackageDataType.INTEGER)); columns.add(AttributesColumn.createColumn(TEXT_LIMITED_COLUMN, GeoPackageDataType.TEXT, (long) UUID.randomUUID().toString() .length())); columns.add(AttributesColumn.createColumn(BLOB_LIMITED_COLUMN, GeoPackageDataType.BLOB, (long) UUID.randomUUID().toString() .getBytes().length)); columns.add(AttributesColumn.createColumn(DATE_COLUMN, GeoPackageDataType.DATE)); columns.add(AttributesColumn.createColumn(DATETIME_COLUMN, GeoPackageDataType.DATETIME)); AttributesTable attributesTable = geoPackage .createAttributesTableWithId("attributes", columns); AttributesDao attributesDao = geoPackage .getAttributesDao(attributesTable.getTableName()); for (int i = 0; i < 10; i++) { AttributesRow newRow = attributesDao.newRow(); newRow.setValue(TEXT_COLUMN, UUID.randomUUID().toString()); newRow.setValue(REAL_COLUMN, Math.random() * 5000.0); newRow.setValue(BOOLEAN_COLUMN, Math.random() < .5 ? false : true); newRow.setValue(BLOB_COLUMN, UUID.randomUUID().toString() .getBytes()); newRow.setValue(INTEGER_COLUMN, (int) (Math.random() * 500)); newRow.setValue(TEXT_LIMITED_COLUMN, UUID.randomUUID().toString()); newRow.setValue(BLOB_LIMITED_COLUMN, UUID.randomUUID().toString() .getBytes()); newRow.setValue(DATE_COLUMN, new Date()); newRow.setValue(DATETIME_COLUMN, new Date()); attributesDao.create(newRow); } }
Example #11
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 3 votes |
/** * Adds an attributes relationship between the base table and user * attributes related table. Creates the user mapping table and an * attributes table if needed. * * @param baseTableName * base table name * @param attributesTable * user attributes table * @param userMappingTable * user mapping table * @return The relationship that was added * @since 3.2.0 */ public ExtendedRelation addAttributesRelationship(String baseTableName, AttributesTable attributesTable, UserMappingTable userMappingTable) { return addRelationship(baseTableName, attributesTable, userMappingTable); }
Example #12
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 2 votes |
/** * Adds an attributes relationship between the base table and user * attributes related table. Creates a default user mapping table and the * attributes table if needed. * * @param baseTableName * base table name * @param attributesTable * user attributes table * @param mappingTableName * user mapping table name * @return The relationship that was added * @since 3.2.0 */ public ExtendedRelation addAttributesRelationship(String baseTableName, AttributesTable attributesTable, String mappingTableName) { return addRelationship(baseTableName, attributesTable, mappingTableName); }
Example #13
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table (only the attributes table is created, no * Contents entry is created) * * @param table * attributes table * @since 1.2.1 */ public void createAttributesTable(AttributesTable table);
Example #14
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with 1 + additionalColumns.size() * columns, an id column named "id" and the provided additional columns. * * @param tableName * table name * @param additionalColumns * additional attributes table columns to create in addition to * id * @return attributes table * @since 1.2.1 */ public AttributesTable createAttributesTableWithId(String tableName, List<AttributesColumn> additionalColumns);
Example #15
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with 1 + additionalColumns.size() * columns, an id column named "id" and the provided additional columns. * * @param tableName * table name * @param additionalColumns * additional attributes table columns to create in addition to * id * @param constraints * constraints * @return attributes table * @since 3.3.0 */ public AttributesTable createAttributesTableWithId(String tableName, List<AttributesColumn> additionalColumns, Collection<Constraint> constraints);
Example #16
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with 1 + additionalColumns.size() * columns, an id column with the provided name and the provided additional * columns. * * @param tableName * table name * @param idColumnName * id column name * @param additionalColumns * additional attributes table columns to create in addition to * id * @return attributes table * @since 1.2.1 */ public AttributesTable createAttributesTable(String tableName, String idColumnName, List<AttributesColumn> additionalColumns);
Example #17
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with 1 + additionalColumns.size() * columns, an id column with the provided name and the provided additional * columns. * * @param tableName * table name * @param idColumnName * id column name * @param additionalColumns * additional attributes table columns to create in addition to * id * @param constraints * constraints * @return attributes table * @since 3.3.0 */ public AttributesTable createAttributesTable(String tableName, String idColumnName, List<AttributesColumn> additionalColumns, Collection<Constraint> constraints);
Example #18
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with columns.size() columns and must * include an integer id column * * @param tableName * table name * @param columns * table columns to create * @return attributes table * @since 1.2.1 */ public AttributesTable createAttributesTable(String tableName, List<AttributesColumn> columns);
Example #19
Source File: GeoPackageCore.java From geopackage-core-java with MIT License | 2 votes |
/** * Create a new attributes table and a new Contents * * The attributes table will be created with columns.size() columns and must * include an integer id column * * @param tableName * table name * @param columns * table columns to create * @param constraints * constraints * @return attributes table * @since 3.3.0 */ public AttributesTable createAttributesTable(String tableName, List<AttributesColumn> columns, Collection<Constraint> constraints);
Example #20
Source File: StyleTable.java From geopackage-core-java with MIT License | 2 votes |
/** * Constructor * * @param attributesTable * attributes table */ public StyleTable(AttributesTable attributesTable) { this(); setContents(attributesTable.getContents()); }