Java Code Examples for mil.nga.sf.GeometryEnvelope#getMaxY()

The following examples show how to use mil.nga.sf.GeometryEnvelope#getMaxY() . 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 5 votes vote down vote up
/**
 * 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 2
Source File: FeatureIndexManagerUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
private static FeatureIndexTestEnvelope createEnvelope(
        GeometryEnvelope envelope, int percentage) {

    FeatureIndexTestEnvelope testEnvelope = new FeatureIndexTestEnvelope();

    double minX;
    double maxX;
    double minY;
    double maxY;

    if (percentage < 100) {

        float percentageRatio = percentage / 100.0f;

        double width = envelope.getMaxX() - envelope.getMinX();
        double height = envelope.getMaxY() - envelope.getMinY();

        minX = envelope.getMinX()
                + (Math.random() * width * (1.0 - percentageRatio));
        minY = envelope.getMinY()
                + (Math.random() * height * (1.0 - percentageRatio));

        maxX = minX + (width * percentageRatio);
        maxY = minY + (height * percentageRatio);

    } else {
        minX = envelope.getMinX();
        maxX = envelope.getMaxX();
        minY = envelope.getMinY();
        maxY = envelope.getMaxY();
    }

    testEnvelope.envelope = new GeometryEnvelope(minX, minY, maxX, maxY);
    testEnvelope.percentage = percentage;

    return testEnvelope;
}
 
Example 3
Source File: FeatureIndexManagerUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
private static FeatureIndexTestEnvelope createEnvelope(
		GeometryEnvelope envelope, int percentage) {

	FeatureIndexTestEnvelope testEnvelope = new FeatureIndexTestEnvelope();

	double minX;
	double maxX;
	double minY;
	double maxY;

	if (percentage < 100) {

		float percentageRatio = percentage / 100.0f;

		double width = envelope.getMaxX() - envelope.getMinX();
		double height = envelope.getMaxY() - envelope.getMinY();

		minX = envelope.getMinX()
				+ (Math.random() * width * (1.0 - percentageRatio));
		minY = envelope.getMinY()
				+ (Math.random() * height * (1.0 - percentageRatio));

		maxX = minX + (width * percentageRatio);
		maxY = minY + (height * percentageRatio);

	} else {
		minX = envelope.getMinX();
		maxX = envelope.getMaxX();
		minY = envelope.getMinY();
		maxY = envelope.getMaxY();
	}

	testEnvelope.envelope = new GeometryEnvelope(minX, minY, maxX, maxY);
	testEnvelope.percentage = percentage;

	return testEnvelope;
}
 
Example 4
Source File: FeatureTableCoreIndex.java    From geopackage-core-java with MIT License 4 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: BoundingBox.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Constructor
 * 
 * @param envelope
 *            geometry envelope
 * @since 2.0.0
 */
public BoundingBox(GeometryEnvelope envelope) {
	this(envelope.getMinX(), envelope.getMinY(), envelope.getMaxX(),
			envelope.getMaxY());
}