py-gpsd2


Namepy-gpsd2 JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryPython 3 library for working with gpsd
upload_time2023-05-15 01:35:14
maintainer
docs_urlNone
authorMartijn Braam
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Python3 GPSD client
===================

This is a library for polling gpsd in Python3.

Forked from (gpsd-py3)[https://github.com/MartijnBraam/gpsd-py3]

Installation
------------

Install through pip::

    $ pip3 install py-gpsd2

Usage
-----

Just import it and poll the gps. Only a single gpsd server a time is supported::

    import gpsd2

    # Connect to the local gpsd
    gpsd2.connect()

    # Connect somewhere else
    gpsd2.connect(host="127.0.0.1", port=123456)

    # Get gps position
    packet = gpsd2.get_current()

    # See the inline docs for GpsResponse for the available data
    print(packet.position())


GpsResponse Object Information
-----

### Properties ###
Description and information copied from [http://catb.org/gpsd/gpsd_json.html](http://catb.org/gpsd/gpsd_json.html).

- **mode**
	- *Description:* Indicates the status of the GPS reception
	- *Availability:* Always
	- *Data Type:* Int
	- *Possible Values:* 0=no mode value yet seen, 1=no fix, 2=2D fix, 3=3D fix
- **sats**
	- *Description:* The number of satellites received by the GPS unit
	- *Availability:* Always
	- *Data Type:* Int
- **lat**
	- *Description:* Latitude in degrees
	- *Availability:* mode >= 2
	- *Data Type:*
	- *Possible Values:* -90.0 to 90.0
- **lon**
	- *Description:* Longitude in degrees
	- *Availability:* mode >= 2
	- *Data Type:* float
	- *Possible Values:* -180.0 to 180.0
- **track**
	- *Description:* Course over ground, degrees from true north
	- *Availability:* mode >= 2
	- *Data Type:* float
- **hspeed**
	- *Description:* Speed over ground, meters per second
	- *Availability:* mode >= 2
	- *Data Type:* float
- **time**
	- *Description:* Time/date stamp in ISO8601 format, UTC. May have a fractional part of up to .001sec precision May be absent if mode is not 2 or 3.
	- *Availability:* mode >= 2
	- *Data Type:* string
	- *Sample Value:* 2016-08-05T01:51:44.000Z
- **error**
	- *Description:* Error information 
		- c - ecp: Climb/sink error estimate in meters/sec, 95% confidence.
		- s - eps: Speed error estinmate in meters/sec, 95% confidence.
		- t - ept: Estimated timestamp error (%f, seconds, 95% confidence). Present if time is present.
		- v - epv: Estimated vertical error in meters, 95% confidence. Present if mode is 3 and DOPs can be calculated from the satellite view.
		- x - epx: Longitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.
		- y - epy: Latitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.
	- *Availability:* mode >= 2 *(**NOTE:** c & v require mode >= 3)*
	- *Data Type:* dictionary
	- *Possible Values:*
- **alt**
	- *Description:* Altitude in meters
	- *Availability:* mode >= 3
	- *Data Type:* float
- **climb**
	- *Description:* Climb (positive) or sink (negative) rate, meters per second
	- *Availability:* mode >= 3
	- *Data Type:* float

### Methods ###
- **position**
	- *Description:* Get the latitude and longtitude as tuple
	- *Availability:* mode >= 2
	- *Parameters:* None
	- *Return Type:* tuple (latitude, longitude)
	- *Sample Value:*  (39.8333333, -98.585522)
- **speed**
	- *Description:* Get the horisontal speed with the small movements filtered out
	- *Availability:* mode >= 2
	- *Parameters:* None
	- *Return Type:* float
- **position_precision**
	- *Description:* Get the error margin in meters for the current fix
	- *Availability:* mode >= 2
	- *Parameters:* None
	- *Return Type:* tuple (x-y plane, z direction)
- **get_time(local_time: bool)**
	- *Description:* Get the GPS time in UTC or in local timezone
	- *Availability:* mode >= 2
	- *Parameters:* local_time
	- *Return Type:* datetime
- **map_url**
	- *Description:* Get a openstreetmap url for the current position
	- *Availability:* mode >= 2
	- *Parameters:* None
	- *Return Type:* string
	- *Sample Value:* http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15
- **altitude**
	- *Description:* Get the altitude in meters
	- *Availability:* mode >= 3
	- *Parameters:* None
	- *Return Type:* float
- **movement**
	- *Description:* Get the speed and direction of the current movement as dict
	- *Availability:* mode >= 3
	- *Parameters:* None
	- *Return Type:* dictionary
		- speed
		- track
		- climb
- **speed_vertical**
	- *Description:* Get the vertical speed with the small movements filtered out
	- *Availability:* mode >= 3
	- *Parameters:* None
	- *Return Type:* float


Exception Information
-----

- NoFixError: Raised when a value is requested with the mode below the threshold for obtaining the data
	- Needs at least 2D fix
	- Needs at least 3D fix
- General Exceptions
	- Unexpected message received from gps: ...
	- Unexpected data received as welcome. Is the server a gpsd 3 server?


Information on Available Functions
-----

- **connect**
	- *Description:* Connect to a GPSD instance
	- *Parameters:* host="127.0.0.1", port=2947
	- *Return Type:* None
- **get_current**
	- *Description:* Poll gpsd for a new position
	- *Parameters:* None
	- *Return Type:* GpsResponse Object
- **device**
	- *Description:* Get information about current gps device
	- *Parameters:* None
	- *Return Type:* dictionary
		- path
		- speed
		- driver
	- *Sample Data:* {'speed': 9600, 'path': '/dev/ttyS0', 'driver': 'MTK-3301'}


----------

## Sample Code ##

```python
#!/usr/bin/env python3

import gpsd

# Connect to the local gpsd
gpsd.connect()

# Connect somewhere else
gpsd.connect(host="127.0.0.1", port=123456)

# Get gps position
packet = gpsd.get_current()

# See the inline docs for GpsResponse for the available data
print(" ************ PROPERTIES ************* ")
print("  Mode: " + str(packet.mode))
print("Satellites: " + str(packet.sats))
if packet.mode >= 2:
print("  Latitude: " + str(packet.lat))
print(" Longitude: " + str(packet.lon))
print(" Track: " + str(packet.track))
print("  Horizontal Speed: " + str(packet.hspeed))
print(" Time: " + str(packet.time))
print(" Error: " + str(packet.error))
else:
print("  Latitude: NOT AVAILABLE")
print(" Longitude: NOT AVAILABLE")
print(" Track: NOT AVAILABLE")
print("  Horizontal Speed: NOT AVAILABLE")
print(" Error: NOT AVAILABLE")

if packet.mode >= 3:
print("  Altitude: " + str(packet.alt))
print(" Climb: " + str(packet.climb))
else:
print("  Altitude: NOT AVAILABLE")
print(" Climb: NOT AVAILABLE")

print(" ************** METHODS ************** ")
if packet.mode >= 2:
print("  Location: " + str(packet.position()))
print(" Speed: " + str(packet.speed()))
print("Position Precision: " + str(packet.position_precision()))
print("  Time UTC: " + str(packet.time_utc()))
print("Time Local: " + str(packet.time_local()))
print("   Map URL: " + str(packet.map_url()))
else:
print("  Location: NOT AVAILABLE")
print(" Speed: NOT AVAILABLE")
print("Position Precision: NOT AVAILABLE")
print("  Time UTC: NOT AVAILABLE")
print("Time Local: NOT AVAILABLE")
print("   Map URL: NOT AVAILABLE")

if packet.mode >= 3:
print("  Altitude: " + str(packet.altitude()))
# print("  Movement: " + str(packet.movement()))
# print("  Speed Vertical: " + str(packet.speed_vertical()))
else:
print("  Altitude: NOT AVAILABLE")
# print("  Movement: NOT AVAILABLE")
# print(" Speed Vertical: NOT AVAILABLE")

print(" ************* FUNCTIONS ************* ")
print("Device: " + str(gpsd.device()))
```


### Sample Output ###
```
     ************ PROPERTIES *************
                  Mode: 3
            Satellites: 10
              Latitude: 39.8333333
             Longitude: -98.585522
                 Track: 237.31
      Horizontal Speed: 0.0
                  Time: 2016-08-05T03:02:13.000Z
                 Error: {'v': 31.97, 't': 0.005, 'x': 10.055, 'c': (63.94,), 's': 35 .16, 'y': 17.58}
              Altitude: 100.3
                 Climb: 0.0
     ************** METHODS **************
               Location: (39.8333333, -98.585522)
                  Speed: 0
     Position Precision: (17.58, 31.97)
               Time UTC: 2016-08-05 03:02:13
             Time Local: 2016-08-04 23:02:13-04:00
                Map URL: http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15
               Altitude: 100.3
     ************* FUNCTIONS *************
                 Device: {'driver': 'MTK-3301', 'path': '/dev/ttyS0', 'speed': 9600}
```
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "py-gpsd2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Martijn Braam",
    "author_email": "hatsunearu <me@hatsunearu.xyz>",
    "download_url": "https://files.pythonhosted.org/packages/9d/dc/03125ecf40af5855b4d3c4c8197c6eb31e6c190a408e05a9d8725521968e/py_gpsd2-0.1.0.tar.gz",
    "platform": null,
    "description": "Python3 GPSD client\n===================\n\nThis is a library for polling gpsd in Python3.\n\nForked from (gpsd-py3)[https://github.com/MartijnBraam/gpsd-py3]\n\nInstallation\n------------\n\nInstall through pip::\n\n    $ pip3 install py-gpsd2\n\nUsage\n-----\n\nJust import it and poll the gps. Only a single gpsd server a time is supported::\n\n    import gpsd2\n\n    # Connect to the local gpsd\n    gpsd2.connect()\n\n    # Connect somewhere else\n    gpsd2.connect(host=\"127.0.0.1\", port=123456)\n\n    # Get gps position\n    packet = gpsd2.get_current()\n\n    # See the inline docs for GpsResponse for the available data\n    print(packet.position())\n\n\nGpsResponse Object Information\n-----\n\n### Properties ###\nDescription and information copied from [http://catb.org/gpsd/gpsd_json.html](http://catb.org/gpsd/gpsd_json.html).\n\n- **mode**\n\t- *Description:* Indicates the status of the GPS reception\n\t- *Availability:* Always\n\t- *Data Type:* Int\n\t- *Possible Values:* 0=no mode value yet seen, 1=no fix, 2=2D fix, 3=3D fix\n- **sats**\n\t- *Description:* The number of satellites received by the GPS unit\n\t- *Availability:* Always\n\t- *Data Type:* Int\n- **lat**\n\t- *Description:* Latitude in degrees\n\t- *Availability:* mode >= 2\n\t- *Data Type:*\n\t- *Possible Values:* -90.0 to 90.0\n- **lon**\n\t- *Description:* Longitude in degrees\n\t- *Availability:* mode >= 2\n\t- *Data Type:* float\n\t- *Possible Values:* -180.0 to 180.0\n- **track**\n\t- *Description:* Course over ground, degrees from true north\n\t- *Availability:* mode >= 2\n\t- *Data Type:* float\n- **hspeed**\n\t- *Description:* Speed over ground, meters per second\n\t- *Availability:* mode >= 2\n\t- *Data Type:* float\n- **time**\n\t- *Description:* Time/date stamp in ISO8601 format, UTC. May have a fractional part of up to .001sec precision May be absent if mode is not 2 or 3.\n\t- *Availability:* mode >= 2\n\t- *Data Type:* string\n\t- *Sample Value:* 2016-08-05T01:51:44.000Z\n- **error**\n\t- *Description:* Error information \n\t\t- c - ecp: Climb/sink error estimate in meters/sec, 95% confidence.\n\t\t- s - eps: Speed error estinmate in meters/sec, 95% confidence.\n\t\t- t - ept: Estimated timestamp error (%f, seconds, 95% confidence). Present if time is present.\n\t\t- v - epv: Estimated vertical error in meters, 95% confidence. Present if mode is 3 and DOPs can be calculated from the satellite view.\n\t\t- x - epx: Longitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.\n\t\t- y - epy: Latitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.\n\t- *Availability:* mode >= 2 *(**NOTE:** c & v require mode >= 3)*\n\t- *Data Type:* dictionary\n\t- *Possible Values:*\n- **alt**\n\t- *Description:* Altitude in meters\n\t- *Availability:* mode >= 3\n\t- *Data Type:* float\n- **climb**\n\t- *Description:* Climb (positive) or sink (negative) rate, meters per second\n\t- *Availability:* mode >= 3\n\t- *Data Type:* float\n\n### Methods ###\n- **position**\n\t- *Description:* Get the latitude and longtitude as tuple\n\t- *Availability:* mode >= 2\n\t- *Parameters:* None\n\t- *Return Type:* tuple (latitude, longitude)\n\t- *Sample Value:*  (39.8333333, -98.585522)\n- **speed**\n\t- *Description:* Get the horisontal speed with the small movements filtered out\n\t- *Availability:* mode >= 2\n\t- *Parameters:* None\n\t- *Return Type:* float\n- **position_precision**\n\t- *Description:* Get the error margin in meters for the current fix\n\t- *Availability:* mode >= 2\n\t- *Parameters:* None\n\t- *Return Type:* tuple (x-y plane, z direction)\n- **get_time(local_time: bool)**\n\t- *Description:* Get the GPS time in UTC or in local timezone\n\t- *Availability:* mode >= 2\n\t- *Parameters:* local_time\n\t- *Return Type:* datetime\n- **map_url**\n\t- *Description:* Get a openstreetmap url for the current position\n\t- *Availability:* mode >= 2\n\t- *Parameters:* None\n\t- *Return Type:* string\n\t- *Sample Value:* http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15\n- **altitude**\n\t- *Description:* Get the altitude in meters\n\t- *Availability:* mode >= 3\n\t- *Parameters:* None\n\t- *Return Type:* float\n- **movement**\n\t- *Description:* Get the speed and direction of the current movement as dict\n\t- *Availability:* mode >= 3\n\t- *Parameters:* None\n\t- *Return Type:* dictionary\n\t\t- speed\n\t\t- track\n\t\t- climb\n- **speed_vertical**\n\t- *Description:* Get the vertical speed with the small movements filtered out\n\t- *Availability:* mode >= 3\n\t- *Parameters:* None\n\t- *Return Type:* float\n\n\nException Information\n-----\n\n- NoFixError: Raised when a value is requested with the mode below the threshold for obtaining the data\n\t- Needs at least 2D fix\n\t- Needs at least 3D fix\n- General Exceptions\n\t- Unexpected message received from gps: ...\n\t- Unexpected data received as welcome. Is the server a gpsd 3 server?\n\n\nInformation on Available Functions\n-----\n\n- **connect**\n\t- *Description:* Connect to a GPSD instance\n\t- *Parameters:* host=\"127.0.0.1\", port=2947\n\t- *Return Type:* None\n- **get_current**\n\t- *Description:* Poll gpsd for a new position\n\t- *Parameters:* None\n\t- *Return Type:* GpsResponse Object\n- **device**\n\t- *Description:* Get information about current gps device\n\t- *Parameters:* None\n\t- *Return Type:* dictionary\n\t\t- path\n\t\t- speed\n\t\t- driver\n\t- *Sample Data:* {'speed': 9600, 'path': '/dev/ttyS0', 'driver': 'MTK-3301'}\n\n\n----------\n\n## Sample Code ##\n\n```python\n#!/usr/bin/env python3\n\nimport gpsd\n\n# Connect to the local gpsd\ngpsd.connect()\n\n# Connect somewhere else\ngpsd.connect(host=\"127.0.0.1\", port=123456)\n\n# Get gps position\npacket = gpsd.get_current()\n\n# See the inline docs for GpsResponse for the available data\nprint(\" ************ PROPERTIES ************* \")\nprint(\"  Mode: \" + str(packet.mode))\nprint(\"Satellites: \" + str(packet.sats))\nif packet.mode >= 2:\nprint(\"  Latitude: \" + str(packet.lat))\nprint(\" Longitude: \" + str(packet.lon))\nprint(\" Track: \" + str(packet.track))\nprint(\"  Horizontal Speed: \" + str(packet.hspeed))\nprint(\" Time: \" + str(packet.time))\nprint(\" Error: \" + str(packet.error))\nelse:\nprint(\"  Latitude: NOT AVAILABLE\")\nprint(\" Longitude: NOT AVAILABLE\")\nprint(\" Track: NOT AVAILABLE\")\nprint(\"  Horizontal Speed: NOT AVAILABLE\")\nprint(\" Error: NOT AVAILABLE\")\n\nif packet.mode >= 3:\nprint(\"  Altitude: \" + str(packet.alt))\nprint(\" Climb: \" + str(packet.climb))\nelse:\nprint(\"  Altitude: NOT AVAILABLE\")\nprint(\" Climb: NOT AVAILABLE\")\n\nprint(\" ************** METHODS ************** \")\nif packet.mode >= 2:\nprint(\"  Location: \" + str(packet.position()))\nprint(\" Speed: \" + str(packet.speed()))\nprint(\"Position Precision: \" + str(packet.position_precision()))\nprint(\"  Time UTC: \" + str(packet.time_utc()))\nprint(\"Time Local: \" + str(packet.time_local()))\nprint(\"   Map URL: \" + str(packet.map_url()))\nelse:\nprint(\"  Location: NOT AVAILABLE\")\nprint(\" Speed: NOT AVAILABLE\")\nprint(\"Position Precision: NOT AVAILABLE\")\nprint(\"  Time UTC: NOT AVAILABLE\")\nprint(\"Time Local: NOT AVAILABLE\")\nprint(\"   Map URL: NOT AVAILABLE\")\n\nif packet.mode >= 3:\nprint(\"  Altitude: \" + str(packet.altitude()))\n# print(\"  Movement: \" + str(packet.movement()))\n# print(\"  Speed Vertical: \" + str(packet.speed_vertical()))\nelse:\nprint(\"  Altitude: NOT AVAILABLE\")\n# print(\"  Movement: NOT AVAILABLE\")\n# print(\" Speed Vertical: NOT AVAILABLE\")\n\nprint(\" ************* FUNCTIONS ************* \")\nprint(\"Device: \" + str(gpsd.device()))\n```\n\n\n### Sample Output ###\n```\n     ************ PROPERTIES *************\n                  Mode: 3\n            Satellites: 10\n              Latitude: 39.8333333\n             Longitude: -98.585522\n                 Track: 237.31\n      Horizontal Speed: 0.0\n                  Time: 2016-08-05T03:02:13.000Z\n                 Error: {'v': 31.97, 't': 0.005, 'x': 10.055, 'c': (63.94,), 's': 35 .16, 'y': 17.58}\n              Altitude: 100.3\n                 Climb: 0.0\n     ************** METHODS **************\n               Location: (39.8333333, -98.585522)\n                  Speed: 0\n     Position Precision: (17.58, 31.97)\n               Time UTC: 2016-08-05 03:02:13\n             Time Local: 2016-08-04 23:02:13-04:00\n                Map URL: http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15\n               Altitude: 100.3\n     ************* FUNCTIONS *************\n                 Device: {'driver': 'MTK-3301', 'path': '/dev/ttyS0', 'speed': 9600}\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python 3 library for working with gpsd",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/hatsunearu/py-gpsd2/issues",
        "Homepage": "https://github.com/hatsunearu/py-gpsd2"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca845bc6151b790a29d716731c627554933d32d773bdd3cc18c0684d46a362d1",
                "md5": "73c63bc9e084c4acb247b3b17f9d57ac",
                "sha256": "218f75e92b46eb38c1c6cc7858c8ec665d4770371c99edfeed3d3bfa9a8b95d3"
            },
            "downloads": -1,
            "filename": "py_gpsd2-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73c63bc9e084c4acb247b3b17f9d57ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8023,
            "upload_time": "2023-05-15T01:35:12",
            "upload_time_iso_8601": "2023-05-15T01:35:12.263525Z",
            "url": "https://files.pythonhosted.org/packages/ca/84/5bc6151b790a29d716731c627554933d32d773bdd3cc18c0684d46a362d1/py_gpsd2-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9ddc03125ecf40af5855b4d3c4c8197c6eb31e6c190a408e05a9d8725521968e",
                "md5": "ff948a69d93b57f300abca7261280747",
                "sha256": "4d0fed77c646bb85944145eda747a0caa2fcc2a1779daf3d4df9e3e6a384ab62"
            },
            "downloads": -1,
            "filename": "py_gpsd2-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ff948a69d93b57f300abca7261280747",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7257,
            "upload_time": "2023-05-15T01:35:14",
            "upload_time_iso_8601": "2023-05-15T01:35:14.202626Z",
            "url": "https://files.pythonhosted.org/packages/9d/dc/03125ecf40af5855b4d3c4c8197c6eb31e6c190a408e05a9d8725521968e/py_gpsd2-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-15 01:35:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hatsunearu",
    "github_project": "py-gpsd2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py-gpsd2"
}
        
Elapsed time: 0.07896s