Stellarium  HEAD
Public Slots | Signals | Public Member Functions | Static Public Member Functions
StelLocationMgr Class Reference

Manage the list of available location. More...

#include <StelLocationMgr.hpp>

Public Slots

const StelLocation locationForString (const QString &s) const
 Return the StelLocation for a given string Can match location name, or coordinates.
 
void locationFromIP ()
 Find location via online lookup of IP address.
 
QStringList getAllTimezoneNames () const
 return a QStringList of valid timezone names in Stellarium's location database.
 
QColor getColorForCoordinates (const double lng, const double lat) const
 Retrieve a color from coordinate lookup into the current planet texture (or specialized earth map)
 
static QString sanitizeTimezoneStringForLocationDB (QString tzString)
 Check timezone string and return either the same or one that we use in the Stellarium location database. More...
 
static QString sanitizeTimezoneStringFromLocationDB (QString dbString)
 Attempt to translate a timezone name from those used in Stellarium's location database to a name which is known to Qt at runtime as result of QTimeZone::availableTimeZoneIds(). More...
 

Signals

void locationListChanged ()
 Can be used to detect changes to the full location list i.e. More...
 

Public Member Functions

 StelLocationMgr ()
 Default constructor which loads the list of locations from the base and user location files.
 
 StelLocationMgr (const LocationList &locations)
 Construct a StelLocationMgr which uses the locations given instead of loading them from the files.
 
void setLocations (const LocationList &locations)
 Replaces the loaded location list.
 
LocationList getAll () const
 Return the list of all loaded locations.
 
LocationMap getAllMap () const
 Returns a map of all loaded locations. The key is the location ID, suitable for a list view.
 
const StelLocation locationFromCLI () const
 Return the StelLocation from a CLI.
 
const StelLocationgetLastResortLocation () const
 Return a valid location when no valid one was found.
 
bool canSaveUserLocation (const StelLocation &loc) const
 Get whether a location can be permanently added to the list of user locations The main constraint is that the small string must be unique.
 
bool saveUserLocation (const StelLocation &loc)
 Add permanently a location to the list of user locations It is later identified by its small string.
 
bool canDeleteUserLocation (const QString &id) const
 Get whether a location can be deleted from the list of user locations If the location comes from the base read only list, it cannot be deleted. More...
 
bool deleteUserLocation (const QString &id)
 Delete permanently the given location from the list of user locations If the location comes from the base read only list, it cannot be deleted and false is returned. More...
 
LocationMap pickLocationsNearby (const QString &planetName, const float longitude, const float latitude, const float radiusDegrees)
 Find list of locations within. More...
 
LocationMap pickLocationsInRegion (const QString &region)
 Find list of locations in a particular region only.
 
QStringList getRegionNames (const QString &planet="") const
 return a QStringList of region names by planet (return all list of regions if planet name is empty)
 

Static Public Member Functions

static QString pickRegionFromCountryCode (const QString &countryCode)
 Pick region name from ISO 3166-1 two-letter country codes.
 
static QString pickRegionFromCountry (const QString &country)
 Pick region name from country English name.
 
static QString pickRegionFromCode (int regionCode)
 Pick region name from region code.
 
static QPair< Vec3d, Vec2dgeo2utm (const double longitude, const double latitude, const int zone=0)
 Compute UTM coordinates including convergence angle from geographic coordinates (WGS84). More...
 
static QPair< Vec3d, Vec2dutm2geo (const double easting, const double northing, const int zone, const bool north)
 Compute geographical coordinates (WGS84) from UTM https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system. More...
 
static QPair< int, QChar > utmZone (const double longitude, const double latitude)
 Find UTM zone designation. More...
 

Detailed Description

Manage the list of available location.

Member Function Documentation

◆ canDeleteUserLocation()

bool StelLocationMgr::canDeleteUserLocation ( const QString &  id) const

Get whether a location can be deleted from the list of user locations If the location comes from the base read only list, it cannot be deleted.

Parameters
idthe location ID

◆ deleteUserLocation()

bool StelLocationMgr::deleteUserLocation ( const QString &  id)

Delete permanently the given location from the list of user locations If the location comes from the base read only list, it cannot be deleted and false is returned.

Parameters
idthe location ID

◆ geo2utm()

static QPair<Vec3d,Vec2d> StelLocationMgr::geo2utm ( const double  longitude,
const double  latitude,
const int  zone = 0 
)
static

Compute UTM coordinates including convergence angle from geographic coordinates (WGS84).

https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

  • longitude geographic longitude from Greenwich, degrees [-180...+180]
  • latitude geographic latitude from equator, degrees. UTM defined for [-80...+84]
  • zone UTM zone. If 0, compute best-fit zone.
    Returns
    {{E[m], N[m], zone}, {gamma[rad], k}} The returned zone contains the input or, if input was 0 (or missing), the best-fitting zone. North or South is not returned but is trivially found from latitude.

◆ locationListChanged

void StelLocationMgr::locationListChanged ( )
signal

Can be used to detect changes to the full location list i.e.

when the user added or removed locations

◆ pickLocationsNearby()

LocationMap StelLocationMgr::pickLocationsNearby ( const QString &  planetName,
const float  longitude,
const float  latitude,
const float  radiusDegrees 
)

Find list of locations within.

Parameters
radiusDegreesof selected (usually screen-clicked) coordinates.

◆ sanitizeTimezoneStringForLocationDB

static QString StelLocationMgr::sanitizeTimezoneStringForLocationDB ( QString  tzString)
staticslot

Check timezone string and return either the same or one that we use in the Stellarium location database.

If timezone name starts with "UTC", always return unchanged. This is required to store timezone names exactly as we know them, and not mix ours and current-IANA spelling flavour.

◆ sanitizeTimezoneStringFromLocationDB

static QString StelLocationMgr::sanitizeTimezoneStringFromLocationDB ( QString  dbString)
staticslot

Attempt to translate a timezone name from those used in Stellarium's location database to a name which is known to Qt at runtime as result of QTimeZone::availableTimeZoneIds().

That list may be updated by OS anytime and is known to differ between OSes. Some spellings may be different, or in some cases some names get simply translated to "UTC+HH:MM" style. The empty string gets translated to "UTC".

◆ utm2geo()

static QPair<Vec3d,Vec2d> StelLocationMgr::utm2geo ( const double  easting,
const double  northing,
const int  zone,
const bool  north 
)
static

Compute geographical coordinates (WGS84) from UTM https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system.

  • easting (metres). False Easting of Zone meridian = 500000
  • northing (metres). For southern latitudes, equator = 10000000
  • zone UTM zone (longitudinal).
  • north true for N, false for S latitude zones.
    Returns
    {{longitude[deg], latitude[deg], refLong[deg]}, {gamma[rad], k}}

◆ utmZone()

static QPair<int, QChar> StelLocationMgr::utmZone ( const double  longitude,
const double  latitude 
)
static

Find UTM zone designation.

The letters are usually not important for finding the coordinates. This works for the whole globe, even for polar zones, and observes the adjusted zones of Svalbard and Norway.