MosaicFormatterMapper extends Mapper<NullWritable, NullWritable, NullWritable, NullWritable> { static Geometry getPartGeometry(int partitionNumber, int numPartitions) { double x1 = -180.0; double x2 = 180.0; double degreePerPartition = 180.0 / numPartitions; double y1 = 90.0 - partitionNumber * degreePerPartition; double y2 = 90.0 - (partitionNumber + 1) * degreePerPartition; return new GeometryFactory().toGeometry(new Envelope(x1, x2, y1, y2)); }  @Override void run(Context context);  }
@Test public void testGetPartGeometry() throws Exception { Geometry partGeometry = MosaicFormatterMapper.getPartGeometry(0, 18); assertNotNull(partGeometry); assertTrue(partGeometry.isRectangle()); Envelope envelope = partGeometry.getEnvelopeInternal(); assertEquals("minX", -180.0, envelope.getMinX(), 1e-5); assertEquals("maxX", +180.0, envelope.getMaxX(), 1e-5); assertEquals("minY", 80.0, envelope.getMinY(), 1e-5); assertEquals("maxY", 90.0, envelope.getMaxY(), 1e-5); partGeometry = MosaicFormatterMapper.getPartGeometry(9, 18); assertNotNull(partGeometry); assertTrue(partGeometry.isRectangle()); envelope = partGeometry.getEnvelopeInternal(); assertEquals("minX", -180.0, envelope.getMinX(), 1e-5); assertEquals("maxX", +180.0, envelope.getMaxX(), 1e-5); assertEquals("minY", -10.0, envelope.getMinY(), 1e-5); assertEquals("maxY", 0.0, envelope.getMaxY(), 1e-5); partGeometry = MosaicFormatterMapper.getPartGeometry(17, 18); assertNotNull(partGeometry); assertTrue(partGeometry.isRectangle()); envelope = partGeometry.getEnvelopeInternal(); assertEquals("minX", -180.0, envelope.getMinX(), 1e-5); assertEquals("maxX", +180.0, envelope.getMaxX(), 1e-5); assertEquals("minY", -90.0, envelope.getMinY(), 1e-5); assertEquals("maxY", -80.0, envelope.getMaxY(), 1e-5); }