mil.nga.geopackage.geom.GeoPackageGeometryData Java Examples

The following examples show how to use mil.nga.geopackage.geom.GeoPackageGeometryData. 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: FeatureTileUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
public static long insertPolygon(FeatureDao featureDao, double[][]... points) {
    FeatureRow featureRow = featureDao.newRow();
    GeoPackageGeometryData geomData = new GeoPackageGeometryData(
            ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
    Polygon polygon = new Polygon(false, false);
    for (double[][] ring : points) {
        LineString lineString = getLineString(ring);
        polygon.addRing(lineString);
    }
    geomData.setGeometry(polygon);
    featureRow.setGeometry(geomData);
    return featureDao.insert(featureRow);
}
 
Example #2
Source File: GeoPackageGeometryDataUtils.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Compare two geometry envelopes and verify they are equal
 * 
 * @param expected
 * @param actual
 */
private static void compareEnvelopes(GeometryEnvelope expected,
		GeometryEnvelope actual) {

	if (expected == null) {
		TestCase.assertNull(actual);
	} else {
		TestCase.assertNotNull(actual);

		TestCase.assertEquals(
				GeoPackageGeometryData.getIndicator(expected),
				GeoPackageGeometryData.getIndicator(actual));
		TestCase.assertEquals(expected.getMinX(), actual.getMinX());
		TestCase.assertEquals(expected.getMaxX(), actual.getMaxX());
		TestCase.assertEquals(expected.getMinY(), actual.getMinY());
		TestCase.assertEquals(expected.getMaxY(), actual.getMaxY());
		TestCase.assertEquals(expected.hasZ(), actual.hasZ());
		TestCase.assertEquals(expected.getMinZ(), actual.getMinZ());
		TestCase.assertEquals(expected.getMaxZ(), actual.getMaxZ());
		TestCase.assertEquals(expected.hasM(), actual.hasM());
		TestCase.assertEquals(expected.getMinM(), actual.getMinM());
		TestCase.assertEquals(expected.getMaxM(), actual.getMaxM());
	}

}
 
Example #3
Source File: GeoPackageGeometryDataUtils.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Compare two geometry datas and verify they are equal
 * 
 * @param expected
 * @param actual
 */
public static void compareGeometryData(GeoPackageGeometryData expected,
		GeoPackageGeometryData actual) {

	// Compare geometry data attributes
	TestCase.assertEquals(expected.isExtended(), actual.isExtended());
	TestCase.assertEquals(expected.isEmpty(), actual.isEmpty());
	TestCase.assertEquals(expected.getByteOrder(), actual.getByteOrder());
	TestCase.assertEquals(expected.getSrsId(), actual.getSrsId());
	compareEnvelopes(expected.getEnvelope(), actual.getEnvelope());
	TestCase.assertEquals(expected.getWkbGeometryIndex(),
			actual.getWkbGeometryIndex());

	// Compare header bytes
	compareByteArrays(expected.getHeaderBytes(), actual.getHeaderBytes());

	// Compare geometries
	compareGeometries(expected.getGeometry(), actual.getGeometry());

	// Compare well-known binary geometries
	compareByteArrays(expected.getWkbBytes(), actual.getWkbBytes());

	// Compare all bytes
	compareByteArrays(expected.getBytes(), actual.getBytes());

}
 
Example #4
Source File: GeoPackageGeometryDataUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Compare two geometry envelopes and verify they are equal
 *
 * @param expected
 * @param actual
 */
private static void compareEnvelopes(GeometryEnvelope expected,
                                     GeometryEnvelope actual) {

    if (expected == null) {
        TestCase.assertNull(actual);
    } else {
        TestCase.assertNotNull(actual);

        TestCase.assertEquals(GeoPackageGeometryData.getIndicator(expected),
                GeoPackageGeometryData.getIndicator(actual));
        TestCase.assertEquals(expected.getMinX(), actual.getMinX());
        TestCase.assertEquals(expected.getMaxX(), actual.getMaxX());
        TestCase.assertEquals(expected.getMinY(), actual.getMinY());
        TestCase.assertEquals(expected.getMaxY(), actual.getMaxY());
        TestCase.assertEquals(expected.hasZ(), actual.hasZ());
        TestCase.assertEquals(expected.getMinZ(), actual.getMinZ());
        TestCase.assertEquals(expected.getMaxZ(), actual.getMaxZ());
        TestCase.assertEquals(expected.hasM(), actual.hasM());
        TestCase.assertEquals(expected.getMinM(), actual.getMinM());
        TestCase.assertEquals(expected.getMaxM(), actual.getMaxM());
    }

}
 
Example #5
Source File: GeoPackageGeometryDataUtils.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Compare two geometry datas and verify they are equal
 *
 * @param expected
 * @param actual
 */
public static void compareGeometryData(GeoPackageGeometryData expected,
                                       GeoPackageGeometryData actual) {

    // Compare geometry data attributes
    TestCase.assertEquals(expected.isExtended(), actual.isExtended());
    TestCase.assertEquals(expected.isEmpty(), actual.isEmpty());
    TestCase.assertEquals(expected.getByteOrder(), actual.getByteOrder());
    TestCase.assertEquals(expected.getSrsId(), actual.getSrsId());
    compareEnvelopes(expected.getEnvelope(), actual.getEnvelope());
    TestCase.assertEquals(expected.getWkbGeometryIndex(),
            actual.getWkbGeometryIndex());

    // Compare header bytes
    compareByteArrays(expected.getHeaderBytes(), actual.getHeaderBytes());

    // Compare geometries
    compareGeometries(expected.getGeometry(), actual.getGeometry());

    // Compare well-known binary geometries
    compareByteArrays(expected.getWkbBytes(), actual.getWkbBytes());

    // Compare all bytes
    compareByteArrays(expected.getBytes(), actual.getBytes());

}
 
Example #6
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 #7
Source File: FeatureTableCoreIndex.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Index the geometry id and geometry data
 * 
 * @param tableIndex
 *            table index
 * @param geomId
 *            geometry id
 * @param geomData
 *            geometry data
 * 
 * @return true if indexed
 */
protected boolean index(TableIndex tableIndex, long geomId,
		GeoPackageGeometryData geomData) {

	boolean indexed = false;

	if (geomData != null) {

		// Get or build the envelope
		GeometryEnvelope envelope = geomData.getOrBuildEnvelope();

		// Create the new index row
		if (envelope != null) {
			GeometryIndex geometryIndex = geometryIndexDao
					.populate(tableIndex, geomId, envelope);
			try {
				geometryIndexDao.createOrUpdate(geometryIndex);
				indexed = true;
			} catch (SQLException e) {
				throw new GeoPackageException(
						"Failed to create or update Geometry Index. GeoPackage: "
								+ geoPackage.getName() + ", Table Name: "
								+ tableName + ", Geom Id: " + geomId,
						e);
			}
		}
	}

	return indexed;
}
 
Example #8
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Get or build a geometry envelope from the Geometry Data
 * 
 * @param data
 *            geometry data
 * @return geometry envelope
 */
protected GeometryEnvelope getEnvelope(GeoPackageGeometryData data) {
	GeometryEnvelope envelope = null;
	if (data != null) {
		envelope = data.getOrBuildEnvelope();
	}
	return envelope;
}
 
Example #9
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createMinXFunction() {
	createFunction(MIN_X_FUNCTION, new GeometryFunction() {
		@Override
		public Object execute(GeoPackageGeometryData data) {
			Object value = null;
			GeometryEnvelope envelope = getEnvelope(data);
			if (envelope != null) {
				value = envelope.getMinX();
			}
			return value;
		}
	});
}
 
Example #10
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createMaxXFunction() {
	createFunction(MAX_X_FUNCTION, new GeometryFunction() {
		@Override
		public Object execute(GeoPackageGeometryData data) {
			Object value = null;
			GeometryEnvelope envelope = getEnvelope(data);
			if (envelope != null) {
				value = envelope.getMaxX();
			}
			return value;
		}
	});
}
 
Example #11
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createMinYFunction() {
	createFunction(MIN_Y_FUNCTION, new GeometryFunction() {
		@Override
		public Object execute(GeoPackageGeometryData data) {
			Object value = null;
			GeometryEnvelope envelope = getEnvelope(data);
			if (envelope != null) {
				value = envelope.getMinY();
			}
			return value;
		}
	});
}
 
Example #12
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createMaxYFunction() {
	createFunction(MAX_Y_FUNCTION, new GeometryFunction() {
		@Override
		public Object execute(GeoPackageGeometryData data) {
			Object value = null;
			GeometryEnvelope envelope = getEnvelope(data);
			if (envelope != null) {
				value = envelope.getMaxY();
			}
			return value;
		}
	});
}
 
Example #13
Source File: RTreeIndexExtension.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createIsEmptyFunction() {
	createFunction(IS_EMPTY_FUNCTION, new GeometryFunction() {
		@Override
		public Object execute(GeoPackageGeometryData data) {
			return data == null || data.isEmpty()
					|| data.getGeometry() == null;
		}
	});
}
 
Example #14
Source File: FeatureRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * Handles geometry columns
 */
@Override
protected void columnToContentValue(ContentValues contentValues,
		FeatureColumn column, Object value) {

	if (column.isGeometry()) {

		String columnName = column.getName();

		if (value instanceof GeoPackageGeometryData) {
			GeoPackageGeometryData geometryData = (GeoPackageGeometryData) value;
			try {
				contentValues.put(columnName, geometryData.toBytes());
			} catch (IOException e) {
				throw new GeoPackageException(
						"Failed to write Geometry Data bytes. column: "
								+ columnName,
						e);
			}
		} else if (value instanceof byte[]) {
			contentValues.put(columnName, (byte[]) value);
		} else {
			throw new GeoPackageException(
					"Unsupported update geometry column value type. column: "
							+ columnName + ", value type: "
							+ value.getClass().getName());
		}
	} else {
		super.columnToContentValue(contentValues, column, value);
	}

}
 
Example #15
Source File: FeatureRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the simple features geometry value
 * 
 * @return geometry
 * @since 3.1.0
 */
public Geometry getGeometryValue() {
	GeoPackageGeometryData data = getGeometry();
	Geometry geometry = null;
	if (data != null) {
		geometry = data.getGeometry();
	}
	return geometry;
}
 
Example #16
Source File: FeatureRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Get the geometry envelope
 * 
 * @return geometry envelope
 * @since 3.1.0
 */
public GeometryEnvelope getGeometryEnvelope() {
	GeoPackageGeometryData data = getGeometry();
	GeometryEnvelope envelope = null;
	if (data != null) {
		envelope = data.getOrBuildEnvelope();
	}
	return envelope;
}
 
Example #17
Source File: TransactionTest.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Insert a row into the feature table
 *
 * @param featureDao
 *            feature dao
 */
private void insertRow(FeatureDao featureDao) {

	FeatureRow row = featureDao.newRow();
	GeoPackageGeometryData geometry = new GeoPackageGeometryData(featureDao
			.getGeometryColumns().getSrsId());
	geometry.setGeometry(new Point(0, 0));
	row.setGeometry(geometry);
	featureDao.insert(row);

}
 
Example #18
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static void setPoint(FeatureRow featureRow, double x, double y) {
	GeoPackageGeometryData geomData = new GeoPackageGeometryData(
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
	Point point = new Point(false, false, x, y);
	geomData.setGeometry(point);
	featureRow.setGeometry(geomData);
}
 
Example #19
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static long insertLine(FeatureDao featureDao, double[][] points) {
	FeatureRow featureRow = featureDao.newRow();
	GeoPackageGeometryData geomData = new GeoPackageGeometryData(
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
	LineString lineString = getLineString(points);
	geomData.setGeometry(lineString);
	featureRow.setGeometry(geomData);
	return featureDao.insert(featureRow);
}
 
Example #20
Source File: FeatureTileUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
public static long insertPolygon(FeatureDao featureDao,
		double[][]... points) {
	FeatureRow featureRow = featureDao.newRow();
	GeoPackageGeometryData geomData = new GeoPackageGeometryData(
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
	Polygon polygon = new Polygon(false, false);
	for (double[][] ring : points) {
		LineString lineString = getLineString(ring);
		polygon.addRing(lineString);
	}
	geomData.setGeometry(polygon);
	featureRow.setGeometry(geomData);
	return featureDao.insert(featureRow);
}
 
Example #21
Source File: FeatureIndexer.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Index the feature row
 *
 * @param geoPackageId   GeoPackage id
 * @param row            feature row
 * @param possibleUpdate possible update flag
 * @return true if indexed
 */
private boolean index(long geoPackageId, FeatureRow row, boolean possibleUpdate) {

    boolean indexed = false;

    GeoPackageGeometryData geomData = row.getGeometry();
    if (geomData != null) {

        // Get the envelope
        GeometryEnvelope envelope = geomData.getEnvelope();

        // If no envelope, build one from the geometry
        if (envelope == null) {
            Geometry geometry = geomData.getGeometry();
            if (geometry != null) {
                envelope = GeometryEnvelopeBuilder.buildEnvelope(geometry);
            }
        }

        // Create the new index row
        if (envelope != null) {
            GeometryMetadata metadata = geometryMetadataDataSource.populate(geoPackageId, featureDao.getTableName(), row.getId(), envelope);
            if (possibleUpdate) {
                geometryMetadataDataSource.createOrUpdate(metadata);
            } else {
                geometryMetadataDataSource.create(metadata);
            }
            indexed = true;
        }
    }

    return indexed;
}
 
Example #22
Source File: FeatureInfoBuilder.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Project the geometry into the provided projection
 *
 * @param geometryData geometry data
 * @param projection   projection
 */
public void projectGeometry(GeoPackageGeometryData geometryData, Projection projection) {

    if (geometryData.getGeometry() != null) {

        try {
            SpatialReferenceSystemDao srsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), SpatialReferenceSystem.class);
            int srsId = geometryData.getSrsId();
            SpatialReferenceSystem srs = srsDao.queryForId((long) srsId);

            if (!projection.equals(srs.getOrganization(), srs.getOrganizationCoordsysId())) {

                Projection geomProjection = srs.getProjection();
                ProjectionTransform transform = geomProjection.getTransformation(projection);

                Geometry projectedGeometry = transform.transform(geometryData.getGeometry());
                geometryData.setGeometry(projectedGeometry);
                SpatialReferenceSystem projectionSrs = srsDao.getOrCreateCode(projection.getAuthority(), Long.parseLong(projection.getCode()));
                geometryData.setSrsId((int) projectionSrs.getSrsId());
            }
        } catch (SQLException e) {
            throw new GeoPackageException("Failed to project geometry to projection with Authority: "
                    + projection.getAuthority() + ", Code: " + projection.getCode(), e);
        }
    }

}
 
Example #23
Source File: FeatureRow.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * Handles geometry columns
 */
@Override
protected void columnToContentValue(ContentValues contentValues,
                                    FeatureColumn column, Object value) {

    if (column.isGeometry()) {

        String columnName = column.getName();

        if (value instanceof GeoPackageGeometryData) {
            GeoPackageGeometryData geometryData = (GeoPackageGeometryData) value;
            try {
                contentValues.put(columnName, geometryData.toBytes());
            } catch (IOException e) {
                throw new GeoPackageException(
                        "Failed to write Geometry Data bytes. column: "
                                + columnName,
                        e);
            }
        } else if (value instanceof byte[]) {
            contentValues.put(columnName, (byte[]) value);
        } else {
            throw new GeoPackageException(
                    "Unsupported update geometry column value type. column: "
                            + columnName + ", value type: "
                            + value.getClass().getName());
        }
    } else {
        super.columnToContentValue(contentValues, column, value);
    }

}
 
Example #24
Source File: FeatureRow.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the simple features geometry value
 *
 * @return geometry
 * @since 3.1.0
 */
public Geometry getGeometryValue() {
    GeoPackageGeometryData data = getGeometry();
    Geometry geometry = null;
    if (data != null) {
        geometry = data.getGeometry();
    }
    return geometry;
}
 
Example #25
Source File: FeatureRow.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Get the geometry envelope
 *
 * @return geometry envelope
 * @since 3.1.0
 */
public GeometryEnvelope getGeometryEnvelope() {
    GeoPackageGeometryData data = getGeometry();
    GeometryEnvelope envelope = null;
    if (data != null) {
        envelope = data.getOrBuildEnvelope();
    }
    return envelope;
}
 
Example #26
Source File: TransactionTest.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Insert a row into the feature table
 *
 * @param featureDao feature dao
 */
private void insertRow(FeatureDao featureDao) {

    FeatureRow row = featureDao.newRow();
    GeoPackageGeometryData geometry = new GeoPackageGeometryData(
            featureDao.getGeometryColumns().getSrsId());
    geometry.setGeometry(new Point(0, 0));
    row.setGeometry(geometry);
    featureDao.insert(row);

}
 
Example #27
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
public static void setPoint(FeatureRow featureRow, double x, double y) {
    GeoPackageGeometryData geomData = new GeoPackageGeometryData(
            ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
    Point point = new Point(false, false, x, y);
    geomData.setGeometry(point);
    featureRow.setGeometry(geomData);
}
 
Example #28
Source File: FeatureTileUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
public static long insertLine(FeatureDao featureDao, double[][] points) {
    FeatureRow featureRow = featureDao.newRow();
    GeoPackageGeometryData geomData = new GeoPackageGeometryData(
            ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
    LineString lineString = getLineString(points);
    geomData.setGeometry(lineString);
    featureRow.setGeometry(geomData);
    return featureDao.insert(featureRow);
}
 
Example #29
Source File: GeoPackageGeometryDataUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test transforming geometries between projections
 *
 * @param geoPackage
 * @throws SQLException
 * @throws IOException
 */
public static void testGeometryProjectionTransform(GeoPackage geoPackage)
        throws SQLException, IOException {

    GeometryColumnsDao geometryColumnsDao = geoPackage
            .getGeometryColumnsDao();

    if (geometryColumnsDao.isTableExists()) {
        List<GeometryColumns> results = geometryColumnsDao.queryForAll();

        for (GeometryColumns geometryColumns : results) {

            FeatureDao dao = geoPackage.getFeatureDao(geometryColumns);
            TestCase.assertNotNull(dao);

            FeatureCursor cursor = dao.queryForAll();

            while (cursor.moveToNext()) {

                GeoPackageGeometryData geometryData = cursor.getGeometry();
                if (geometryData != null) {

                    Geometry geometry = geometryData.getGeometry();

                    if (geometry != null) {

                        SpatialReferenceSystemDao srsDao = geoPackage
                                .getSpatialReferenceSystemDao();
                        long srsId = geometryData.getSrsId();
                        SpatialReferenceSystem srs = srsDao
                                .queryForId(srsId);

                        long epsg = srs.getOrganizationCoordsysId();
                        Projection projection = srs.getProjection();
                        long toEpsg = -1;
                        if (epsg == ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) {
                            toEpsg = ProjectionConstants.EPSG_WEB_MERCATOR;
                        } else {
                            toEpsg = ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM;
                        }
                        ProjectionTransform transformTo = projection
                                .getTransformation(toEpsg);
                        ProjectionTransform transformFrom = srs.getTransformation(transformTo
                                .getToProjection());

                        byte[] bytes = geometryData.getWkbBytes();

                        Geometry projectedGeometry = transformTo
                                .transform(geometry);
                        GeoPackageGeometryData projectedGeometryData = new GeoPackageGeometryData(
                                -1);
                        projectedGeometryData
                                .setGeometry(projectedGeometry);
                        projectedGeometryData.toBytes();
                        byte[] projectedBytes = projectedGeometryData
                                .getWkbBytes();

                        if (epsg > 0) {
                            TestCase.assertFalse(equalByteArrays(bytes,
                                    projectedBytes));
                        }

                        Geometry restoredGeometry = transformFrom
                                .transform(projectedGeometry);

                        compareGeometries(geometry, restoredGeometry, .001);
                    }
                }

            }
            cursor.close();
        }
    }
}
 
Example #30
Source File: FeatureUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * 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);
}