from sqlalchemy import schema
from sqlalchemy.sql import select
from sqlalchemy.sql.expression import func as sqlfunc
-import geoalchemy.functions as geofunc
from osgeo import ogr
import formencode
from wrpylib import mwdb, wrmwdb, mwmarkup, wrmwmarkup
connection.execute(wrregioncache.delete())
# Query all combinations of sledruns and regions
- sel = select([wrregion.c.id.label('region_id'), wrregion.c.border.label('border'), wrsledruncache.c.page_id, wrsledruncache.c.position_longitude, wrsledruncache.c.position_latitude], geofunc.gcontains(wrregion.c.border, sqlfunc.point(wrsledruncache.c.position_longitude, wrsledruncache.c.position_latitude)))
+ sel = select([wrregion.c.id.label('region_id'), sqlfunc.AsWKB(wrregion.c.border).label('border'), wrsledruncache.c.page_id, wrsledruncache.c.position_longitude, wrsledruncache.c.position_latitude], sqlfunc.contains(wrregion.c.border, sqlfunc.point(wrsledruncache.c.position_longitude, wrsledruncache.c.position_latitude)))
ins = wrregioncache.insert()
# Refill wrregioncache
result = connection.execute(sel)
for row in result:
point.SetPoint(0, row.position_longitude, row.position_latitude)
- if point.Within(ogr.CreateGeometryFromWkb(row.border.geom_wkb)):
+ if point.Within(ogr.CreateGeometryFromWkb(row.border)):
connection.execute(ins.values(region_id=row.region_id, page_id=row.page_id))
# commit
tables in MediaWiki easy. The module uses sqlalchemy to access the database.
"""
from sqlalchemy import Table, Column, types, schema
-from geoalchemy import GeometryExtensionColumn, MultiPolygon
def wrreport_table(metadata):
Column("id", types.Integer, primary_key=True),
Column("name", types.Unicode(50)),
Column("page_id", types.Integer),
- GeometryExtensionColumn("border", MultiPolygon(2, 4326))
+ Column("border", types.Binary) # MultiPolygon(2, 4326)
)