|
@ -169,7 +169,40 @@ class TestExample(DbTest): |
|
|
os.path.join(PATH_TO_SQL_DIR, "japan_segments.sql") |
|
|
os.path.join(PATH_TO_SQL_DIR, "japan_segments.sql") |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Taking this task very literally and using the GeoJSON |
|
|
|
|
|
# directly with PostGIS `ST_GeomFromGeoJSON` |
|
|
sql = """ |
|
|
sql = """ |
|
|
|
|
|
SELECT id FROM japan_segments |
|
|
|
|
|
WHERE ST_Within( |
|
|
|
|
|
bounds, |
|
|
|
|
|
ST_SetSRID(ST_GeomFromGeoJSON('{ |
|
|
|
|
|
"type": "Polygon", |
|
|
|
|
|
"coordinates": [ |
|
|
|
|
|
[ |
|
|
|
|
|
[ |
|
|
|
|
|
130.27313232421875, |
|
|
|
|
|
30.519681272749402 |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
131.02020263671875, |
|
|
|
|
|
30.519681272749402 |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
131.02020263671875, |
|
|
|
|
|
30.80909017893796 |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
130.27313232421875, |
|
|
|
|
|
30.80909017893796 |
|
|
|
|
|
], |
|
|
|
|
|
[ |
|
|
|
|
|
130.27313232421875, |
|
|
|
|
|
30.519681272749402 |
|
|
|
|
|
] |
|
|
|
|
|
] |
|
|
|
|
|
] |
|
|
|
|
|
}'), 4326) |
|
|
|
|
|
); |
|
|
""" |
|
|
""" |
|
|
with conn.cursor(cursor_factory=RealDictCursor) as cur: |
|
|
with conn.cursor(cursor_factory=RealDictCursor) as cur: |
|
|
cur.execute(sql) |
|
|
cur.execute(sql) |
|
|