Skip to content

Commit

Permalink
Merge pull request #1111 from ngageoint/reader-rewrite
Browse files Browse the repository at this point in the history
rewrote GeoWaveRasterReaderState
  • Loading branch information
mawhitby committed Jun 2, 2017
2 parents 8ee0a6d + bc1e897 commit 73ae05a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ private GridCoverage2D loadTiles(
// envelope with the bounds of the data set. If not, give warning
//
// /////////////////////////////////////////////////////////////////////
if (!state.getRequestEnvelopeTransformed().intersects(
if (!state.getRequestEnvelopeXformed().intersects(
originalEnvelope,
true)) {
LOGGER.warn("The requested envelope does not intersect the envelope of this mosaic");
LOGGER.warn(state.getRequestEnvelopeTransformed().toString());
LOGGER.warn(state.getRequestEnvelopeXformed().toString());
LOGGER.warn(originalEnvelope.toString());

return null;
Expand Down Expand Up @@ -607,7 +607,7 @@ private GridCoverage2D loadTiles(
state.getCoverageName(),
OverviewPolicy.getDefaultPolicy(),
readP,
state.getRequestEnvelopeTransformed(),
state.getRequestEnvelopeXformed(),
pixelDimension);

}
Expand Down Expand Up @@ -665,7 +665,7 @@ private GridCoverage2D loadTiles(

try (final CloseableIterator<GridCoverage> gridCoverageIt = queryForTiles(
pixelDimension,
state.getRequestEnvelopeTransformed(),
state.getRequestEnvelopeXformed(),
resolutionLevels[imageChoice.intValue()][0],
resolutionLevels[imageChoice.intValue()][1],
adapter)) {
Expand All @@ -683,11 +683,11 @@ else if (interpolation == null) {
backgroundColor,
outputTransparentColor,
pixelDimension,
state.getRequestEnvelopeTransformed(),
state.getRequestEnvelopeXformed(),
resolutionLevels[imageChoice.intValue()][0],
resolutionLevels[imageChoice.intValue()][1],
adapter.getNoDataValuesPerBand(),
state.isXAxisSwitch(),
state.isAxisSwapped(),
coverageFactory,
state.getCoverageName(),
interpolation,
Expand Down Expand Up @@ -850,7 +850,7 @@ private GridCoverage2D transformResult(
final GridCoverage2D coverage,
final Rectangle pixelDimension,
final GeoWaveRasterReaderState state ) {
if (state.getRequestEnvelopeTransformed() == state.getRequestedEnvelope()) {
if (state.getRequestEnvelopeXformed() == state.getRequestedEnvelope()) {
return coverage; // nothing to do
}

Expand Down Expand Up @@ -881,7 +881,7 @@ public static void transformRequestEnvelope(
if (CRS.equalsIgnoreMetadata(
state.getRequestedEnvelope().getCoordinateReferenceSystem(),
crs)) {
state.setRequestEnvelopeTransformed(state.getRequestedEnvelope());
state.setRequestEnvelopeXformed(state.getRequestedEnvelope());

return; // and finish
}
Expand All @@ -895,14 +895,14 @@ public static void transformRequestEnvelope(
crs).getMathTransform();

if (transform.isIdentity()) { // Identity Transform ?
state.setRequestEnvelopeTransformed(state.getRequestedEnvelope());
state.setRequestEnvelopeXformed(state.getRequestedEnvelope());
return; // and finish
}

state.setRequestEnvelopeTransformed(CRS.transform(
state.setRequestEnvelopeXformed(CRS.transform(
transform,
state.getRequestedEnvelope()));
state.getRequestEnvelopeTransformed().setCoordinateReferenceSystem(
state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
crs);

// if (config.getIgnoreAxisOrder() == false) { // check for axis
Expand All @@ -915,19 +915,19 @@ public static void transformRequestEnvelope(

// x Axis problem ???
if ((indexX == indexRequestedY) && (indexY == indexRequestedX)) {
state.setXAxisSwitch(true);
state.setAxisSwap(true);
final Rectangle2D tmp = new Rectangle2D.Double(
state.getRequestEnvelopeTransformed().getMinimum(
state.getRequestEnvelopeXformed().getMinimum(
1),
state.getRequestEnvelopeTransformed().getMinimum(
state.getRequestEnvelopeXformed().getMinimum(
0),
state.getRequestEnvelopeTransformed().getSpan(
state.getRequestEnvelopeXformed().getSpan(
1),
state.getRequestEnvelopeTransformed().getSpan(
state.getRequestEnvelopeXformed().getSpan(
0));
state.setRequestEnvelopeTransformed(new GeneralEnvelope(
state.setRequestEnvelopeXformed(new GeneralEnvelope(
tmp));
state.getRequestEnvelopeTransformed().setCoordinateReferenceSystem(
state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
crs);
}
else if ((indexX == indexRequestedX) && (indexY == indexRequestedY)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,86 @@
/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/

/*******************************************************************************
* Copyright (c) 2013-2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License,
* Version 2.0 which accompanies this distribution and is available at
* http://www.apache.org/licenses/LICENSE-2.0.txt
******************************************************************************/
package mil.nga.giat.geowave.adapter.raster.plugin;

import org.geotools.geometry.GeneralEnvelope;

/**
* Holds the state of the reader making it thread safe
* This class allows us to make the GeoWaveRasterReader thread safe by storing
* its state here
*/

public class GeoWaveRasterReaderState
{
private boolean xAxisSwitch = false;
private final String coverageName;
private boolean axisSwap = false;
private GeneralEnvelope requestedEnvelope = null;
private GeneralEnvelope requestEnvelopeTransformed = null;
private GeneralEnvelope requestEnvelopeXformed;

public GeoWaveRasterReaderState(
final String coverageName ) {
this.coverageName = coverageName;
}

/**
* @return the coverageName
*/
public String getCoverageName() {
return coverageName;
}

public GeneralEnvelope getRequestedEnvelope() {
return requestedEnvelope;
/**
* @return the boolean value of axisSwap
*/
public boolean isAxisSwapped() {
return axisSwap;
}

public void setRequestedEnvelope(
final GeneralEnvelope requestedEnvelope ) {
this.requestedEnvelope = requestedEnvelope;
/**
* @param axisSwap
* the boolean value to set
*/
public void setAxisSwap(
boolean axisSwap ) {
this.axisSwap = axisSwap;
}

public GeneralEnvelope getRequestEnvelopeTransformed() {
return requestEnvelopeTransformed;
/**
* @return the requestedEnvelope
*/
public GeneralEnvelope getRequestedEnvelope() {
return requestedEnvelope;
}

public void setRequestEnvelopeTransformed(
final GeneralEnvelope requestEnvelopeTransformed ) {
this.requestEnvelopeTransformed = requestEnvelopeTransformed;
/**
* @param requestedEnvelope
* the requestedEnvelope to set
*/
public void setRequestedEnvelope(
GeneralEnvelope requestedEnvelope ) {
this.requestedEnvelope = requestedEnvelope;
}

public boolean isXAxisSwitch() {
return xAxisSwitch;
/**
* @return the requestEnvelopeXformed
*/
public GeneralEnvelope getRequestEnvelopeXformed() {
return requestEnvelopeXformed;
}

public void setXAxisSwitch(
final boolean axisSwitch ) {
xAxisSwitch = axisSwitch;
/**
* @param requestEnvelopeXformed
* the requestEnvelopeXformed to set
*/
public void setRequestEnvelopeXformed(
GeneralEnvelope requestEnvelopeXformed ) {
this.requestEnvelopeXformed = requestEnvelopeXformed;
}

}

0 comments on commit 73ae05a

Please sign in to comment.