Class GeocodingCandidate
Contains comprehensive location information including:
- Geographic coordinates (latitude/longitude)
- Full address components (street, locality, municipality, etc.)
- Administrative hierarchy (district, subregion, region, country)
- Administrative IDs for each level (maintaining data integrity)
- Result type and precision level
All administrative fields are mapped directly from the API response without fallbacks, ensuring data transparency and allowing consumers to handle missing information appropriately.
GeocodingService service = new GeocodingService(config);
List<GeocodingCandidate> results = service.geocode(GeocodingOptions.builder()
.street("Carrer de la Provença")
.locality("Barcelona")
.countryCode("ESP")
.build());
for (GeocodingCandidate candidate : results) {
System.out.println(candidate.getName() + ": " + candidate.getCoord());
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructingGeocodingCandidateinstances. -
Method Summary
Modifier and TypeMethodDescriptionstatic GeocodingCandidate.Builderbuilder()Creates a new builder for constructingGeocodingCandidateinstances.boolean@NotNull CoordinategetCoord()Returns the geographic coordinates of this location.@Nullable StringReturns the country name.@Nullable StringReturns the country code (ISO 3166-1 alpha-2 or alpha-3).@Nullable StringReturns the district name.@Nullable StringReturns the district code/identifier.@Nullable StringReturns the house number.@NotNull StringgetId()Returns the unique identifier for this location.@Nullable StringgetLabel()Returns the full address label or description.@Nullable GeocodingLevelgetLevel()Returns the precision level of this geocoding result.@Nullable StringReturns the locality (locality) name.@Nullable StringReturns the locality (locality) code/identifier.@Nullable StringReturns the municipality name.@Nullable StringReturns the municipality code/identifier.@NotNull StringgetName()Returns the display name of this location.@Nullable StringReturns the postal code.@Nullable StringReturns the region (state/autonomous community) name.@Nullable StringReturns the region (state/autonomous community) code/identifier.@Nullable StringReturns the street name.@Nullable StringReturns the street code/identifier.@Nullable StringReturns the subregion (subregion) name.@Nullable StringReturns the subregion (subregion) code/identifier.@NotNull GeocodingCandidateTypegetType()Returns the type of this geocoding result.inthashCode()toString()
-
Method Details
-
builder
Creates a new builder for constructingGeocodingCandidateinstances.Provides a fluent API for setting all optional fields before building the final object.
- Returns:
- a new Builder instance
-
getId
Returns the unique identifier for this location.The ID format varies depending on the location type and data source. Common formats include numeric IDs (e.g., "28"), country codes (e.g., "ESP"), or composite identifiers (e.g., "ESPMAD").
- Returns:
- the location identifier, never null
-
getName
Returns the display name of this location.This is typically the most recognizable name for the location, which may be a street name, city name, POI name, or country name depending on the result type.
- Returns:
- the location name, never null
-
getLabel
Returns the full address label or description.This is the formatted address string as returned by the Cercalia API. May include the full street address, postal code, and locality.
- Returns:
- the address label, or null if not available
-
getStreet
Returns the street name.Available for street-level and address-level results.
- Returns:
- the street name, or null if not applicable
-
getStreetCode
Returns the street code/identifier.The internal identifier for the street in the Cercalia database.
- Returns:
- the street code, or null if not available
-
getLocality
Returns the locality (locality) name.This is the primary city or locality for the location. Mapped directly from the API without administrative fallbacks.
- Returns:
- the locality name, or null if not available
-
getLocalityCode
Returns the locality (locality) code/identifier.The internal identifier for the locality in the Cercalia database. Format varies but may include numeric or alphanumeric codes.
- Returns:
- the locality code, or null if not available
-
getMunicipality
Returns the municipality name.This is the administrative municipality for the location. Mapped directly from the API without administrative fallbacks.
- Returns:
- the municipality name, or null if not available
-
getMunicipalityCode
Returns the municipality code/identifier.The internal identifier for the municipality in the Cercalia database. Note: This field name maintains a deliberate typo ("municipalityCode") for 1:1 compatibility with the TypeScript SDK.
- Returns:
- the municipality code, or null if not available
-
getDistrict
Returns the district name.This is an administrative subdivision within the municipality. Not all locations have district information.
- Returns:
- the district name, or null if not available
-
getDistrictCode
Returns the district code/identifier.The internal identifier for the district in the Cercalia database.
- Returns:
- the district code, or null if not available
-
getSubregion
Returns the subregion (subregion) name.This is the administrative subregion (typically province) for the location. Mapped directly from the API without administrative fallbacks.
- Returns:
- the subregion name, or null if not available
-
getSubregionCode
Returns the subregion (subregion) code/identifier.The internal identifier for the subregion in the Cercalia database.
- Returns:
- the subregion code, or null if not available
-
getRegion
Returns the region (state/autonomous community) name.This is the administrative region for the location. Mapped directly from the API without administrative fallbacks.
- Returns:
- the region name, or null if not available
-
getRegionCode
Returns the region (state/autonomous community) code/identifier.The internal identifier for the region in the Cercalia database.
- Returns:
- the region code, or null if not available
-
getCountry
Returns the country name.This is the country name in the language specified in the API request.
- Returns:
- the country name, or null if not available
-
getCountryCode
Returns the country code (ISO 3166-1 alpha-2 or alpha-3).Common formats include "ESP" (3-letter) or "ES" (2-letter). The exact format depends on the Cercalia API response.
- Returns:
- the country code, or null if not available
-
getPostalCode
Returns the postal code.The postal code format varies by country (e.g., "08013" for Spain). May be null for some location types like countries or regions.
- Returns:
- the postal code, or null if not available
-
getHouseNumber
Returns the house number.Available only for address-level results that include specific building numbers.
- Returns:
- the house number, or null if not available
-
getCoord
Returns the geographic coordinates of this location.Coordinates are always present for valid geocoding results. No default values (like 0.0, 0.0) are used to avoid incorrect data.
- Returns:
- the coordinate with latitude and longitude, never null
-
getType
Returns the type of this geocoding result.Indicates whether this result is an address, street, POI, locality, etc. Useful for filtering and display purposes.
- Returns:
- the result type, never null
- See Also:
-
getLevel
Returns the precision level of this geocoding result.Indicates the administrative level or precision of the result. Higher precision results (e.g., ADR, ST) have more specific location information.
- Returns:
- the geocoding level, or null if not available
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-