Skip to content

Commit 17eb085

Browse files
authored
Merge pull request #11 from OpenSidewalks/Audiom
OSW v0.2
2 parents 7842704 + b1f9f1c commit 17eb085

66 files changed

Lines changed: 14048 additions & 2216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1088 additions & 690 deletions
Large diffs are not rendered by default.

data/OSW_Validation.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import json
2+
import types
3+
import jsonschema
4+
from pathlib import Path
5+
6+
def load_file(file_path):
7+
"""Load OSW Data"""
8+
with open(file_path, 'r') as file:
9+
data = json.load(file)
10+
return data
11+
12+
def validate_osw_errors(geojson_data, schema):
13+
"""Validate OSW Data against the schema and process all errors"""
14+
validator = jsonschema.Draft7Validator(schema)
15+
errors = validator.iter_errors(geojson_data)
16+
17+
error_count = 0
18+
for error in errors:
19+
error_count = error_count + 1
20+
#format and store in file for further review
21+
print(error)
22+
23+
return error_count==0
24+
25+
workdir=".\\"
26+
schema_path = Path(workdir, "opensidewalks.schema.json")
27+
region_id = "wa.microsoft"
28+
29+
schema = load_file(schema_path)
30+
31+
graph_edges_geojson_path = Path(workdir, "data", f"{region_id}.graph.edges.OSW.geojson")
32+
graph_nodes_geojson_path = Path(workdir, "data", f"{region_id}.graph.nodes.OSW.geojson")
33+
graph_points_geojson_path = Path(workdir, "data", f"{region_id}.graph.points.OSW.geojson")
34+
graph_lines_geojson_path = Path(workdir, "data", f"{region_id}.graph.lines.OSW.geojson")
35+
graph_zones_geojson_path = Path(workdir, "data", f"{region_id}.graph.zones.OSW.geojson")
36+
graph_polygons_geojson_path = Path(workdir, "data", f"{region_id}.graph.polygons.OSW.geojson")
37+
38+
print(f"Validating OSW dataset for {region_id}")
39+
# validate edges
40+
is_valid = validate_osw_errors(load_file(graph_edges_geojson_path), schema)
41+
if is_valid:
42+
print(f"OSW edges are valid for {region_id}")
43+
else:
44+
print(f"OSW edges failed validation for {region_id}")
45+
exit(1)
46+
47+
# validate nodes
48+
is_valid = validate_osw_errors(load_file(graph_nodes_geojson_path), schema)
49+
if is_valid:
50+
print(f"OSW nodes are valid for {region_id}")
51+
else:
52+
print(f"OSW nodes failed validation for {region_id}")
53+
exit(1)
54+
55+
# validate points
56+
if graph_points_geojson_path.exists():
57+
is_valid = validate_osw_errors(load_file(graph_points_geojson_path), schema)
58+
if is_valid:
59+
print(f"OSW points are valid for {region_id}")
60+
else:
61+
print(f"OSW points failed validation for {region_id}")
62+
exit(1)
63+
64+
# validate lines
65+
if graph_lines_geojson_path.exists():
66+
is_valid = validate_osw_errors(load_file(graph_lines_geojson_path), schema)
67+
if is_valid:
68+
print(f"OSW lines are valid for {region_id}")
69+
else:
70+
print(f"OSW lines failed validation for {region_id}")
71+
exit(1)
72+
73+
# validate zones
74+
if graph_zones_geojson_path.exists():
75+
is_valid = validate_osw_errors(load_file(graph_zones_geojson_path), schema)
76+
if is_valid:
77+
print(f"OSW zones are valid for {region_id}")
78+
else:
79+
print(f"OSW zones failed validation for {region_id}")
80+
exit(1)
81+
82+
# validate polygons
83+
if graph_polygons_geojson_path.exists():
84+
is_valid = validate_osw_errors(load_file(graph_polygons_geojson_path), schema)
85+
if is_valid:
86+
print(f"OSW polygons are valid for {region_id}")
87+
else:
88+
print(f"OSW polygons failed validation for {region_id}")
89+
exit(1)

data/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Data source: washington-latest.osm.pbf, suitable for Osmium, Osmosis, imposm, osm2pgsql, mkgmap, and others. This file contains all OSM data up to 2023-08-08T20:22:00Z. File size: 250 MB; MD5 sum: 0a863d1377af9deec074380cc42529cb. [https://download.geofabrik.de/north-america/us/washington.html]. The data was narrowed down to the MultiPolygon defined in region.geojson

data/region.geojson

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"type": "FeatureCollection",
3+
"features": [
4+
{
5+
"type": "Feature",
6+
"geometry": {
7+
"type": "MultiPolygon",
8+
"coordinates": [
9+
[
10+
[
11+
[-122.1369414, 47.6365011],
12+
[-122.1431969, 47.6365115],
13+
[-122.1431951, 47.6469514],
14+
[-122.1430782, 47.6495122],
15+
[-122.1429792, 47.6495373],
16+
[-122.1405534, 47.6496913],
17+
[-122.1342967, 47.6496869],
18+
[-122.1321999, 47.6496722],
19+
[-122.1321845, 47.6496558],
20+
[-122.1321535, 47.6482983],
21+
[-122.1321166, 47.6461809],
22+
[-122.1321064, 47.6451781],
23+
[-122.1321023, 47.6446787],
24+
[-122.1321018, 47.6423675],
25+
[-122.1321109, 47.6368204],
26+
[-122.1321117, 47.6366159],
27+
[-122.1336295, 47.6365148],
28+
[-122.1369414, 47.6365011]
29+
]
30+
]
31+
]
32+
}
33+
}
34+
]
35+
}

data/wa.microsoft.graph.edges.OSW.geojson

Lines changed: 4376 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://sidewalks.washington.edu/opensidewalks/0.2/schema.json",
3+
"dataSource": {"name": "OpenStreetMap", "copyright": "https://www.openstreetmap.org/copyright", "license": "https://opendatacommons.org/licenses/odbl/1-0/"},
4+
"region": {"coordinates": [[[[-122.1369414, 47.6365011], [-122.1431969, 47.6365115], [-122.1431951, 47.6469514], [-122.1430782, 47.6495122], [-122.1429792, 47.6495373], [-122.1405534, 47.6496913], [-122.1342967, 47.6496869], [-122.1321999, 47.6496722], [-122.1321845, 47.6496558], [-122.1321535, 47.6482983], [-122.1321166, 47.6461809], [-122.1321064, 47.6451781], [-122.1321023, 47.6446787], [-122.1321018, 47.6423675], [-122.1321109, 47.6368204], [-122.1321117, 47.6366159], [-122.1336295, 47.6365148], [-122.1369414, 47.6365011]]]], "type": "MultiPolygon"},
5+
"dataTimestamp": "2023-08-08T20:22:00Z",
6+
"pipelineVersion": {"name": "OSWDataPipeline", "version": "0.2-beta", "url": "https://github.com/TaskarCenterAtUW/OSWDataPipeline/tree/v0.2-beta"},
7+
"type": "FeatureCollection",
8+
"features": [
9+
{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-122.141837, 47.6377962], [-122.1417691, 47.6377961], [-122.1417691, 47.6378355], [-122.1416809, 47.6378346]]}, "properties": {"barrier": "fence", "length": 16.1, "_id": "488620715"}},
10+
{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-122.133963, 47.6484834], [-122.1339612, 47.6484111], [-122.13426, 47.6484076], [-122.1342648, 47.648595], [-122.133966, 47.6485984], [-122.1339645, 47.6485424]]}, "properties": {"barrier": "fence", "length": 80.0, "_id": "652133118"}},
11+
{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-122.126402, 47.6389147], [-122.1257784, 47.6389207], [-122.1255743, 47.6389127], [-122.1255344, 47.6388918], [-122.125416, 47.6389215], [-122.1252529, 47.6389228], [-122.125233, 47.6389302], [-122.1250987, 47.6389304], [-122.1249073, 47.6388854], [-122.1245085, 47.6388953], [-122.1245098, 47.6392452], [-122.1242755, 47.6393694], [-122.1243736, 47.6394809], [-122.1244332, 47.6395598], [-122.1244832, 47.6396615], [-122.1245044, 47.6397353], [-122.1244853, 47.6398367], [-122.1244103, 47.6399906], [-122.1244036, 47.6401202], [-122.1243772, 47.6402496], [-122.1243394, 47.6403164], [-122.124285, 47.6404069], [-122.1242779, 47.6404821], [-122.1243118, 47.6405111], [-122.1243159, 47.6406926], [-122.1242946, 47.6407142], [-122.1243072, 47.6407531], [-122.1243505, 47.6407869], [-122.1244078, 47.6409177], [-122.124427, 47.6409777], [-122.1244747, 47.6410461], [-122.1245225, 47.6411147], [-122.1246689, 47.6412448], [-122.124927, 47.6414201], [-122.1250937, 47.641594], [-122.125238, 47.6417816], [-122.1253051, 47.641809], [-122.1253783, 47.6419542], [-122.12536, 47.6419802], [-122.1253986, 47.6421418], [-122.1254413, 47.6421651], [-122.1261629, 47.6421597], [-122.1265044, 47.6421788], [-122.1268947, 47.6422651], [-122.1269984, 47.6423035], [-122.1270676, 47.6423397], [-122.1275301, 47.6426271], [-122.1276657, 47.6425711], [-122.1277735, 47.6425327], [-122.1278572, 47.642509], [-122.1279584, 47.6424912], [-122.1281032, 47.6424735], [-122.1304557, 47.6424418], [-122.1306244, 47.6423792], [-122.1308406, 47.6423816], [-122.1319929, 47.6423875], [-122.1320807, 47.642383], [-122.1321142, 47.6423746], [-122.1321291, 47.6423618], [-122.13214, 47.6423397], [-122.1322152, 47.6383308], [-122.1321949, 47.6382952], [-122.1321644, 47.6382733], [-122.1321618, 47.6380321], [-122.1321459, 47.6379963], [-122.1321583, 47.6379629], [-122.13216, 47.6379379], [-122.132153, 47.6379093], [-122.1319526, 47.6377326]]}, "properties": {"barrier": "fence", "length": 1599.2, "_id": "685568528"}},
12+
{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-122.1394754, 47.6388689], [-122.1394887, 47.6388357]]}, "properties": {"barrier": "fence", "length": 3.8, "_id": "740844725"}},
13+
{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[-122.1394887, 47.6388357], [-122.1395136, 47.6387788]]}, "properties": {"barrier": "fence", "length": 6.6, "_id": "740844727"}}]}

0 commit comments

Comments
 (0)