com.gisgraphy.importer

## Class MunicipalityDetector

- java.lang.Object
- - com.gisgraphy.importer.MunicipalityDetector

- All Implemented Interfaces:
    IMunicipalityDetector

      @Service
      public class MunicipalityDetector
      extends Object
      implements IMunicipalityDetector

  Author:
    david masclet geonames classify features with some code. there is no real definition of City. city are populated place without any distinction. this class try to detect if the place is a city. to do this we search for population administrative division code (one or the other or both and apply a strategy depends on country. for each country we have search for the number of city and search what is the best fields to look to see if it is a city. e.g : for France there is about 36000 city. in geonames there is about 58000 place. if we look at the adm4 code and the population (both) we identify 36875 city.
    it is not deterministic but probabilistic approach.if you got better idea to identify city, please let us know. This can seems tricky but this works well and improve geocoding when we fill the is_in fields,we have a city and not a quater) this code is for the moment replace by the osm conditionsthis seems to be more reliable, but we keep this code for some country specificities based on user feedbacks

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MunicipalityDetector.MunicipalityDetectionStrategy`
    `static class` | `MunicipalityDetector.MunicipalityOSMDetectionStrategy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Map<String,MunicipalityDetector.MunicipalityDetectionStrategy>` | `countrycodeToCityDetectionStrategy`
    `static Map<String,MunicipalityDetector.MunicipalityOSMDetectionStrategy>` | `countrycodeToCityOSMDetectionStrategy`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MunicipalityDetector()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `isMunicipality_internal(MunicipalityDetector.MunicipalityDetectionStrategy strategy, Integer population, String adm1code, String adm2code, String adm3code, String adm4code, String adm5code)`
    `boolean` | `isMunicipality(String countryCode, String placetype, String nodeType, com.gisgraphy.domain.valueobject.GISSource source)`
    `boolean` | `isMunicipalityByGisFeature(String countrycode, GisFeature gisFeature)`

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

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

- - ### Field Detail

    - #### countrycodeToCityOSMDetectionStrategy

          public static final Map<String,MunicipalityDetector.MunicipalityOSMDetectionStrategy> countrycodeToCityOSMDetectionStrategy

    - #### countrycodeToCityDetectionStrategy

          public static final Map<String,MunicipalityDetector.MunicipalityDetectionStrategy> countrycodeToCityDetectionStrategy

  - ### Constructor Detail

    - #### MunicipalityDetector

          public MunicipalityDetector()

  - ### Method Detail

    - #### isMunicipality

          public boolean isMunicipality(String countryCode,
                               String placetype,
                               String nodeType,
                               com.gisgraphy.domain.valueobject.GISSource source)

      Specified by:
        `isMunicipality` in interface `IMunicipalityDetector`

    - #### isMunicipalityByGisFeature

          public boolean isMunicipalityByGisFeature(String countrycode,
                                           GisFeature gisFeature)

      Specified by:
        `isMunicipalityByGisFeature` in interface `IMunicipalityDetector`

    - #### isMunicipality_internal

          protected boolean isMunicipality_internal(MunicipalityDetector.MunicipalityDetectionStrategy strategy,
                                        Integer population,
                                        String adm1code,
                                        String adm2code,
                                        String adm3code,
                                        String adm4code,
                                        String adm5code)

Copyright © 2015. All rights reserved.