-def assert_db_column(row, column, value, context):
- if column == 'object':
- return
-
- if column.startswith('centroid'):
- if value == 'in geometry':
- query = """SELECT ST_Within(ST_SetSRID(ST_Point({}, {}), 4326),
- ST_SetSRID('{}'::geometry, 4326))""".format(
- row['cx'], row['cy'], row['geomtxt'])
- cur = context.db.cursor()
- cur.execute(query)
- assert cur.fetchone()[0], "(Row %s failed: %s)" % (column, query)
- else:
- fac = float(column[9:]) if column.startswith('centroid*') else 1.0
- x, y = value.split(' ')
- assert Almost(float(x) * fac) == row['cx'], "Bad x coordinate"
- assert Almost(float(y) * fac) == row['cy'], "Bad y coordinate"
- elif column == 'geometry':
- geom = context.osm.parse_geometry(value, context.scene)
- cur = context.db.cursor()
- query = "SELECT ST_Equals(ST_SnapToGrid(%s, 0.00001, 0.00001), ST_SnapToGrid(ST_SetSRID('%s'::geometry, 4326), 0.00001, 0.00001))" % (
- geom, row['geomtxt'],)
- cur.execute(query)
- assert cur.fetchone()[0], "(Row %s failed: %s)" % (column, query)
- elif value == '-':
- assert row[column] is None, "Row %s" % column
- else:
- assert value == str(row[column]), \
- "Row '%s': expected: %s, got: %s" % (column, value, str(row[column]))
-
-