cubicweb-postgis


Namecubicweb-postgis JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-postgis
SummaryTest for postgis
upload_time2023-07-12 10:35:37
maintainer
docs_urlNone
authorLOGILAB S.A. (Paris, FRANCE)
requires_python>=2.7
licenseLGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Summary
-------

Add types and functions to work with geometric attributes that are stored in a
Postgis database (that is a PostgreSQL database with Postgis extension
enabled).

The present cube supports only version *2.0 and later* of Postgis.

It introduces one new type when defining attributes in the data model schema:

* a ``Geometry`` type. Additionally, you should give the following elements
  along with a `Geometry` attribute:

  * ``geom_type``. The Postgis type of geometries that this attribute will
    accept, for example ``POINT``, ``MULTILINESTRING`` or ``POLYGON``,

  * ``srid``. The spatial reference system the geometry coordinates will live
    in. This is an integer and a foreign key that must match the ``srid`` key
    in the ``spatial_ref_sys`` table. Most of the time, it will be the same as
    the spatial system EPSG code,

  * ``coord_dimension``. The number of dimensions used by geometries. Defaults
    to 2.

* a ``Geography`` type (see the description_).

.. _description: https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_Geography


Then you can also use geometric functions like ``ST_INTERSECTS``, ``ST_WITHIN``
or ``ST_UNION`` to work with this new type.

See `Postgis manual`_ for reference documentation about Postgis.

.. _Postgis manual: http://postgis.net/docs/


Example
-------

In ``schema.py``, one can declare a ``City`` entity like the following.

.. code-block:: python

    class City(EntityType):
        name = String(required=True)
        geometry = Geometry(geom_type='POLYGON', srid=4326)

You may then make queries like:

.. code-block:: python

   # get all cities in a given bounding box
   rql('City C WHERE C geometry G HAVING(ST_WITHIN(G, ST_MAKEENVELOPE('
       '%(left)s, %(bottom)s, %(right)s, %(top)s, 4326)) = TRUE)',
	   {'left': 2.2,
	   'right': 2.6,
	   'top': 49,
	   'bottom': 48})

   # get all cities at a given distance from a point, sorted by distance
   rql('Any C, ST_DISTANCE(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326)) '
       'ORDERBY 5 WHERE '
	   'C geometry G HAVING ('
	   ' ST_DWITHIN(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326), 0.1) = TRUE)')

            

Raw data

            {
    "_id": null,
    "home_page": "https://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-postgis",
    "name": "cubicweb-postgis",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "LOGILAB S.A. (Paris, FRANCE)",
    "author_email": "contact@logilab.fr",
    "download_url": "https://files.pythonhosted.org/packages/9d/5e/57758dfb451cd73874341dab68e0ab17c217be196fcea0672875489e8c85/cubicweb-postgis-1.0.0.tar.gz",
    "platform": null,
    "description": "Summary\n-------\n\nAdd types and functions to work with geometric attributes that are stored in a\nPostgis database (that is a PostgreSQL database with Postgis extension\nenabled).\n\nThe present cube supports only version *2.0 and later* of Postgis.\n\nIt introduces one new type when defining attributes in the data model schema:\n\n* a ``Geometry`` type. Additionally, you should give the following elements\n  along with a `Geometry` attribute:\n\n  * ``geom_type``. The Postgis type of geometries that this attribute will\n    accept, for example ``POINT``, ``MULTILINESTRING`` or ``POLYGON``,\n\n  * ``srid``. The spatial reference system the geometry coordinates will live\n    in. This is an integer and a foreign key that must match the ``srid`` key\n    in the ``spatial_ref_sys`` table. Most of the time, it will be the same as\n    the spatial system EPSG code,\n\n  * ``coord_dimension``. The number of dimensions used by geometries. Defaults\n    to 2.\n\n* a ``Geography`` type (see the description_).\n\n.. _description: https://postgis.net/docs/using_postgis_dbmanagement.html#PostGIS_Geography\n\n\nThen you can also use geometric functions like ``ST_INTERSECTS``, ``ST_WITHIN``\nor ``ST_UNION`` to work with this new type.\n\nSee `Postgis manual`_ for reference documentation about Postgis.\n\n.. _Postgis manual: http://postgis.net/docs/\n\n\nExample\n-------\n\nIn ``schema.py``, one can declare a ``City`` entity like the following.\n\n.. code-block:: python\n\n    class City(EntityType):\n        name = String(required=True)\n        geometry = Geometry(geom_type='POLYGON', srid=4326)\n\nYou may then make queries like:\n\n.. code-block:: python\n\n   # get all cities in a given bounding box\n   rql('City C WHERE C geometry G HAVING(ST_WITHIN(G, ST_MAKEENVELOPE('\n       '%(left)s, %(bottom)s, %(right)s, %(top)s, 4326)) = TRUE)',\n\t   {'left': 2.2,\n\t   'right': 2.6,\n\t   'top': 49,\n\t   'bottom': 48})\n\n   # get all cities at a given distance from a point, sorted by distance\n   rql('Any C, ST_DISTANCE(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326)) '\n       'ORDERBY 5 WHERE '\n\t   'C geometry G HAVING ('\n\t   ' ST_DWITHIN(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326), 0.1) = TRUE)')\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Test for postgis",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-postgis"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "169f36e1bf39f44dbb03add439d19266fcef3c0d712cb1e782bc61fca526be31",
                "md5": "f6ace58494be701eafe8ed0207e8ecfe",
                "sha256": "8b3a43af3831fb1b8efd9bb0b147d2d0ee32b9c5aeb242244fc9f7a487780fd6"
            },
            "downloads": -1,
            "filename": "cubicweb_postgis-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f6ace58494be701eafe8ed0207e8ecfe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7",
            "size": 9628,
            "upload_time": "2023-07-12T10:35:33",
            "upload_time_iso_8601": "2023-07-12T10:35:33.224672Z",
            "url": "https://files.pythonhosted.org/packages/16/9f/36e1bf39f44dbb03add439d19266fcef3c0d712cb1e782bc61fca526be31/cubicweb_postgis-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d5e57758dfb451cd73874341dab68e0ab17c217be196fcea0672875489e8c85",
                "md5": "e8dbffdd78069efeb86cef0396a233fc",
                "sha256": "72d13c433500cbda1b3ba608e7c17371fb95c2a220afcd69d44311e94e998863"
            },
            "downloads": -1,
            "filename": "cubicweb-postgis-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e8dbffdd78069efeb86cef0396a233fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 10037,
            "upload_time": "2023-07-12T10:35:37",
            "upload_time_iso_8601": "2023-07-12T10:35:37.090633Z",
            "url": "https://files.pythonhosted.org/packages/9d/5e/57758dfb451cd73874341dab68e0ab17c217be196fcea0672875489e8c85/cubicweb-postgis-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-12 10:35:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cubicweb-postgis"
}
        
Elapsed time: 7.10134s