Skip to content

Commit

Permalink
Merge pull request #1231 from dvntucker/granule_collector_test_fix
Browse files Browse the repository at this point in the history
Change test data for granule collector to not need axis order
  • Loading branch information
Simone Giannecchini committed Jul 1, 2016
2 parents 5a6e0a8 + 788b2c1 commit fc52b08
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 38 deletions.
Expand Up @@ -17,27 +17,66 @@

package org.geotools.gce.imagemosaic;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.geotools.data.Query;
import org.geotools.factory.Hints;
import org.geotools.filter.text.cql2.CQL;
import org.geotools.filter.text.cql2.CQLException;
import org.geotools.gce.imagemosaic.acceptors.ColorCheckAcceptor;
import org.geotools.gce.imagemosaic.acceptors.DefaultGranuleAcceptorFactory;
import org.geotools.gce.imagemosaic.acceptors.GranuleAcceptor;
import org.geotools.gce.imagemosaic.acceptors.GranuleAcceptorFactorySPI;
import org.geotools.gce.imagemosaic.acceptors.GranuleAcceptorFactorySPIFinder;
import org.geotools.gce.imagemosaic.acceptors.HeterogeneousCRSAcceptorFactory;
import org.geotools.gce.imagemosaic.acceptors.HomogeneousCRSAcceptor;
import org.geotools.gce.imagemosaic.catalog.GranuleCatalog;
import org.geotools.test.TestData;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

import org.junit.rules.TemporaryFolder;

/**
* Testing that granule collectors correctly get configured and initialized
*/
public class GranuleCollectorSPITest {

@Rule
public TemporaryFolder testFolder = new TemporaryFolder();

@Rule
public TemporaryFolder crsMosaicFolder = new TemporaryFolder();

@Test
public void testCustomizedGranuleAcceptor() throws IOException, URISyntaxException,
CQLException {
URL testDataURL = TestData.url(this, "diffprojections");
File testDataFolder = new File(testDataURL.toURI());
File testDirectory = testFolder.newFolder("diffprojectionstest");
FileUtils.copyDirectory(testDataFolder, testDirectory);
Hints creationHints = new Hints();
ImageMosaicReader imReader = new ImageMosaicReader(testDirectory, creationHints);
assertNotNull(imReader);
assertEquals(imReader.getGranules(
imReader.getGridCoverageNames()[0], true).getCount(null),
2);

GranuleCatalog gc = imReader.getRasterManager("diffprojectionstest").getGranuleCatalog();
assertNotNull(gc);
Query q = new Query(gc.getTypeNames()[0], CQL.toFilter("BBOX(the_geom, -11575371.717655, 5522913.211892, -11521556.424943, 5561374.032840)"));
assertEquals(2, gc.getGranules(q).size());
}

@Test
public void basicTest(){
// get the SPIs
Expand Down
Expand Up @@ -17,15 +17,8 @@
package org.geotools.gce.imagemosaic;

import static org.hamcrest.CoreMatchers.instanceOf;
import it.geosolutions.imageio.pam.PAMDataset;
import it.geosolutions.imageio.pam.PAMDataset.PAMRasterBand;
import it.geosolutions.imageio.pam.PAMParser;
import it.geosolutions.imageio.utilities.ImageIOUtilities;
import it.geosolutions.jaiext.JAIExt;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
Expand All @@ -45,7 +38,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.Connection;
import java.sql.Statement;
Expand All @@ -66,10 +58,7 @@
import java.util.logging.Logger;

import javax.media.jai.RenderedOp;
import javax.swing.JFrame;

import junit.framework.JUnit4TestAdapter;
import junit.textui.TestRunner;
import javax.swing.*;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
Expand Down Expand Up @@ -102,8 +91,6 @@
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.factory.Hints;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.filter.text.cql2.CQL;
import org.geotools.filter.text.cql2.CQLException;
import org.geotools.filter.text.ecql.ECQL;
import org.geotools.gce.imagemosaic.Utils.Prop;
import org.geotools.gce.imagemosaic.catalog.GranuleCatalog;
Expand Down Expand Up @@ -150,6 +137,14 @@
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LinearRing;

import it.geosolutions.imageio.pam.PAMDataset;
import it.geosolutions.imageio.pam.PAMDataset.PAMRasterBand;
import it.geosolutions.imageio.pam.PAMParser;
import it.geosolutions.imageio.utilities.ImageIOUtilities;
import it.geosolutions.jaiext.JAIExt;
import junit.framework.JUnit4TestAdapter;
import junit.textui.TestRunner;

/**
* Testing {@link ImageMosaicReader}.
*
Expand Down Expand Up @@ -4215,26 +4210,4 @@ public void testOverviewSupportFiles() throws Exception {
}
}

@Test
public void testCustomizedGranuleAcceptor() throws IOException, URISyntaxException,
CQLException {
URL testDataURL = TestData.url(this, "diffprojections");
File testDataFolder = new File(testDataURL.toURI());

Hints creationHints = new Hints();
ImageMosaicReader imReader = new ImageMosaicReader(testDataFolder, creationHints);
assertNotNull(imReader);
String[] gridCoverageNames = imReader.getGridCoverageNames();
assertNotNull(gridCoverageNames);
Assert.assertTrue(gridCoverageNames.length==1);
String coverageName = gridCoverageNames[0];
assertEquals(imReader.getGranules(
coverageName, true).getCount(null),
2);

GranuleCatalog gc = imReader.getRasterManager(coverageName).getGranuleCatalog();
assertNotNull(gc);
Query q = new Query(gc.getTypeNames()[0], CQL.toFilter("BBOX(the_geom, -180, -90, 180, 90)"));
assertEquals(2, gc.getGranules(q).size());
}
}
Binary file not shown.
Binary file not shown.

0 comments on commit fc52b08

Please sign in to comment.