CombineUnionService implements CombineResultService { public Envelope combine(List<GetLocationResult> results) { Envelope result = null; for (GetLocationResult add : results) { Envelope envelope = add.getEnvelope(); if (null == result) { result = envelope; } else { result.expandToInclude(envelope); } } return result; }  Envelope combine(List<GetLocationResult> results);  }
@Test public void testCombine() throws Exception { Envelope e1 = new Envelope(10, 40, 10, 30); GetLocationResult glr1 = new GetLocationResult(); glr1.setEnvelope(e1); Envelope e2 = new Envelope(20, 35, 25, 50); GetLocationResult glr2 = new GetLocationResult(); glr2.setEnvelope(e2); List<GetLocationResult> list = new ArrayList<GetLocationResult>(); list.add(glr1); list.add(glr2); CombineResultService cis = new CombineUnionService(); Envelope res = cis.combine(list); Assert.assertEquals(10.0, res.getMinX(), DELTA); Assert.assertEquals(10.0, res.getMinY(), DELTA); Assert.assertEquals(40.0, res.getMaxX(), DELTA); Assert.assertEquals(50.0, res.getMaxY(), DELTA); }