Java Code Examples for mil.nga.geopackage.features.user.FeatureRow#getRowColumnType()
The following examples show how to use
mil.nga.geopackage.features.user.FeatureRow#getRowColumnType() .
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: FeatureUtils.java From geopackage-android with MIT License | 4 votes |
/** * Validate a feature row * * @param columns * @param featureRow */ private static void validateFeatureRow(String[] columns, FeatureRow featureRow) { TestCase.assertEquals(columns.length, featureRow.columnCount()); for (int i = 0; i < featureRow.columnCount(); i++) { FeatureColumn column = featureRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], featureRow.getColumnName(i)); TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i])); int rowType = featureRow.getRowColumnType(i); Object value = featureRow.getValue(i); switch (rowType) { case Cursor.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case Cursor.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case Cursor.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case Cursor.FIELD_TYPE_BLOB: if (featureRow.getGeometryColumnIndex() == i) { TestCase.assertTrue(value instanceof GeoPackageGeometryData); } else { TestCase.assertTrue(value instanceof byte[]); } break; case Cursor.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(featureRow.getId() >= 0); }
Example 2
Source File: FeatureUtils.java From geopackage-java with MIT License | 4 votes |
/** * Validate a feature row * * @param columns * @param featureRow */ private static void validateFeatureRow(String[] columns, FeatureRow featureRow) { TestCase.assertEquals(columns.length, featureRow.columnCount()); for (int i = 0; i < featureRow.columnCount(); i++) { FeatureColumn column = featureRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], featureRow.getColumnName(i)); TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i])); int rowType = featureRow.getRowColumnType(i); Object value = featureRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: if (featureRow.getGeometryColumnIndex() == i) { TestCase.assertTrue(value instanceof GeoPackageGeometryData); } else { TestCase.assertTrue(value instanceof byte[]); } break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(featureRow.getId() >= 0); }