### Question:
SubscenePixelLocator extends AbstractPixelLocator { static PixelLocator create(SampleSource lonSource, SampleSource latSource) { return new SubscenePixelLocator(lonSource, latSource); } private  SubscenePixelLocator(SampleSource lonSource, SampleSource latSource); @Override boolean getPixelLocation(double lon, double lat, Point2D p);  }### Answer:
@Test public void testConstructorThrowsOnDifferentWidths() { final TestSampleSource lonSource = new TestSampleSource(new double[][]{{1.0}, {2.0}}); final TestSampleSource latSource = new TestSampleSource(new double[][]{{3.0}, {4.0}, {5.0}}); try { SubscenePixelLocator.create(latSource, lonSource); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }
@Test public void testConstructorThrowsOnDifferentHeights() { final TestSampleSource lonSource = new TestSampleSource(new double[][]{{1.0, 2.0}, {2.0, 3.0}}); final TestSampleSource latSource = new TestSampleSource(new double[][]{{3.0}, {4.0}}); try { SubscenePixelLocator.create(latSource, lonSource); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }
@Test public void testGetGeoLocation_lonWrapsAt180Deg() { final double[][] lon = {{179, 181}, {179.5, 181.5}}; final double[][] lat = {{20.0, 20.0}, {21.0, 21.0}}; final TestSampleSource lonSource = new TestSampleSource(lon); final TestSampleSource latSource = new TestSampleSource(lat); final PixelLocator wrappingLocator = SubscenePixelLocator.create(lonSource, latSource); final Point2D.Double geoLocation = new Point2D.Double(); assertTrue(wrappingLocator.getGeoLocation(0.0, 0.0, geoLocation)); assertEquals(177.752504965, geoLocation.getX(), 1e-8); assertEquals(19.49082406, geoLocation.getY(), 1e-8); assertTrue(wrappingLocator.getGeoLocation(1.0, 1.0, geoLocation)); assertEquals(-179.75081572, geoLocation.getX(), 1e-8); assertEquals(20.503041839, geoLocation.getY(), 1e-8); }
@Test public void testGetGeoLocation_handlesNaNs() { final double[][] lon = {{179, 181}, {179.5, 181.5}}; final double[][] lat = {{20.0, 20.0}, {Double.NaN, 21.0}}; final TestSampleSource lonSource = new TestSampleSource(lon); final TestSampleSource latSource = new TestSampleSource(lat); final PixelLocator nanLocator = SubscenePixelLocator.create(lonSource, latSource); final Point2D.Double geoLocation = new Point2D.Double(); assertTrue(nanLocator.getGeoLocation(0.0, 0.0, geoLocation)); assertEquals(179.0, geoLocation.getX(), 1e-8); assertEquals(20.0, geoLocation.getY(), 1e-8); assertTrue(nanLocator.getGeoLocation(1.0, 1.0, geoLocation)); assertEquals(-178.5, geoLocation.getX(), 1e-8); assertEquals(21.0, geoLocation.getY(), 1e-8); }