Java Code Examples for mil.nga.geopackage.GeoPackage#createAttributesTableWithId()
The following examples show how to use
mil.nga.geopackage.GeoPackage#createAttributesTableWithId() .
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: 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 2
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); } }