test_class.declarator: DELTA = 1e-20
test_class.modifier: private static final
test_class.original_string: private static final double DELTA = 1e-20;
test_class.type: double
test_class.var_name: DELTA
test_class.declarator: commandDispatcher
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private CommandDispatcher commandDispatcher;
test_class.type: CommandDispatcher
test_class.var_name: commandDispatcher
test_class.file: plugin/geocoder/geocoder/src/test/java/org/geomajas/plugin/geocoder/command/geocoder/GetLocationForStringCommandTest.java
test_class.identifier: GetLocationForStringCommandTest
test_case.body: @Test
  	public void expandPointTest() throws Exception {
  		GetLocationForStringRequest request = new GetLocationForStringRequest();
  		request.setCrs("EPSG:900913");
  		request.setLocation("booischot");
  
  		CommandResponse commandResponse = commandDispatcher.execute(GetLocationForStringRequest.COMMAND, request, null,
  				"en");
  		Assert.assertNotNull(commandResponse);
  		Assert.assertTrue(commandResponse instanceof GetLocationForStringResponse);
  		GetLocationForStringResponse response = (GetLocationForStringResponse)commandResponse;
  		Assert.assertTrue(response.isLocationFound());
  		Assert.assertEquals("booischot", response.getCanonicalLocation());
  		Assert.assertNotNull(response.getCenter());
  		Assert.assertNotNull(response.getBbox());
  		Assert.assertEquals(621468.063486916, response.getCenter().getX(), DELTA);
  		Assert.assertEquals(5706881.117852388, response.getCenter().getY(), DELTA);
  		Assert.assertEquals(621325.5343735645, response.getBbox().getX(), DELTA);
  		Assert.assertEquals(5706809.617868648, response.getBbox().getY(), DELTA);
  		Assert.assertEquals(285.05822670296766, response.getBbox().getWidth(), DELTA);
  		Assert.assertEquals(142.99996748007834, response.getBbox().getHeight(), DELTA);
  		Assert.assertEquals("static-regex", response.getGeocoderName());
  		Assert.assertNotNull(response.getUserData());
  		Assert.assertEquals("schotbooi", ((UserDataTestInfo)response.getUserData()).getValue());
  	}
test_case.class_method_signature: GetLocationForStringCommandTest.expandPointTest()
test_case.full_signature: @Test public void expandPointTest()
test_case.identifier: expandPointTest
test_case.invocations: setCrs setLocation execute assertNotNull assertTrue assertTrue isLocationFound assertEquals getCanonicalLocation assertNotNull getCenter assertNotNull getBbox assertEquals getX getCenter assertEquals getY getCenter assertEquals getX getBbox assertEquals getY getBbox assertEquals getWidth getBbox assertEquals getHeight getBbox assertEquals getGeocoderName assertNotNull getUserData assertEquals getValue getUserData
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void expandPointTest()
focal_class.declarator: geocoderInfo
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private GeocoderInfo geocoderInfo;
focal_class.type: GeocoderInfo
focal_class.var_name: geocoderInfo
focal_class.declarator: defaultSplitGeocoderStringService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private SplitCommaReverseService defaultSplitGeocoderStringService;
focal_class.type: SplitCommaReverseService
focal_class.var_name: defaultSplitGeocoderStringService
focal_class.declarator: defaultCombineResultService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private CombineUnionService defaultCombineResultService;
focal_class.type: CombineUnionService
focal_class.var_name: defaultCombineResultService
focal_class.declarator: dtoConverterService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private DtoConverterService dtoConverterService;
focal_class.type: DtoConverterService
focal_class.var_name: dtoConverterService
focal_class.declarator: geocoderUtilService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private GeocoderUtilService geocoderUtilService;
focal_class.type: GeocoderUtilService
focal_class.var_name: geocoderUtilService
focal_class.declarator: geoService
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private GeoService geoService;
focal_class.type: GeoService
focal_class.var_name: geoService
focal_class.file: plugin/geocoder/geocoder/src/main/java/org/geomajas/plugin/geocoder/command/geocoder/GetLocationForStringCommand.java
focal_class.identifier: GetLocationForStringCommand
focal_class.interfaces: implements CommandHasRequest<GetLocationForStringRequest, GetLocationForStringResponse>
focal_class.class_method_signature: GetLocationForStringCommand.getEmptyCommandRequest()
focal_class.full_signature: @Override public GetLocationForStringRequest getEmptyCommandRequest()
focal_class.identifier: getEmptyCommandRequest
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: GetLocationForStringRequest
focal_class.signature: GetLocationForStringRequest getEmptyCommandRequest()
focal_class.class_method_signature: GetLocationForStringCommand.getEmptyCommandResponse()
focal_class.full_signature: @Override public GetLocationForStringResponse getEmptyCommandResponse()
focal_class.identifier: getEmptyCommandResponse
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: GetLocationForStringResponse
focal_class.signature: GetLocationForStringResponse getEmptyCommandResponse()
focal_class.class_method_signature: GetLocationForStringCommand.execute(GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_class.full_signature: @Override public void execute(GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_class.return: void
focal_class.signature: void execute(GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_class.class_method_signature: GetLocationForStringCommand.getShouldUsePattern(String namePattern)
focal_class.full_signature: private Pattern getShouldUsePattern(String namePattern)
focal_class.identifier: getShouldUsePattern
focal_class.modifiers: private
focal_class.parameters: (String namePattern)
focal_class.return: Pattern
focal_class.signature: Pattern getShouldUsePattern(String namePattern)
focal_class.class_method_signature: GetLocationForStringCommand.shouldUse(Pattern namePattern, String serviceName)
focal_class.full_signature: private boolean shouldUse(Pattern namePattern, String serviceName)
focal_class.identifier: shouldUse
focal_class.modifiers: private
focal_class.parameters: (Pattern namePattern, String serviceName)
focal_class.return: boolean
focal_class.signature: boolean shouldUse(Pattern namePattern, String serviceName)
focal_method.body: @Override
  	public void execute(GetLocationForStringRequest request, GetLocationForStringResponse response) throws Exception {
  		String location = request.getLocation();
  		if (null == location) {
  			throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "location");
  		}
  		String crsString = request.getCrs();
  		if (null == crsString) {
  			throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs");
  		}
  		Locale locale = null;
  		if (null != request.getLocale()) {
  			locale = new Locale(request.getLocale());
  		}
  		int maxAlternatives = request.getMaxAlternatives();
  
  		Crs crs = geoService.getCrs2(crsString);
  
  		SplitGeocoderStringService splitGeocoderStringService = geocoderInfo.getSplitGeocoderStringService();
  		if (null == splitGeocoderStringService) {
  			splitGeocoderStringService = defaultSplitGeocoderStringService;
  		}
  		CombineResultService combineResultService = geocoderInfo.getCombineResultService();
  		if (null == combineResultService) {
  			combineResultService = defaultCombineResultService;
  		}
  
  		List<String> locationList = splitGeocoderStringService.split(location);
  
  		List<GetLocationResult> results = new ArrayList<GetLocationResult>();
  		List<GetLocationResult[]> alternatives = new ArrayList<GetLocationResult[]>();
  		Pattern namePattern = getShouldUsePattern(request.getServicePattern());
  		for (GeocoderService geocoderService : geocoderInfo.getGeocoderServices()) {
  			if (shouldUse(namePattern, geocoderService.getName())) {
  				GetLocationResult[] result = geocoderService.getLocation(locationList, maxAlternatives, locale);
  				if (null != result && result.length > 0) {
  					for (GetLocationResult aResult : result) {
  						aResult.setGeocoderName(geocoderService.getName());
  
  						CoordinateReferenceSystem sourceCrs = geocoderService.getCrs();
  						Envelope envelope = aResult.getEnvelope();
  
  						// point locations needs to converted to an area based on configuration settings
  						if (null == envelope) {
  							envelope = geocoderUtilService.extendPoint(aResult.getCoordinate(), sourceCrs,
  									geocoderInfo.getPointDisplayWidth(), geocoderInfo.getPointDisplayHeight());
  						}
  
  						// result needs to be CRS transformed to request CRS
  						aResult.setEnvelope(geocoderUtilService.transform(envelope, sourceCrs, crs));
  					}
  					if (result.length > 1) {
  						alternatives.add(result);
  					} else {
  						results.add(result[0]);
  					}
  					if (!geocoderInfo.isLoopAllServices()) {
  						break;
  					}
  				}
  			}
  		}
  
  		response.setLocationFound(false);
  		if (!results.isEmpty()) {
  			response.setLocationFound(true);
  
  			// combine match strings, default to search string unless we know we can do better
  			String matchedLocation = location;
  			String geocoderName = null;
  			if (results.size() == 1) {
  				List<String> matchedStrings = results.get(0).getCanonicalStrings();
  				if (null != matchedStrings) {
  					matchedLocation = splitGeocoderStringService.combine(matchedStrings);
  				}
  				geocoderName = results.get(0).getGeocoderName();
  			}
  			response.setCanonicalLocation(matchedLocation);
  			response.setGeocoderName(geocoderName);
  
  			// combine the user data, only when there is just one result
  			if (results.size() == 1) {
  				response.setUserData(results.get(0).getUserData());
  			}
  
  			// combine location envelopes
  			Envelope resultEnvelope = combineResultService.combine(results);
  			Bbox bbox = dtoConverterService.toDto(resultEnvelope);
  			response.setBbox(bbox);
  			response.setCenter(new Coordinate(bbox.getX() + bbox.getWidth() / 2, bbox.getY() + bbox.getHeight() / 2));
  		} else {
  			List<GetLocationForStringAlternative> altList = new ArrayList<GetLocationForStringAlternative>();
  			response.setAlternatives(altList);
  			for (GetLocationResult[] altArr : alternatives) {
  				for (GetLocationResult alt : altArr) {
  					if (maxAlternatives > 0 && maxAlternatives <= altList.size()) {
  						break;
  					}
  					GetLocationForStringAlternative one = new GetLocationForStringAlternative();
  
  					String matchedLocation = location;
  					List<String> matchedStrings = alt.getCanonicalStrings();
  					if (null != matchedStrings) {
  						matchedLocation = splitGeocoderStringService.combine(matchedStrings);
  					}
  					one.setCanonicalLocation(matchedLocation);
  
  					// set additional info data
  					one.setGeocoderName(alt.getGeocoderName());
  					one.setUserData(alt.getUserData());
  
  					// combine location envelopes
  					Bbox bbox = dtoConverterService.toDto(alt.getEnvelope());
  					one.setBbox(bbox);
  					one.setCenter(
  							new Coordinate(bbox.getX() + bbox.getWidth() / 2, bbox.getY() + bbox.getHeight() / 2));
  
  					altList.add(one);
  				}
  			}
  		}
  
  	}
focal_method.class_method_signature: GetLocationForStringCommand.execute(GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_method.full_signature: @Override public void execute(GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_method.identifier: execute
focal_method.invocations: getLocation getCrs getLocale getLocale getMaxAlternatives getCrs2 getSplitGeocoderStringService getCombineResultService split getShouldUsePattern getServicePattern getGeocoderServices shouldUse getName getLocation setGeocoderName getName getCrs getEnvelope extendPoint getCoordinate getPointDisplayWidth getPointDisplayHeight setEnvelope transform add add isLoopAllServices setLocationFound isEmpty setLocationFound size getCanonicalStrings get combine getGeocoderName get setCanonicalLocation setGeocoderName size setUserData getUserData get combine toDto setBbox setCenter getX getWidth getY getHeight setAlternatives size getCanonicalStrings combine setCanonicalLocation setGeocoderName getGeocoderName setUserData getUserData toDto getEnvelope setBbox setCenter getX getWidth getY getHeight add
focal_method.modifiers: @Override public
focal_method.parameters: (GetLocationForStringRequest request, GetLocationForStringResponse response)
focal_method.return: void
focal_method.signature: void execute(GetLocationForStringRequest request, GetLocationForStringResponse response)