How to use the geoalchemy2.Geography function in GeoAlchemy2

To help you get started, we’ve selected a few GeoAlchemy2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geoalchemy / geoalchemy2 / tests / test_functional.py View on Github external
class Lake(Base):
    __tablename__ = 'lake'
    __table_args__ = {'schema': 'gis'}
    id = Column(Integer, primary_key=True)
    geom = Column(Geometry(geometry_type='LINESTRING', srid=4326))

    def __init__(self, geom):
        self.geom = geom


class Poi(Base):
    __tablename__ = 'poi'
    __table_args__ = {'schema': 'gis'}
    id = Column(Integer, primary_key=True)
    geom = Column(Geometry(geometry_type='POINT', srid=4326))
    geog = Column(Geography(geometry_type='POINT', srid=4326))

    def __init__(self, geog):
        self.geog = geog


class Summit(Base):
    __tablename__ = 'summit'
    __table_args__ = {'schema': 'gis'}
    id = Column(Integer, primary_key=True)
    geom = Column(Geometry(
        geometry_type='POINT', srid=4326, management=True))

    def __init__(self, geom):
        self.geom = geom
github geoalchemy / geoalchemy2 / tests / test_functional.py View on Github external
def test_ST_Distance_type_coerce(self):
        poi_id = self._create_one_poi()
        poi = session.query(Poi) \
            .filter(Poi.geog.ST_Distance(
                type_coerce('POINT(5 45)', Geography)) < 1000).one()
        assert poi.id == poi_id
github ibis-project / ibis / ibis / sql / alchemy.py View on Github external
# supports timezones.
        return sa.TIMESTAMP(bool(itype.timezone))
    elif isinstance(itype, dt.Array):
        ibis_type = itype.value_type
        if not isinstance(ibis_type, (dt.Primitive, dt.String)):
            raise TypeError(
                'Type {} is not a primitive type or string type'.format(
                    ibis_type
                )
            )
        return sa.ARRAY(_to_sqla_type(ibis_type, type_map=type_map))
    elif geospatial_supported and isinstance(itype, dt.GeoSpatial):
        if itype.geotype == 'geometry':
            return ga.Geometry
        elif itype.geotype == 'geography':
            return ga.Geography
        else:
            return ga.types._GISType
    else:
        return type_map[type(itype)]
github cryptoparty / cryptoparty.in / cryptoparty / model.py View on Github external
self.position = wkt_pos
        self.confirmed = False
        self.confirmation_token = random_string(length=42)

    def confirm(self, token):
        if self.confirmed:
            raise ValueError('Party already confirmed')
        if self.confirmation_token == token:
            self.confirmed = True


class Subscription(Base):
    __tablename__ = 'Subscriptions'
    id = Column(Integer, primary_key=True)
    email = Column(String)
    position = Column(Geography('POINT', srid=4326))
    confirmed = Column(Boolean)
    confirmation_token = Column(String)

    def __init__(self, email, lat, lon):
        self.email = email
        self.confirmed = False
        wkt_pos = "POINT(%f %f)" % (lon, lat)
        self.position = wkt_pos
        self.confirmation_token = random_string(length=43)

    def confirm(self, token):
        if self.confirmed:
            raise ValueError('Party already confirmed')
        if self.confirmation_token == token:
            self.confirmed = True
github GIScience / openpoiservice / openpoiservice / server / db_import / models.py View on Github external
from openpoiservice.server import db, ops_settings
from geoalchemy2 import Geography
import logging

logger = logging.getLogger(__name__)


class Pois(db.Model):
    __tablename__ = ops_settings['provider_parameters']['table_name']
    logger.info('table name for pois: {}'.format(__tablename__))

    uuid = db.Column(db.LargeBinary, primary_key=True)
    osm_id = db.Column(db.BigInteger, nullable=False, index=True)
    osm_type = db.Column(db.Integer, nullable=False)
    # address = db.Column(db.Text, nullable=True)
    geom = db.Column(Geography(geometry_type="POINT", srid=4326, spatial_index=True), nullable=False)

    tags = db.relationship("Tags", backref='{}'.format(ops_settings['provider_parameters']['table_name']),
                           lazy='dynamic')

    categories = db.relationship("Categories", backref='{}'.format(ops_settings['provider_parameters']['table_name']),
                                 lazy='dynamic')

    def __repr__(self):
        return '' % self.osm_id


class Categories(db.Model):
    __tablename__ = ops_settings['provider_parameters']['table_name'] + "_categories"
    logger.info('Table name for categories: {}'.format(__tablename__))

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)