Java Code Examples for mil.nga.geopackage.features.columns.GeometryColumns#setGeometryType()
The following examples show how to use
mil.nga.geopackage.features.columns.GeometryColumns#setGeometryType() .
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 | 7 votes |
/** * Create feature dao * * @return */ public static FeatureDao createFeatureDao(GeoPackage geoPackage) { BoundingBox boundingBox = new BoundingBox(); GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_tiles", "geom")); geometryColumns.setGeometryType(GeometryType.GEOMETRY); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns); return featureDao; }
Example 2
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadata(GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, null); }
Example 3
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata and id column * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumn( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata2", "geom2")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, null); }
Example 4
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata and additional columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata3", "geom3")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, additionalColumns); }
Example 5
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata, id column, and additional * columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumnAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata4", "geom4")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_other_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, additionalColumns); }
Example 6
Source File: GeoPackageRepository.java From geopackage-mapcache-android with MIT License | 6 votes |
/** * Create feature table in the given geopackage */ public boolean createFeatureTable(String gpName, BoundingBox boundingBox, GeometryType geometryType, String tableName){ GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(tableName, "geom")); geometryColumns.setGeometryType(geometryType); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); GeoPackage geoPackage = manager.open(gpName); try { GeometryColumns created = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); if(created != null) { return true; } } finally { geoPackage.close(); } return false; }
Example 7
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 6 votes |
/** * Create feature dao * * @return feature dao */ public static FeatureDao createFeatureDao(GeoPackage geoPackage) { BoundingBox boundingBox = new BoundingBox(); GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(TABLE_NAME, "geom")); geometryColumns.setGeometryType(GeometryType.GEOMETRY); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); geoPackage.createFeatureTableWithMetadata(geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns); return featureDao; }
Example 8
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadata(GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, null); }
Example 9
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata and id column * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumn( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata2", "geom2")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, null); }
Example 10
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata and additional columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, additionalColumns); }
Example 11
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata, id column, and additional * columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumnAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_other_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, additionalColumns); }
Example 12
Source File: FeatureIndexManagerUtils.java From geopackage-android with MIT License | 5 votes |
/** * Test large index * * @param activity activity * @param geoPackage GeoPackage * @param numFeatures num features * @param verbose verbose printing * @throws SQLException upon error */ public static void testLargeIndex(Activity activity, GeoPackage geoPackage, int numFeatures, boolean verbose) throws SQLException { String featureTable = "large_index"; GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(featureTable, "geom")); geometryColumns.setGeometryType(GeometryType.POLYGON); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-180, -90, 180, 90); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); List<FeatureColumn> additionalColumns = GeoPackageTestUtils .getFeatureColumns(); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, additionalColumns, boundingBox, srs.getId()); FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns); System.out.println(); System.out.println("Inserting Feature Rows: " + numFeatures); TestUtils.addRowsToFeatureTable(geoPackage, geometryColumns, featureDao.getTable(), numFeatures, false, false, false); testTimedIndex(activity, geoPackage, featureTable, true, verbose); }
Example 13
Source File: FeatureIndexManagerUtils.java From geopackage-java with MIT License | 5 votes |
/** * Test large index * * @param geoPackage * GeoPackage * @param numFeatures * num features * @param verbose * verbose printing * @throws SQLException * upon error */ public static void testLargeIndex(GeoPackage geoPackage, int numFeatures, boolean verbose) throws SQLException { String featureTable = "large_index"; GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(featureTable, "geom")); geometryColumns.setGeometryType(GeometryType.POLYGON); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-180, -90, 180, 90); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); List<FeatureColumn> additionalColumns = GeoPackageTestUtils .getFeatureColumns(); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, additionalColumns, boundingBox, srs.getId()); FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns); System.out.println(); System.out.println("Inserting Feature Rows: " + numFeatures); TestUtils.addRowsToFeatureTable(geoPackage, geometryColumns, featureDao.getTable(), numFeatures, false, false, false); testTimedIndex(geoPackage, featureTable, true, verbose); }
Example 14
Source File: GeometryColumnsUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); GeometryColumnsDao dao = geoPackage.getGeometryColumnsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); TestCase.assertEquals(count, dao.getFeatureTables().size()); // Retrieve a random srs List<SpatialReferenceSystem> results = srsDao.queryForAll(); SpatialReferenceSystem srs = null; if (!results.isEmpty()) { int random = (int) (Math.random() * results.size()); srs = results.get(random); } // Create a new contents Contents contents = new Contents(); contents.setTableName("test_contents"); contents.setDataType(ContentsDataType.FEATURES); contents.setIdentifier("test_contents"); contents.setDescription(""); // contents.setLastChange(new Date()); contents.setMinX(-180.0); contents.setMinY(-90.0); contents.setMaxX(180.0); contents.setMaxY(90.0); contents.setSrs(srs); // Create the feature table geoPackage.createFeatureTable(TestUtils.buildFeatureTable( contents.getTableName(), "geom", GeometryType.GEOMETRY)); contentsDao.create(contents); String columnName = "TEST_COLUMN_NAME"; GeometryType geometryType = GeometryType.POINT; byte z = 2; byte m = 2; // Create new geometry columns GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setContents(contents); geometryColumns.setColumnName(columnName); geometryColumns.setGeometryType(geometryType); geometryColumns.setSrs(contents.getSrs()); geometryColumns.setZ(z); geometryColumns.setM(m); dao.create(geometryColumns); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); TestCase.assertEquals(newCount, dao.getFeatureTables().size()); TestCase.assertTrue(dao.getFeatureTables().contains( contents.getTableName())); // Verify saved geometry columns GeometryColumns queryGeometryColumns = dao .queryForId(geometryColumns.getId()); TestCase.assertEquals(contents.getId(), queryGeometryColumns.getTableName()); TestCase.assertEquals(columnName, queryGeometryColumns.getColumnName()); TestCase.assertEquals(geometryType, queryGeometryColumns.getGeometryType()); TestCase.assertEquals(contents.getSrsId().longValue(), queryGeometryColumns.getSrsId()); TestCase.assertEquals(z, queryGeometryColumns.getZ()); TestCase.assertEquals(m, queryGeometryColumns.getM()); TestCase.assertEquals(contents.getId(), queryGeometryColumns .getContents().getId()); TestCase.assertEquals(contents.getSrsId().longValue(), queryGeometryColumns.getSrs().getId()); } }
Example 15
Source File: GeometryColumnsUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); ContentsDao contentsDao = geoPackage.getContentsDao(); GeometryColumnsDao dao = geoPackage.getGeometryColumnsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); TestCase.assertEquals(count, dao.getFeatureTables().size()); // Retrieve a random srs List<SpatialReferenceSystem> results = srsDao.queryForAll(); SpatialReferenceSystem srs = null; if (!results.isEmpty()) { int random = (int) (Math.random() * results.size()); srs = results.get(random); } // Create a new contents Contents contents = new Contents(); contents.setTableName("test_contents"); contents.setDataType(ContentsDataType.FEATURES); contents.setIdentifier("test_contents"); contents.setDescription(""); // contents.setLastChange(new Date()); contents.setMinX(-180.0); contents.setMinY(-90.0); contents.setMaxX(180.0); contents.setMaxY(90.0); contents.setSrs(srs); // Create the feature table geoPackage.createFeatureTable(TestUtils.buildFeatureTable( contents.getTableName(), "geom", GeometryType.GEOMETRY)); contentsDao.create(contents); String columnName = "TEST_COLUMN_NAME"; GeometryType geometryType = GeometryType.POINT; byte z = 2; byte m = 2; // Create new geometry columns GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setContents(contents); geometryColumns.setColumnName(columnName); geometryColumns.setGeometryType(geometryType); geometryColumns.setSrs(contents.getSrs()); geometryColumns.setZ(z); geometryColumns.setM(m); dao.create(geometryColumns); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); TestCase.assertEquals(newCount, dao.getFeatureTables().size()); TestCase.assertTrue(dao.getFeatureTables().contains( contents.getTableName())); // Verify saved geometry columns GeometryColumns queryGeometryColumns = dao .queryForId(geometryColumns.getId()); TestCase.assertEquals(contents.getId(), queryGeometryColumns.getTableName()); TestCase.assertEquals(columnName, queryGeometryColumns.getColumnName()); TestCase.assertEquals(geometryType, queryGeometryColumns.getGeometryType()); TestCase.assertEquals(contents.getSrsId().longValue(), queryGeometryColumns.getSrsId()); TestCase.assertEquals(z, queryGeometryColumns.getZ()); TestCase.assertEquals(m, queryGeometryColumns.getM()); TestCase.assertEquals(contents.getId(), queryGeometryColumns .getContents().getId()); TestCase.assertEquals(contents.getSrsId().longValue(), queryGeometryColumns.getSrs().getId()); } }