@Test public void testSearchTransform() throws Exception { SearchFeatureRequest request = new SearchFeatureRequest(); request.setLayerId(LAYER_ID); request.setCrs("EPSG:4326"); request.setMax(3); SearchCriterion searchCriterion = new SearchCriterion(); searchCriterion.setAttributeName(NAME_ATTRIBUTE); searchCriterion.setOperator("like"); searchCriterion.setValue("'%3'"); request.setCriteria(new SearchCriterion[] {searchCriterion}); SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute( SearchFeatureRequest.COMMAND, request, null, "en"); Assert.assertFalse(response.isError()); Assert.assertEquals(LAYER_ID, response.getLayerId()); Feature[] features = response.getFeatures(); Assert.assertNotNull(features); Assert.assertEquals(1, features.length); Assert.assertEquals("Country 3", features[0].getLabel()); Geometry geometry = features[0].getGeometry(); Assert.assertNotNull(geometry); Coordinate coor = geometry.getGeometries()[0].getGeometries()[0].getCoordinates()[0]; Assert.assertEquals(-1, coor.getX(), DOUBLE_TOLERANCE); Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE); request.setCrs("EPSG:900913"); response = (SearchFeatureResponse) dispatcher.execute(SearchFeatureRequest.COMMAND, request, null, "en"); if (response.isError()) { response.getErrors().get(0).printStackTrace(); } Assert.assertFalse(response.isError()); Assert.assertEquals(LAYER_ID, response.getLayerId()); features = response.getFeatures(); Assert.assertNotNull(features); Assert.assertEquals(1, features.length); Assert.assertEquals("Country 3", features[0].getLabel()); geometry = features[0].getGeometry(); Assert.assertNotNull(geometry); coor = geometry.getGeometries()[0].getGeometries()[0].getCoordinates()[0]; Assert.assertEquals(-111319.49079327357, coor.getX(), DOUBLE_TOLERANCE); Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE); }
@Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); } }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  @Override SearchFeatureRequest getEmptyCommandRequest(); @Override SearchFeatureResponse getEmptyCommandResponse(); @Override void execute(SearchFeatureRequest request, SearchFeatureResponse response); }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  @Override SearchFeatureRequest getEmptyCommandRequest(); @Override SearchFeatureResponse getEmptyCommandResponse(); @Override void execute(SearchFeatureRequest request, SearchFeatureResponse response);  }