Skip to content

Instantly share code, notes, and snippets.

View eoghanmurray's full-sized avatar

Eoghan Murray eoghanmurray

View GitHub Profile
fd = Feed(local_gtfs_zip)
try:
fd.read_table('frequencies.txt')
except (KeyError, IOError) as e:
pass
else:
raise Exception('need to handle frequency based schedules')
trips_by_route = defaultdict(list)
class MutableList(Mutable, list):
@classmethod
def coerce(cls, key, value):
"Convert plain dictionaries to MutableDict."
if not isinstance(value, MutableList):
if isinstance(value, list):
return MutableList(value)
# this call will raise ValueError
return Mutable.coerce(key, value)
else:
Station Name | node_id | station_way_id
-----------------------------+------------+------------
Acklington | 3122470853 |
Acklington | 20915833 |
Airbles | 30562471 |
Airbles | 2977094542 |
Airdrie | 2978794033 |
Airdrie | 30617723 |
Aldgate East | 1741698385 |
Aldgate East | 1825191028 |
name | osm_id | osm_way_id | tags
-----------------------------+------------+------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="osmconvert 0.7T" timestamp="2016-05-30T19:44:05Z">
<bounds minlat="48.79409" minlon="-9.667832" maxlat="61.92858" maxlon="2.25"/>
<node id="33847396" lat="55.9328844" lon="-3.215253" version="3" timestamp="2015-01-24T18:33:41Z" changeset="28379428" uid="388774" user="drnoble"/>
<node id="33847399" lat="55.9329578" lon="-3.2150655" version="3" timestamp="2015-01-24T18:33:41Z" changeset="28379428" uid="388774" user="drnoble"/>
<node id="33847401" lat="55.9331153" lon="-3.2152619" version="3" timestamp="2015-01-24T18:33:41Z" changeset="28379428" uid="388774" user="drnoble"/>
<node id="33847405" lat="55.9333842" lon="-3.2145749" version="3" timestamp="2015-01-24T18:33:41Z" changeset="28379428" uid="388774" user="drnoble"/>
<node id="33847407" lat="55.933535" lon="-3.2147631" version="3" timestamp="2015-01-24T18:33:41Z" changeset="28379428" uid="388774" user="drnoble"/>
<node id="33847409" lat="55.9336135" lon="-3.2145625" version="3" time
$ ./osm2pgsql -v -C 20000 --number-processes 4 -s -S ../default.style -U postgres -H localhost -P 5432 -W --hstore-all --hstore-add-index -d osm_gb great-britain-latest.osm
osm2pgsql version 0.91.0-dev (64 bit id space)
Password:
Using built-in tag processing pipeline
Using projection SRS 3857 (Spherical Mercator)
Setting up table: planet_osm_point
Setting up table: planet_osm_line
Setting up table: planet_osm_polygon
Setting up table: planet_osm_roads
-- postgresql-9.5-postgis-2.2
create table test (name character varying, p geometry(point, 900913), a geometry(Geometry, 900913));
insert into test values ('a', '010100002031BF0D00713D0AD7F54711C1A4703D1A3D965941', null);
insert into test values ('b', '010100002031BF0D0002FB34FAC62E11C1FAF7FB8141965941', '010300002031BF0D00010000000D0000009A9999998B3211C114AE47F13D965941295C8FC2863211C1A4703D5A569659418FC2F528D33011C1EC51B84E5A9659417B14AE47B62F11C1B81E851B5A965941295C8FC2BC2F11C18FC2F5F85D96594114AE47E10D2C11C1295C8FE26F965941EC51B81EF32B11C1666666D6699659417B14AE47D12C11C1F6285CFF139659418FC2F528BA2F11C1F6285C7F14965941B81E85EBBE2F11C11F85EB01279659415C8FC2F5DB2F11C1D7A3702D2C965941F6285C8F2F3011C15C8FC235309659419A9999998B3211C114AE47F13D965941');
select name, st_contains(ST_CollectionHomogenize(c.g), u.p)
from test u,
(select unnest(st_clusterwithin(coalesce(u2.a, st_expand(u2.p, 350)), 250)) g
from test u2) c order by name;
<relation id="4007477" version="1" timestamp="2014-09-02T14:28:18Z" changeset="25183275" uid="2185740" user="mprhode">
<member type="way" ref="145078273" role="outer"/>
<member type="way" ref="113970233" role="outer"/>
<tag k="type" v="multipolygon"/>
<tag k="amenity" v="university"/>
<tag k="tourism" v="attraction"/>
</relation>
<way id="113970233" version="12" timestamp="2014-09-02T14:28:18Z" changeset="25183275" uid="2185740" user="mprhode">
<nd ref="2142852432"/>
osm_gb=# SELECT op, count(*) FROM (
SELECT way, tags->'operator' op FROM planet_osm_polygon WHERE tags->'amenity' = 'university'
UNION
SELECT way, tags->'operator' op from planet_osm_point where tags->'amenity' = 'university') x
WHERE st_dwithin(geography(st_transform(way, 4326)),
geography(st_transform((select way from planet_osm_point
where tags->'place' = 'city' and name = 'Cambridge' limit 1), 4326)), 20000)
GROUP BY op
ORDER BY count(*) DESC;
op | count
var xxxtime = 0;
var xxxcount = 0;
var yyytime = 0;
var yyycount = 0;
var rrwebRecord = (function () {
[...snip...]
if (m.attributeName === 'style') {