Package org.onebusaway.geocoder.model

Examples of org.onebusaway.geocoder.model.GeocoderResults


  }

  @Test
  public void test() {

    GeocoderResults results = new GeocoderResults();

    GeocoderResult result = new GeocoderResult();
    result.setAddress("101 test blvd");
    result.setAdministrativeArea("wa");
    result.setCity("seattle");
    result.setCountry("usa");
    result.setLatitude(47.0);
    result.setLongitude(-122.0);
    result.setPostalCode("98000");
    results.addResult(result);

    GeocoderService mock = Mockito.mock(GeocoderService.class);
    Mockito.when(mock.geocode("test")).thenReturn(results);

    DatabaseCachingGeocoderImpl geocoder = new DatabaseCachingGeocoderImpl();
    geocoder.setSessionFactory(_sessionFactory);
    geocoder.setGeocoderService(mock);

    GeocoderResults resultsA = geocoder.geocode("test");
    List<GeocoderResult> resultsListA = resultsA.getResults();
    assertEquals(1, resultsListA.size());
    GeocoderResult resultA = resultsListA.get(0);

    assertEquals("101 test blvd", resultA.getAddress());
    assertEquals("wa", resultA.getAdministrativeArea());
    assertEquals("seattle", resultA.getCity());
    assertEquals("usa", resultA.getCountry());
    assertEquals(47.0, resultA.getLatitude(), 0.0);
    assertEquals(-122.0, resultA.getLongitude(), 0.0);
    assertEquals("98000", resultA.getPostalCode());

    GeocoderResults resultsB = geocoder.geocode("test");
    List<GeocoderResult> resultsListB = resultsB.getResults();
    assertEquals(1, resultsListB.size());
    GeocoderResult resultB = resultsListB.get(0);

    assertEquals("101 test blvd", resultB.getAddress());
    assertEquals("wa", resultB.getAdministrativeArea());
View Full Code Here


    URL url = url(b.toString());

    Digester digester = createDigester();

    GeocoderResults results = new GeocoderResults();
    digester.push(results);

    try {
      digester.parse(url.openStream());
    } catch (Exception ex) {
View Full Code Here

  public String execute() {

    if (_text == null || _text.length() == 0)
      return INPUT;

    GeocoderResults results = _service.setUserDefaultSearchFromGeocoderService(_text);
    _records = results.getResults();

    if (_records.isEmpty()) {
      return "noRecords";
    } else if (_records.size() > 1) {
      _session.put(TextmarksActionConstants.SESSION_KEY_GEOCODER_RESULTS,
View Full Code Here

        GeocoderResultsEntity.class, location);

    if (entity != null)
      return entity.getResults();

    GeocoderResults results = _geocoderService.geocode(location);

    entity = new GeocoderResultsEntity();
    entity.setLocation(location);
    entity.setResults(results);
    _template.saveOrUpdate(entity);
View Full Code Here

    URL url = url(b.toString());

    Digester digester = createDigester();

    GeocoderResults results = new GeocoderResults();
    digester.push(results);

    InputStream inputStream = null;
    try {
      inputStream = url.openStream();
View Full Code Here

    result.setCity(_city);
    result.setAdministrativeArea(_state);
    result.setPostalCode(_postalCode);
    result.setCountry(_country);

    GeocoderResults results = new GeocoderResults();
    results.addResult(result);
    return results;
  }
View Full Code Here

  }

  public GeocoderResults setUserDefaultSearchFromGeocoderService(
      String location) {

    GeocoderResults results = _geocoderService.geocode(location);
    List<GeocoderResult> records = results.getResults();

    if (records.size() == 1) {

      GeocoderResult result = records.get(0);
View Full Code Here

  }

  @Override
  public String execute() {

    GeocoderResults results = _service.setUserDefaultSearchFromGeocoderService(_location);

    _records = results.getResults();

    if (_records.isEmpty()) {
      return "noRecords";
    } else if (_records.size() > 1) {
      return "multipleRecords";
View Full Code Here

  public String execute() {

    if (_location == null || _location.length() == 0)
      return INPUT;

    GeocoderResults results = _service.setUserDefaultSearchFromGeocoderService(_location);
    _records = results.getResults();

    if (_records.isEmpty()) {
      return "noRecords";
    } else if (_records.size() > 1) {
      return "multipleRecords";
View Full Code Here

TOP

Related Classes of org.onebusaway.geocoder.model.GeocoderResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.