{ "info": { "author": "Yang Liu", "author_email": "gloolar@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n ____ _______ ___________ ____ ____ ______\n / __ \\/ ___/ / / / ___/ __ \\/ __ \\/ __ `/ ___/\n / /_/ (__ ) /_/ / /__/ /_/ / /_/ / /_/ / /\n / .___/____/\\__, /\\___/\\____/ .___/\\__, /_/\n /_/ /____/ /_/ /____/\n\n[![PyPI](https://img.shields.io/pypi/v/psycopgr.svg)](https://pypi.org/project/psycopgr/)\n[![PyPI - License](https://img.shields.io/pypi/l/psycopgr.svg)](https://pypi.org/project/psycopgr/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/psycopgr.svg)\n\n`psycopgr` is a Python wrapper of [pgRouting](http://pgrouting.org/) with one purpose:\n\n**Computing routes on real map for humans.**\n\nTested with\n\n- Python 3.6.5\n- PostgreSQL 11.2\n- PostGIS 2.5.2\n- pgRouting 2.6.2\n- osm2pgrouting 2.3.6\n\n## Preparation \n\n- Install `PostgreSQL`, `PostGIS`, and `pgRouting`\n- Create database to store map data\n- Import OpenStreet map data into database\n\nA step by step note can be found [here](https://herrkaefer.com/2016/08/30/pgrouting-notes/).\n\n## Installation\n\n```sh\npip install psycopgr\n```\n\nor\n\n```sh\npipenv install psycopgr\n```\n\n## Routing with Python!\n\nFirst,\n\n```python\nfrom psycopgr import PgrNode, PGRouting\n```\n\nCreate an PGRouting instance with database connection:\n\n```python\npgr = PGRouting(database='mydb', user='user')\n```\n\nAdjust meta datas of tables including the edge table properies if they are different from the default (only the different properties needs to be set), e.g.:\n\n```python\npgr.set_meta_data(cost='cost_s', reverse_cost='reverse_cost_s', directed=true)\n```\n\nThis is the default meta data:\n\n```python\n{\n 'table': 'ways',\n 'id': 'gid',\n 'source': 'source',\n 'target': 'target',\n 'cost': 'cost_s', # driving time in second\n 'reverse_cost': 'reverse_cost_s', # reverse driving time in second\n 'x1': 'x1',\n 'y1': 'y1',\n 'x2': 'x2',\n 'y2': 'y2',\n 'geometry': 'the_geom',\n 'has_reverse_cost': True,\n 'directed': True,\n 'srid': 4326\n}\n```\n\nNodes are points on map which are represented by `PgrNode` namedtuple with geographic coordinates (longitude and latitude) rather than vague vertex id (vid) in the tables. `PgrNodes` is defined as:\n\n```python\nPgrNode = namedtuple('PgrNode', ['id', 'lon', 'lat'])\n```\n\nin which `id` could be `None` or self-defined value, and `lon` and `lat` are double precision values. \n\nFor example:\n\n```python\nnodes = [PgrNode(None, 116.30150, 40.05500),\n PgrNode(None, 116.36577, 40.00253),\n PgrNode(None, 116.30560, 39.95458),\n PgrNode(None, 116.46806, 39.99857)]\n```\n\nNow we can do routings! This is really straightforward:\n\n```python\n# many-to-many\nroutings = pgr.get_routes(nodes, nodes, end_speed=5.0, pgx_file='r.pgx')\n# one-to-one\nroutings = pgr.get_routes(nodes[0], nodes[1])\n# one-to-many\nroutings = pgr.get_routes(nodes[0], nodes)\n# many-to-one\nroutings = pgr.get_routes(nodes, node[2])\n```\n\n- `end_speed`: speed from node to nearest vertices on ways in unit km/h.\n- `gpx_file`: set it to output paths to a gpx file.\n\nThe returned is a dict of dict: `{(start_node, end_node): {'path': [PgrNode], 'cost': cost}`\n\nBy default, `cost` is traveling time along the path in unit second. It depends on the means of columns of the edge table that you set as `cost` and `reverse_cost`. You can assign the relations by `set_meta_data` function.\n\nWe can also get only costs without detailed paths returned:\n\n```python\ncosts = pgr.get_costs(nodes, nodes)\n```\n\nThe returned is also a dict: `{(start_node, end_node): cost}`\n\n## Low-level wrapper of pgRouting functions\n\n| psycopgr function | pgRouting function |\n| :---------------- | :----------------- |\n| dijkstra | pgr_dijkstra |\n| dijkstra_cost | pgr_dijkstraCost |\n| astar | pgr_astar |\n\nThese are direct wrappings of pgRouting functions. For example, `dijkstra` takes vertex ids as input. This list may be extended in the future.\n\n## Tutorial\n\nHere is a [tutorial](https://herrkaefer.com/2016/09/01/psycopgr-tutorial/).\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/herrkaefer/psycopgr", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "psycopgr", "package_url": "https://pypi.org/project/psycopgr/", "platform": "", "project_url": "https://pypi.org/project/psycopgr/", "project_urls": { "Homepage": "https://github.com/herrkaefer/psycopgr" }, "release_url": "https://pypi.org/project/psycopgr/1.0.6/", "requires_dist": [ "psycopg2" ], "requires_python": ">=2.7", "summary": "A Python wrapper of pgRouting for routing from nodes to nodes on real map.", "version": "1.0.6" }, "last_serial": 5282813, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "85af0b3adf1dfd5015cb7a6620936989", "sha256": "9dcb02c5790e24b134a3e64b6c1c63a1bf9fd7da3778514ca899644e3eb91f18" }, "downloads": -1, "filename": "psycopgr-1.0.1.tar.gz", "has_sig": false, "md5_digest": "85af0b3adf1dfd5015cb7a6620936989", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6140, "upload_time": "2017-11-17T07:29:15", "url": "https://files.pythonhosted.org/packages/50/d3/4b3aac7f90f26cac7682891d68620a5f64afb04dd384493f346d0e4b92b3/psycopgr-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "d77e496bc0a968aa3c36da94f6f1365d", "sha256": "2dedef4519d4967228af6de9325a01f97657500a683a2ebb396fdc6029ba0cc9" }, "downloads": -1, "filename": "psycopgr-1.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d77e496bc0a968aa3c36da94f6f1365d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 7286, "upload_time": "2019-04-29T21:03:26", "url": "https://files.pythonhosted.org/packages/80/68/858f23b7f8f41c5a056880419617a410ea3664f8d630b6f21a86d9e0d61f/psycopgr-1.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa7db2ad1b2ecccc801ccbd3f7ad38fa", "sha256": "30df5d6014960b7f98c2134500f75b8ebf1e302cccb04c541c14ecb906aefd3e" }, "downloads": -1, "filename": "psycopgr-1.0.2.tar.gz", "has_sig": false, "md5_digest": "aa7db2ad1b2ecccc801ccbd3f7ad38fa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 7177, "upload_time": "2019-04-29T21:03:31", "url": "https://files.pythonhosted.org/packages/f1/01/dd3ad2098c94fe6526526dea975efeecd585513a239552062be627cd5d4f/psycopgr-1.0.2.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "0749ebd674644c47ca6af0c25c4088ba", "sha256": "a4d5342314d3b13b172f44caba91c867dad30dcbf33226246836067d9eefd978" }, "downloads": -1, "filename": "psycopgr-1.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0749ebd674644c47ca6af0c25c4088ba", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 6798, "upload_time": "2019-05-04T21:12:33", "url": "https://files.pythonhosted.org/packages/24/41/90f0fced8a51ba0aaee060ca43374a935499c231e808767453a4b1d50117/psycopgr-1.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c5bc8fd50d3141c5f0524685100860f5", "sha256": "bc6a8055c5769ad734557eab528f0b61a732aa26cacad1aab5d20639417f0973" }, "downloads": -1, "filename": "psycopgr-1.0.4.tar.gz", "has_sig": false, "md5_digest": "c5bc8fd50d3141c5f0524685100860f5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 6602, "upload_time": "2019-05-04T21:12:34", "url": "https://files.pythonhosted.org/packages/cf/13/778eb84aebfbc64dfa069f2a80d4c91c76319ef9209a4933f53216363b3f/psycopgr-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "3264efef8142d3308a034f53a5998a1a", "sha256": "671001496149c3e102a5eebe32c4b6fddde60b10fcba040aa33e45c30a43cbcf" }, "downloads": -1, "filename": "psycopgr-1.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3264efef8142d3308a034f53a5998a1a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 6968, "upload_time": "2019-05-04T22:25:23", "url": "https://files.pythonhosted.org/packages/ff/a3/ebe4a46485a3c7b9a279f35e3a883771e348ea9fc8986fe52135eb333e1d/psycopgr-1.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3ae502adef8d3b10523a1ab2d12935f", "sha256": "b5740c4b8c3c8448c1bd0e1af17acb20d8885323f8f8bc458582a32a964327f5" }, "downloads": -1, "filename": "psycopgr-1.0.5.tar.gz", "has_sig": false, "md5_digest": "f3ae502adef8d3b10523a1ab2d12935f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 6759, "upload_time": "2019-05-04T22:25:24", "url": "https://files.pythonhosted.org/packages/11/0d/35126fded9c4171904f2d6706d2a8c3e810e17d936a53854cbab01ed2c0f/psycopgr-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "bc0cdba8c074bfb17ffa320c6a4aa9fb", "sha256": "6b57cfd427627ad78c0f1bedc62d9b9202794719841a4a8c5faf13111ed3135d" }, "downloads": -1, "filename": "psycopgr-1.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bc0cdba8c074bfb17ffa320c6a4aa9fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 8504, "upload_time": "2019-05-17T15:44:44", "url": "https://files.pythonhosted.org/packages/5f/3b/2ead8c7a6e27b912d15d91524fbf24bc587dba62942c190dec96afb20e1c/psycopgr-1.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "53373279bbed2424083b4fcdb1c270f3", "sha256": "108e4d0235a79cc50416fdc1f575b9730221c82c0f91a169e2c008af0cd2f93c" }, "downloads": -1, "filename": "psycopgr-1.0.6.tar.gz", "has_sig": false, "md5_digest": "53373279bbed2424083b4fcdb1c270f3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 8443, "upload_time": "2019-05-17T15:44:46", "url": "https://files.pythonhosted.org/packages/ee/72/07bc65cc0d3bd230490d4930bde635bb90f1ad89b0cab940967c634d2f7c/psycopgr-1.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bc0cdba8c074bfb17ffa320c6a4aa9fb", "sha256": "6b57cfd427627ad78c0f1bedc62d9b9202794719841a4a8c5faf13111ed3135d" }, "downloads": -1, "filename": "psycopgr-1.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bc0cdba8c074bfb17ffa320c6a4aa9fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 8504, "upload_time": "2019-05-17T15:44:44", "url": "https://files.pythonhosted.org/packages/5f/3b/2ead8c7a6e27b912d15d91524fbf24bc587dba62942c190dec96afb20e1c/psycopgr-1.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "53373279bbed2424083b4fcdb1c270f3", "sha256": "108e4d0235a79cc50416fdc1f575b9730221c82c0f91a169e2c008af0cd2f93c" }, "downloads": -1, "filename": "psycopgr-1.0.6.tar.gz", "has_sig": false, "md5_digest": "53373279bbed2424083b4fcdb1c270f3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 8443, "upload_time": "2019-05-17T15:44:46", "url": "https://files.pythonhosted.org/packages/ee/72/07bc65cc0d3bd230490d4930bde635bb90f1ad89b0cab940967c634d2f7c/psycopgr-1.0.6.tar.gz" } ] }