com.gisgraphy.geocoding

## Class GeocodingService

- java.lang.Object
- - com.gisgraphy.geocoding.GeocodingService

- All Implemented Interfaces:
    com.gisgraphy.geocoding.IGeocodingService

      @Service
      public class GeocodingService
      extends Object
      implements com.gisgraphy.geocoding.IGeocodingService

  Geocode internationnal address via gisgraphy services
  Author:
    David Masclet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ACCEPT_DISTANCE_BETWEEN_CITY_AND_STREET`
    `static SolrResponseDtoDistanceComparator` | `comparator`
    `static com.gisgraphy.domain.valueobject.Pagination` | `FIVE_RESULT_PAGINATION`
    `static Pattern` | `HOUSENUMBERPATTERN`
    `protected static org.slf4j.Logger` | `logger` The logger
    `static com.gisgraphy.domain.valueobject.Output` | `LONG_OUTPUT`
    `static com.gisgraphy.domain.valueobject.Output` | `MEDIUM_OUTPUT`
    `static com.gisgraphy.domain.valueobject.Pagination` | `ONE_RESULT_PAGINATION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeocodingService()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected com.gisgraphy.addressparser.AddressResultsDto` | `buildAddressResultDtoFromSolrResponseDto(List<com.gisgraphy.fulltext.SolrResponseDto> solResponseDtos, String houseNumberToFind)`
    `protected com.gisgraphy.addressparser.AddressResultsDto` | `buildAddressResultDtoFromStreetsAndCities(List<com.gisgraphy.fulltext.SolrResponseDto> streets, List<com.gisgraphy.fulltext.SolrResponseDto> cities, String houseNumberToFind)`
    `protected List<com.gisgraphy.fulltext.SolrResponseDto>` | `findCitiesInText(String text, String countryCode)`
    `protected List<com.gisgraphy.fulltext.SolrResponseDto>` | `findExactMatches(String text, String countryCode)`
    `protected String` | `findHouseNumber(String address, String countryCode)`
    `protected List<com.gisgraphy.fulltext.SolrResponseDto>` | `findInText(String text, String countryCode, com.vividsolutions.jts.geom.Point point, Class<?>[] placetypes)`
    `protected List<com.gisgraphy.fulltext.SolrResponseDto>` | `findStreetInText(String text, String countryCode, com.vividsolutions.jts.geom.Point point)`
    `com.gisgraphy.addressparser.AddressResultsDto` | `geocode(com.gisgraphy.addressparser.AddressQuery query)`
    `com.gisgraphy.addressparser.AddressResultsDto` | `geocode(com.gisgraphy.addressparser.Address address, String countryCode)`
    `void` | `geocodeAndSerialize(com.gisgraphy.addressparser.AddressQuery query, OutputStream outputStream)`
    `String` | `geocodeToString(com.gisgraphy.addressparser.AddressQuery query)`
    `protected String` | `getBestCitySearchSentence(com.gisgraphy.addressparser.Address address)`
    `protected boolean` | `isGeocodable(com.gisgraphy.addressparser.Address address)`
    `protected List<com.gisgraphy.fulltext.SolrResponseDto>` | `mergeSolrResponseDto(List<com.gisgraphy.fulltext.SolrResponseDto> exactMatches, List<com.gisgraphy.fulltext.SolrResponseDto> aproximativeMatches)`
    `protected void` | `populateAddressFromCity(com.gisgraphy.fulltext.SolrResponseDto city, com.gisgraphy.addressparser.Address address)`
    `protected com.gisgraphy.street.HouseNumberDto` | `searchHouseNumber(String houseNumberToFind, List<com.gisgraphy.street.HouseNumberDto> houseNumbersList, String countryCode)`
    `void` | `setAddressParser(com.gisgraphy.addressparser.IAddressParserService addressParser)`
    `void` | `setFullTextSearchEngine(com.gisgraphy.fulltext.IFullTextSearchEngine fullTextSearchEngine)`
    `void` | `setGisgraphyConfig(com.gisgraphy.domain.valueobject.GisgraphyConfig gisgraphyConfig)`
    `void` | `setImporterConfig(ImporterConfig importerConfig)`
    `void` | `setStatsUsageService(IStatsUsageService statsUsageService)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ACCEPT_DISTANCE_BETWEEN_CITY_AND_STREET

          public static final int ACCEPT_DISTANCE_BETWEEN_CITY_AND_STREET

      See Also:
        Constant Field Values

    - #### LONG_OUTPUT

          public static final com.gisgraphy.domain.valueobject.Output LONG_OUTPUT

    - #### MEDIUM_OUTPUT

          public static final com.gisgraphy.domain.valueobject.Output MEDIUM_OUTPUT

    - #### ONE_RESULT_PAGINATION

          public static final com.gisgraphy.domain.valueobject.Pagination ONE_RESULT_PAGINATION

    - #### FIVE_RESULT_PAGINATION

          public static final com.gisgraphy.domain.valueobject.Pagination FIVE_RESULT_PAGINATION

    - #### comparator

          public static final SolrResponseDtoDistanceComparator comparator

    - #### HOUSENUMBERPATTERN

          public static final Pattern HOUSENUMBERPATTERN

    - #### logger

          protected static final org.slf4j.Logger logger

      The logger

  - ### Constructor Detail

    - #### GeocodingService

          public GeocodingService()

  - ### Method Detail

    - #### geocodeAndSerialize

          public void geocodeAndSerialize(com.gisgraphy.addressparser.AddressQuery query,
                                 OutputStream outputStream)
                                   throws com.gisgraphy.geocoding.GeocodingException

      Specified by:
        `geocodeAndSerialize` in interface `com.gisgraphy.geocoding.IGeocodingService`
      Throws:
        `com.gisgraphy.geocoding.GeocodingException`

    - #### geocodeToString

          public String geocodeToString(com.gisgraphy.addressparser.AddressQuery query)
                                 throws com.gisgraphy.geocoding.GeocodingException

      Specified by:
        `geocodeToString` in interface `com.gisgraphy.geocoding.IGeocodingService`
      Throws:
        `com.gisgraphy.geocoding.GeocodingException`

    - #### geocode

          public com.gisgraphy.addressparser.AddressResultsDto geocode(com.gisgraphy.addressparser.AddressQuery query)
                                                                throws com.gisgraphy.geocoding.GeocodingException

      Specified by:
        `geocode` in interface `com.gisgraphy.geocoding.IGeocodingService`
      Throws:
        `com.gisgraphy.geocoding.GeocodingException`

    - #### isGeocodable

          protected boolean isGeocodable(com.gisgraphy.addressparser.Address address)

    - #### geocode

          public com.gisgraphy.addressparser.AddressResultsDto geocode(com.gisgraphy.addressparser.Address address,
                                                              String countryCode)
                                                                throws com.gisgraphy.geocoding.GeocodingException

      Specified by:
        `geocode` in interface `com.gisgraphy.geocoding.IGeocodingService`
      Throws:
        `com.gisgraphy.geocoding.GeocodingException`

    - #### getBestCitySearchSentence

          protected String getBestCitySearchSentence(com.gisgraphy.addressparser.Address address)

    - #### buildAddressResultDtoFromStreetsAndCities

          protected com.gisgraphy.addressparser.AddressResultsDto buildAddressResultDtoFromStreetsAndCities(List<com.gisgraphy.fulltext.SolrResponseDto> streets,
                                                                                                List<com.gisgraphy.fulltext.SolrResponseDto> cities,
                                                                                                String houseNumberToFind)

    - #### searchHouseNumber

          protected com.gisgraphy.street.HouseNumberDto searchHouseNumber(String houseNumberToFind,
                                                              List<com.gisgraphy.street.HouseNumberDto> houseNumbersList,
                                                              String countryCode)

    - #### buildAddressResultDtoFromSolrResponseDto

          protected com.gisgraphy.addressparser.AddressResultsDto buildAddressResultDtoFromSolrResponseDto(List<com.gisgraphy.fulltext.SolrResponseDto> solResponseDtos,
                                                                                               String houseNumberToFind)

    - #### populateAddressFromCity

          protected void populateAddressFromCity(com.gisgraphy.fulltext.SolrResponseDto city,
                                     com.gisgraphy.addressparser.Address address)

    - #### findCitiesInText

          protected List<com.gisgraphy.fulltext.SolrResponseDto> findCitiesInText(String text,
                                                                      String countryCode)

    - #### findStreetInText

          protected List<com.gisgraphy.fulltext.SolrResponseDto> findStreetInText(String text,
                                                                      String countryCode,
                                                                      com.vividsolutions.jts.geom.Point point)

    - #### findInText

          protected List<com.gisgraphy.fulltext.SolrResponseDto> findInText(String text,
                                                                String countryCode,
                                                                com.vividsolutions.jts.geom.Point point,
                                                                Class<?>[] placetypes)

    - #### mergeSolrResponseDto

          protected List<com.gisgraphy.fulltext.SolrResponseDto> mergeSolrResponseDto(List<com.gisgraphy.fulltext.SolrResponseDto> exactMatches,
                                                                          List<com.gisgraphy.fulltext.SolrResponseDto> aproximativeMatches)

      Parameters:
        `exactMatches` -
        `aproximativeMatches` -
      Returns:
        a list of `SolrResponseDto` with list1[0],list2[0],list1[1],list2[1],... it remove duplicates and null

    - #### findExactMatches

          protected List<com.gisgraphy.fulltext.SolrResponseDto> findExactMatches(String text,
                                                                      String countryCode)

    - #### findHouseNumber

          protected String findHouseNumber(String address,
                               String countryCode)

    - #### setAddressParser

          @Autowired
          public void setAddressParser(com.gisgraphy.addressparser.IAddressParserService addressParser)

    - #### setFullTextSearchEngine

          @Autowired
          public void setFullTextSearchEngine(com.gisgraphy.fulltext.IFullTextSearchEngine fullTextSearchEngine)

    - #### setStatsUsageService

          @Autowired
          public void setStatsUsageService(IStatsUsageService statsUsageService)

    - #### setImporterConfig

          @Autowired
          public void setImporterConfig(ImporterConfig importerConfig)

    - #### setGisgraphyConfig

          @Autowired
          public void setGisgraphyConfig(com.gisgraphy.domain.valueobject.GisgraphyConfig gisgraphyConfig)

Copyright © 2015. All rights reserved.