Databases Reference
In-Depth Information
Next we repeat many of the same steps for the road data. The GIS export is more complex
for roads than for trees because the roads are described per block, with each block
divided into segments. Effectively, there is a new segment recorded for every turn in the
road. Road data also includes metrics about traffic rates, pavement age and type, etc.
Our goal is to find a quiet shady spot in which to walk and take a cell phone call. So we
can leverage the road data per segment in a couple of ways. Let's create one estimator
to describe how quiet each segment is based on comparing the traffic types and rates.
Then we'll create another estimator to describe the shade based on comparing how the
pavement reflects sunlight.
( def roads-fields [ "?road_name" "?bike_lane" "?bus_route" "?truck_route"
"?albedo" "?road_lat" "?road_lng" "?road_alt" "?geohash"
"?traffic_count" "?traffic_index" "?traffic_class"
"?paving_length" "?paving_width" "?paving_area"
"?surface_type" ])
( defn get-roads [ src road-meta trap ]
"subquery to parse/filter the road data"
( <- roads-fields
( src ?road_name ?misc ?geo ?kind )
( re-matches # "^\s+Sequence.*Traffic Count.*" ?misc )
( parse-road ?misc :>
?traffic_count ?traffic_index ?traffic_class
?paving_length ?paving_width ?paving_area ?surface_type
?overlay_year_str ?bike_lane ?bus_route ?truck_route )
( road-meta ?surface_type ?albedo_new ?albedo_worn )
(( c/each read-string ) ?overlay_year_str :> ?overlay_year )
( estimate-albedo ?overlay_year ?albedo_new ?albedo_worn :> ?albedo )
( bigram ?geo :> ?pt0 ?pt1 )
( midpoint ?pt0 ?pt1 :> ?lat ?lng ?alt )
;; why filter for min? because there are geo duplicates..
(( c/each c/min ) ?lat ?lng ?alt :> ?road_lat ?road_lng ?road_alt )
( geo/encode ?road_lat ?road_lng geo-precision :> ?geohash )
( :trap ( hfs-textline trap ))))
Similar to the business process for trees, the get-roads function is the subquery used
to filter, merge, and refine the estimators about roads. The roads-fields function de‐
fines the fields used to describe roads throughout the app; other fields get discarded.
The regular expression (re-matches #"^\s+Sequence.*Traffic Count.*" ?misc)
filters records about roads out of the GIS tuple stream, creating a branch.
Search WWH ::




Custom Search