City¶
-
public class
City
extends Place¶ A
City
is a specific kind ofPlace
that stores the ID and name of a city. It can also store the names and IDs of the city’s country and region, but this is not mandatory. If any geographical descriptor (e.g. city, region, or country) is not specified, its name will be stored asPlace.NOWHERE
, but this constant should not be used by clients. Note that thecity
descriptor is mandatory.
Fields¶
Constructors¶
City¶
-
public
City
(long cityId, long regionId, long countryId, String cityName, String regionName, String countryName, Point latLng, long population, String featureCode)¶ Initialize instance fields and instance fields of superclasses based on provided arguments For creating cities that have city, region, and country all specified.
Parameters: - cityId – ID of city
- regionId – ID of city’s region
- countryId – ID of country’s region
- cityName – Name of city
- regionName – Name of region city lies within
- countryName – Name of country city lies within
- latLng – Latitude and longitude coordinates of city
- population – Population of the city
- featureCode – Feature code of the city
City¶
-
public
City
(long cityId, long regionId, String cityName, String regionName, Point latLng, long population, String featureCode)¶ Initialize instance fields and instance fields of superclasses based on provided arguments. For creating cities that have no country descriptor, but do have specified regions.
Parameters: - cityId – ID of city
- regionId – ID of city’s region
- cityName – Name of city
- regionName – Name of region city lies within
- latLng – Latitude and longitude coordinates of city
- population – Population of the city
- featureCode – Feature code of the city
City¶
-
public
City
(long cityId, String cityName, Point latLng, long population, String featureCode)¶ Initialize instance fields and instance fields of superclasses based on provided arguments For creating cities that have no region nor country descriptor
Parameters: - cityId – ID of city
- cityName – Name of city
- latLng – Latitude and longitude coordinates of city
- population – Population of the city
- featureCode – Feature code of the city
City¶
-
public
City
(JSONObject json)¶ Initialize instance fields and those of superclass based on provided JSON This class extracts the following fields, if they are present:
country_name
andregion_name
. It requires that the keyname
exist, as its value will be used as the City’s nameParameters: - json – JSON object describing the city to create
Throws: - JSONException – May be thrown in response to an invalidly formatted JSON object
Methods¶
getFullName¶
-
public String
getFullName
()¶ Get a name for the city that lists all available geographic descriptor names. For example,
Washington, D.C.
would be expressed asWashington, D.C., United States
, whileSan Francisco
would be expressed asSan Francisco, California, United States
.Returns: Name of city that includes all available geographic descriptors
newOnlyMissingRegion¶
-
public static City
newOnlyMissingRegion
(long cityId, long countryId, String cityName, String countryName, Point latLng, long population, String featureCode)¶ Return
City
object with fields initialized with provided parameters For creating cities that are only missing the region descriptor This unusual pseudo-constructor is required to avoid ambiguity between constructorsParameters: - cityId – ID of city
- countryId – ID of country’s region
- cityName – Name of city
- countryName – Name of country city lies within
- latLng – Latitude and longitude coordinates of city
- population – Population of the city
- featureCode – Feature code of the city
Returns: City object that has been initialized