def get(self, id):
     objectTrajactory = ObjectTrajactoryModel.query.get(id)
     importantRegions = ImportantRegion.query.filter(
         func.ST_Intersects(ImportantRegion.geom,
                            objectTrajactory.gps_line)).all()
     result = objectTrajactory.dictRepr()
     result["important_regions"] = [r.dictRepr() for r in importantRegions]
     return result, 200
Exemple #2
0
 def bboxIntersects(cls, bbox, fromSrid=4326, toSrid=4326):
     bboxGeom = shapelyBBox(bbox)
     wkbGeometry = WKBElement(buffer(bboxGeom.wkb), fromSrid)
     if fromSrid != toSrid:
         wkbGeometry = func.ST_Transform(wkbGeometry, toSrid)
     geomColumn = cls.geometryColumn()
     return and_(geomColumn.intersects(wkbGeometry),
                 func.ST_Intersects(geomColumn, wkbGeometry))
def get_grid_datas(id_area, buffer, grid):
    """Get one enabled municipality by insee code
        ---
        tags:
          - Reférentiel géo
        parameters:
          - name: insee
            in: path
            type: string
            required: true
            default: none
            properties:
              area_name:
                type: string
                description: Municipality name
              area_code:
                type: string
                description: Municipality insee code
              geometry:
                type: geometry
        responses:
          200:
            description: A municipality
        """
    try:
        qarea = LAreas.query.filter(LAreas.id_area == id_area)
        area = qarea.one()
        qgrid = MVTerritoryGeneralStats.query.filter(
            MVTerritoryGeneralStats.type_code == grid
        ).filter(
            func.ST_Intersects(
                MVTerritoryGeneralStats.geom_local, func.ST_Buffer(area.geom, buffer),
            )
        )
        datas = qgrid.all()
        features = []
        for d in datas:
            features.append(d.as_geofeature("geom_4326", "id_area"))
        return FeatureCollection(features)
    except Exception as e:
        current_app.logger.error("<get_grid_datas> ERROR:", e)
        return {"Error": str(e)}, 400
Exemple #4
0
 def geom_intersects(cls, geometry, srid):
     wkb_geometry = _wrap_wkb_geometry(geometry, srid)
     geom_column = cls.geometry_column()
     return func.ST_Intersects(
         geom_column, transform_geometry(geom_column, wkb_geometry, srid))
Exemple #5
0
from sqlalchemy import and_
from itertools import chain
from multiprocessing import Pool, cpu_count, Process
from numpy import mean
from itertools import groupby

# DATA IMPORT
###############################################################################

print("Database connection established.")

# import white area including coastdat id
ww_isection = session.query(CosmoClmGrid.gid,
                            func.ST_Intersection(CosmoClmGrid.geom,
                                            GeoPotArea.geom)).\
    filter(func.ST_Intersects(GeoPotArea.geom, CosmoClmGrid.geom))

ww_isection = [(wid, loads(bytes(geom.data))) for wid, geom in ww_isection]

# import grid districts
gds = session.query(GridDistrict.subst_id,
                    func.ST_Transform(GridDistrict.geom, 4326))
gds = [(sid, to_shape(geom)) for sid, geom in gds]

# import weadata data for Germany (roughly bounding box in cosmoclmgrid)
weadata = session.query(Spatial.gid, Timeseries.tsarray).\
    join(Located, Located.spatial_id == Spatial.gid).\
    join(Timeseries, Located.data_id == Timeseries.id).\
    join(Scheduled, Scheduled.data_id == Timeseries.id).\
    join(Year, Scheduled.time_id == Year.year).\
    join(Typified, Typified.data_id == Timeseries.id).\
Exemple #6
0
 def pointIntersects(cls, point, geomColumn=None, srid=4326):
     pointGeom = Point(point)
     wkbGeometry = WKBElement(buffer(pointGeom.wkb), srid)
     geomColumn = cls.geometryColumn() if geomColumn is None else geomColumn
     return func.ST_Intersects(geomColumn, wkbGeometry)