Java Code Examples for mil.nga.sf.GeometryEnvelope#hasZ()
The following examples show how to use
mil.nga.sf.GeometryEnvelope#hasZ() .
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: GeometryMetadataDataSource.java From geopackage-android with MIT License | 6 votes |
/** * Populate a new geometry metadata from an envelope * * @param geoPackageId GeoPackage id * @param tableName table name * @param geomId geometry id * @param envelope geometry envelope * @return geometry metadata */ public GeometryMetadata populate(long geoPackageId, String tableName, long geomId, GeometryEnvelope envelope) { GeometryMetadata metadata = new GeometryMetadata(); metadata.setGeoPackageId(geoPackageId); metadata.setTableName(tableName); metadata.setId(geomId); metadata.setMinX(envelope.getMinX()); metadata.setMaxX(envelope.getMaxX()); metadata.setMinY(envelope.getMinY()); metadata.setMaxY(envelope.getMaxY()); if (envelope.hasZ()) { metadata.setMinZ(envelope.getMinZ()); metadata.setMaxZ(envelope.getMaxZ()); } if (envelope.hasM()) { metadata.setMinM(envelope.getMinM()); metadata.setMaxM(envelope.getMaxM()); } return metadata; }
Example 2
Source File: GeometryMetadataDataSource.java From geopackage-android with MIT License | 6 votes |
/** * Get the query SQL for an envelope, GeoPackage id, and table name * * @param envelope geometry envelope * @return SQL * @since 3.4.0 */ public String querySQL(GeometryEnvelope envelope) { StringBuilder selection = new StringBuilder(); selection.append(GeometryMetadata.COLUMN_GEOPACKAGE_ID).append(" = ? AND ") .append(GeometryMetadata.COLUMN_TABLE_NAME).append(" = ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MIN_X).append(" <= ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MAX_X).append(" >= ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MIN_Y).append(" <= ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MAX_Y).append(" >= ?"); if (envelope.hasZ()) { selection.append(" AND ").append(GeometryMetadata.COLUMN_MIN_Z).append(" <= ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MAX_Z).append(" >= ?"); } if (envelope.hasM()) { selection.append(" AND ").append(GeometryMetadata.COLUMN_MIN_M).append(" <= ?"); selection.append(" AND ").append(GeometryMetadata.COLUMN_MAX_M).append(" >= ?"); } return selection.toString(); }
Example 3
Source File: GeometryIndexDao.java From geopackage-core-java with MIT License | 6 votes |
/** * Populate a new geometry index from an envelope * * @param tableIndex * table index * @param geomId * geometry id * @param envelope * geometry envelope * @return geometry index */ public GeometryIndex populate(TableIndex tableIndex, long geomId, GeometryEnvelope envelope) { GeometryIndex geometryIndex = new GeometryIndex(); geometryIndex.setTableIndex(tableIndex); geometryIndex.setGeomId(geomId); geometryIndex.setMinX(envelope.getMinX()); geometryIndex.setMaxX(envelope.getMaxX()); geometryIndex.setMinY(envelope.getMinY()); geometryIndex.setMaxY(envelope.getMaxY()); if (envelope.hasZ()) { geometryIndex.setMinZ(envelope.getMinZ()); geometryIndex.setMaxZ(envelope.getMaxZ()); } if (envelope.hasM()) { geometryIndex.setMinM(envelope.getMinM()); geometryIndex.setMaxM(envelope.getMaxM()); } return geometryIndex; }
Example 4
Source File: GeometryMetadataDataSource.java From geopackage-android with MIT License | 5 votes |
/** * Get the query SQL args for an envelope, GeoPackage id, and table name * * @param envelope geometry envelope * @param geoPackageId GeoPackage id * @param tableName table name * @return SQL args * @since 3.4.0 */ public String[] querySQLArgs(GeometryEnvelope envelope, long geoPackageId, String tableName) { int args = 6; if (envelope.hasZ()) { args += 2; } if (envelope.hasM()) { args += 2; } double minX = envelope.getMinX() - tolerance; double maxX = envelope.getMaxX() + tolerance; double minY = envelope.getMinY() - tolerance; double maxY = envelope.getMaxY() + tolerance; String[] selectionArgs = new String[args]; int argCount = 0; selectionArgs[argCount++] = String.valueOf(geoPackageId); selectionArgs[argCount++] = tableName; selectionArgs[argCount++] = String.valueOf(maxX); selectionArgs[argCount++] = String.valueOf(minX); selectionArgs[argCount++] = String.valueOf(maxY); selectionArgs[argCount++] = String.valueOf(minY); if (envelope.hasZ()) { double minZ = envelope.getMinZ() - tolerance; double maxZ = envelope.getMaxZ() + tolerance; selectionArgs[argCount++] = String.valueOf(maxZ); selectionArgs[argCount++] = String.valueOf(minZ); } if (envelope.hasM()) { double minM = envelope.getMinM() - tolerance; double maxM = envelope.getMaxM() + tolerance; selectionArgs[argCount++] = String.valueOf(maxM); selectionArgs[argCount++] = String.valueOf(minM); } return selectionArgs; }
Example 5
Source File: FeatureIndexManagerUtils.java From geopackage-android with MIT License | 5 votes |
/** * Validate a Feature Row result * * @param featureIndexManager * @param featureRow * @param queryEnvelope */ private static void validateFeatureRow( FeatureIndexManager featureIndexManager, FeatureRow featureRow, GeometryEnvelope queryEnvelope, boolean includeEmpty) { TestCase.assertNotNull(featureRow); GeometryEnvelope envelope = featureRow.getGeometryEnvelope(); if (!includeEmpty) { TestCase.assertNotNull(envelope); if (queryEnvelope != null) { TestCase.assertTrue(envelope.getMinX() <= queryEnvelope .getMaxX()); TestCase.assertTrue(envelope.getMaxX() >= queryEnvelope .getMinX()); TestCase.assertTrue(envelope.getMinY() <= queryEnvelope .getMaxY()); TestCase.assertTrue(envelope.getMaxY() >= queryEnvelope .getMinY()); if (envelope.isHasZ()) { if (queryEnvelope.hasZ()) { TestCase.assertTrue(envelope.getMinZ() <= queryEnvelope .getMaxZ()); TestCase.assertTrue(envelope.getMaxZ() >= queryEnvelope .getMinZ()); } } if (envelope.isHasM()) { if (queryEnvelope.hasM()) { TestCase.assertTrue(envelope.getMinM() <= queryEnvelope .getMaxM()); TestCase.assertTrue(envelope.getMaxM() >= queryEnvelope .getMinM()); } } } } }
Example 6
Source File: GeoPackageGeometryData.java From geopackage-core-java with MIT License | 5 votes |
/** * Get the envelope flag indicator * * 1 for xy, 2 for xyz, 3 for xym, 4 for xyzm (null would be 0) * * @param envelope * geometry envelope * * @return indicator */ public static int getIndicator(GeometryEnvelope envelope) { int indicator = 1; if (envelope.hasZ()) { indicator++; } if (envelope.hasM()) { indicator += 2; } return indicator; }
Example 7
Source File: FeatureIndexManagerUtils.java From geopackage-java with MIT License | 5 votes |
/** * Validate a Feature Row result * * @param featureIndexManager * @param featureRow * @param queryEnvelope */ private static void validateFeatureRow( FeatureIndexManager featureIndexManager, FeatureRow featureRow, GeometryEnvelope queryEnvelope, boolean includeEmpty) { TestCase.assertNotNull(featureRow); GeometryEnvelope envelope = featureRow.getGeometryEnvelope(); if (!includeEmpty) { TestCase.assertNotNull(envelope); if (queryEnvelope != null) { TestCase.assertTrue( envelope.getMinX() <= queryEnvelope.getMaxX()); TestCase.assertTrue( envelope.getMaxX() >= queryEnvelope.getMinX()); TestCase.assertTrue( envelope.getMinY() <= queryEnvelope.getMaxY()); TestCase.assertTrue( envelope.getMaxY() >= queryEnvelope.getMinY()); if (envelope.isHasZ()) { if (queryEnvelope.hasZ()) { TestCase.assertTrue( envelope.getMinZ() <= queryEnvelope.getMaxZ()); TestCase.assertTrue( envelope.getMaxZ() >= queryEnvelope.getMinZ()); } } if (envelope.isHasM()) { if (queryEnvelope.hasM()) { TestCase.assertTrue( envelope.getMinM() <= queryEnvelope.getMaxM()); TestCase.assertTrue( envelope.getMaxM() >= queryEnvelope.getMinM()); } } } } }
Example 8
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 4 votes |
/** * Build a query builder to query for Geometry Index objects within the * Geometry Envelope * * @param envelope * geometry envelope * @return query builder */ public QueryBuilder<GeometryIndex, GeometryIndexKey> queryBuilder( GeometryEnvelope envelope) { QueryBuilder<GeometryIndex, GeometryIndexKey> qb = geometryIndexDao .queryBuilder(); try { double minX = envelope.getMinX() - tolerance; double maxX = envelope.getMaxX() + tolerance; double minY = envelope.getMinY() - tolerance; double maxY = envelope.getMaxY() + tolerance; Where<GeometryIndex, GeometryIndexKey> where = qb.where(); where.eq(GeometryIndex.COLUMN_TABLE_NAME, tableName).and() .le(GeometryIndex.COLUMN_MIN_X, maxX).and() .ge(GeometryIndex.COLUMN_MAX_X, minX).and() .le(GeometryIndex.COLUMN_MIN_Y, maxY).and() .ge(GeometryIndex.COLUMN_MAX_Y, minY); if (envelope.hasZ()) { double minZ = envelope.getMinZ() - tolerance; double maxZ = envelope.getMaxZ() + tolerance; where.and().le(GeometryIndex.COLUMN_MIN_Z, maxZ).and() .ge(GeometryIndex.COLUMN_MAX_Z, minZ); } if (envelope.hasM()) { double minM = envelope.getMinM() - tolerance; double maxM = envelope.getMaxM() + tolerance; where.and().le(GeometryIndex.COLUMN_MIN_M, maxM).and() .ge(GeometryIndex.COLUMN_MAX_M, minM); } } catch (SQLException e) { throw new GeoPackageException( "Failed to build query for Geometry Indices. GeoPackage: " + geoPackage.getName() + ", Table Name: " + tableName + ", Column Name: " + columnName, e); } return qb; }