Class GeocodingOptions
Provides a fluent builder interface for constructing geocoding queries. Supports structured search by address components or free-form text queries.
GeocodingService service = new GeocodingService(config);
// Structured search by address components
List<GeocodingCandidate> results = service.geocode(GeocodingOptions.builder()
.street("Carrer de la Provença")
.locality("Barcelona")
.postalCode("08013")
.countryCode("ESP")
.limit(10)
.build());
// Free-form text search
List<GeocodingCandidate> results = service.geocode(GeocodingOptions.builder()
.query("Provença 5, Barcelona")
.fullSearch(true)
.build());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructingGeocodingOptionsinstances. -
Method Summary
Modifier and TypeMethodDescriptionstatic GeocodingOptions.Builderbuilder()Creates a new builder for constructingGeocodingOptionsinstances.@Nullable StringReturns the country name.@Nullable StringReturns the country code (ISO 3166-1).@Nullable BooleanReturns whether to enable full search mode.@Nullable StringReturns the house number.@Nullable IntegergetLimit()Returns the maximum number of results to return.@Nullable StringReturns the locality (locality) name.@Nullable StringReturns the municipality name.@Nullable StringReturns the postal code.@Nullable StringgetQuery()Returns the free-form text query for geocoding.@Nullable StringReturns the region (state/autonomous community) name.@Nullable StringReturns the street name.@Nullable StringReturns the subregion (subregion) name.
-
Method Details
-
builder
Creates a new builder for constructingGeocodingOptionsinstances.- Returns:
- a new Builder instance
-
getQuery
Returns the free-form text query for geocoding.When set, this takes precedence over structured address components. Use this for general text searches like "Provença 5, Barcelona".
- Returns:
- the text query, or null if using structured search
-
getCountry
Returns the country name.The full country name (e.g., "Spain", "España").
- Returns:
- the country name, or null if not specified
-
getCountryCode
Returns the country code (ISO 3166-1).Recommended to use 2-letter codes (e.g., "ES" for Spain) or 3-letter codes (e.g., "ESP"). Default is "ESP" if not specified.
- Returns:
- the country code, or null if not specified
-
getLocality
Returns the locality (locality) name.The primary locality for the search.
- Returns:
- the locality name, or null if not specified
-
getMunicipality
Returns the municipality name.The administrative municipality for the search.
- Returns:
- the municipality name, or null if not specified
-
getRegion
Returns the region (state/autonomous community) name.The administrative region for the search.
- Returns:
- the region name, or null if not specified
-
getSubregion
Returns the subregion (subregion) name.The administrative subregion (typically province) for the search.
- Returns:
- the subregion name, or null if not specified
-
getStreet
Returns the street name.The street name for structured address search.
- Returns:
- the street name, or null if not specified
-
getPostalCode
Returns the postal code.The postal code for the search area.
- Returns:
- the postal code, or null if not specified
-
getHouseNumber
Returns the house number.The specific house or building number for the address.
- Returns:
- the house number, or null if not specified
-
getLimit
Returns the maximum number of results to return.Limits the number of candidates returned by the API. If not specified, the API's default limit is used.
- Returns:
- the result limit, or null for API default
-
getFullSearch
Returns whether to enable full search mode.When enabled, performs a more exhaustive search that may include partial matches and broader results. Useful when the initial search returns few or no results.
- Returns:
- true if full search is enabled, false or null otherwise
-