haiku/headers/private/netservices/Geolocation.h

46 lines
917 B
C
Raw Normal View History

Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
/*
* Copyright 2014-2019, Haiku, Inc. All Rights Reserved.
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
* Distributed under the terms of the MIT License.
*/
#ifndef _GEOLOCATION_H
#define _GEOLOCATION_H
#include <Country.h>
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
#include <Url.h>
namespace BPrivate {
namespace Network {
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
class BGeolocation {
public:
BGeolocation();
BGeolocation(const BUrl& geolocationService,
const BUrl& geocodingService);
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
status_t LocateSelf(float& latitude, float& longitude);
status_t Locate(const BString placeName, float& latitude,
float& longitude);
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
status_t Name(const float latitude, const float longitude,
BString& name);
status_t Country(const float latitude, const float longitude,
BCountry& country);
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
private:
BUrl fGeolocationService;
BUrl fGeocodingService;
static const char* kDefaultGeolocationService;
static const char* kDefaultGeocodingService;
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
};
} // namespace Network
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
} // namespace BPrivate
Add BGeolocation experimental API. A BGeolocation object can query an online service to get geolocation and geotagging data: * LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points * Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging) * Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting). The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app. Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it. All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused. This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 18:23:04 +04:00
#endif