diff options
-rw-r--r-- | hessen.out | 369 | ||||
-rw-r--r-- | info.c | 273 | ||||
-rw-r--r-- | malta.map | bin | 0 -> 2842233 bytes | |||
-rw-r--r-- | mkfile | 8 |
4 files changed, 650 insertions, 0 deletions
diff --git a/hessen.out b/hessen.out new file mode 100644 index 0000000..c3a4ef5 --- /dev/null +++ b/hessen.out @@ -0,0 +1,369 @@ +Mapsforge Header Information +magic: mapsforge binary OSM +header size: 6271 bytes +version: 4 +file size: 139845675 bytes +created: Sat Feb 26 09:55:27 CET 2005 +bbox: (49.2909°N, 7.66757°E)(51.7625°N, 10.344°E) +tile size: 256 +projection: Mercator +flags: pos0 zoom0 lang author +pos0: (50.5267°N, 9.00577°E) +zoom0: 8 +lang: en,de,fr,es +author: mapsforge-map-writer-0.9.0 +pois: + amenity=bench + highway=bus_stop + power=tower + barrier=gate + highway=traffic_signals + highway=turning_circle + barrier=bollard + amenity=restaurant + tourism=information + amenity=recycling + amenity=parking + barrier=lift_gate + amenity=post_box + amenity=shelter + railway=level_crossing + historic=memorial + place=locality + natural=peak + place=village + barrier=cycle_barrier + shop=bakery + amenity=cafe + power=generator + amenity=fast_food + leisure=playground + amenity=telephone + amenity=bank + shop=hairdresser + tourism=viewpoint + amenity=place_of_worship + religion=christian + shop=supermarket + emergency=phone + amenity=pharmacy + amenity=pub + amenity=fountain + natural=spring + amenity=kindergarten + tourism=hotel + amenity=fire_station + amenity=fuel + amenity=toilets + tourism=attraction + amenity=atm + man_made=surveillance + man_made=tower + railway=tram_stop + amenity=post_office + amenity=school + place=town + place=suburb + place=hamlet + amenity=bar + amenity=drinking_water + shop=bicycle + railway=station + tourism=museum + railway=halt + amenity=bicycle_rental + amenity=library + amenity=townhall + leisure=slipway + highway=mini_roundabout + amenity=theatre + aeroway=gate + amenity=police + shop=laundry + amenity=grave_yard + religion=muslim + amenity=cinema + tourism=hostel + amenity=hospital + amenity=university + aeroway=helipad + amenity=bus_station + natural=cave_entrance + historic=monument + religion=jewish + aeroway=aerodrome + place=city + shop=organic + tourism=alpine_hut + barrier=toll_booth + shop=mall + station=subway + man_made=windmill + place=island +ways: + building=yes + highway=track + highway=residential + building=house + natural=scrub + highway=service + landuse=farmland + oneway=yes + highway=footway + landuse=meadow + building=residential + highway=path + tracktype=grade2 + tracktype=grade3 + tracktype=grade5 + landuse=forest + tracktype=grade1 + tracktype=grade4 + landuse=grass + waterway=stream + highway=secondary + building=garage + highway=primary + railway=rail + area=yes + bridge=yes + highway=tertiary + amenity=parking + boundary=administrative + landuse=residential + natural=wood + access=private + natural=nosea + natural=sea + natural=water + highway=motorway + highway=unclassified + building=apartments + highway=steps + oneway=no + roof:shape=gabled + natural=grassland + landuse=allotments + barrier=fence + tunnel=yes + leisure=pitch + highway=motorway_link + highway=living_street + landuse=farmyard + highway=trunk + landuse=industrial + building=garages + landuse=cemetery + barrier=wall + leisure=park + building=industrial + building=detached + highway=trunk_link + highway=cycleway + landuse=orchard + landuse=commercial + leisure=playground + waterway=river + building=shed + sport=soccer + roof:shape=flat + building=commercial + highway=pedestrian + building=terrace + waterway=drain + admin_level=6 + highway=primary_link + access=destination + building=school + admin_level=4 + building=roof + sport=tennis + roof:material=roof_tiles + building=hut + landuse=basin + roof:orientation=across + amenity=school + building:part=yes + waterway=canal + railway=platform + leisure=sports_centre + building=barn + leisure=garden + building:material=plaster + barrier=retaining_wall + railway=disused + landuse=railway + landuse=reservoir + waterway=riverbank + building=church + railway=tram + leisure=nature_reserve + roof:orientation=along + landuse=retail + building=greenhouse + leisure=swimming_pool + landuse=quarry + natural=heath + aeroway=taxiway + landuse=village_green + man_made=pier + landuse=construction + sport=multi + roof:shape=hipped + natural=wetland + admin_level=5 + highway=secondary_link + sport=equestrian + landuse=recreation_ground + railway=light_rail + highway=construction + piste:type=nordic + sport=swimming + tourism=attraction + landuse=vineyard + leisure=track + highway=bridleway + landuse=brownfield + building=retail + wood=deciduous + building=office + building=public + building=farm_auxiliary + piste:difficulty=easy + building=university + leisure=stadium + building=warehouse + highway=tertiary_link + place=locality + building=cabin + leisure=water_park + amenity=grave_yard + historic=castle + barrier=city_wall + building=chapel + building=civic + aeroway=runway + building=farm + wood=mixed + oneway=-1 + natural=beach + leisure=common + landuse=greenfield + amenity=hospital + sport=shooting + amenity=university + sport=basketball + roof:shape=pyramidal + landuse=landfill + roof:material=tar_paper + landuse=military + piste:difficulty=intermediate + tunnel=no + building=hospital + railway=narrow_gauge + amenity=toilets + building:part=elevator + natural=scree + building=hotel + leisure=golf_course + waterway=dam + amenity=fountain + highway=road + building:material=brick + building=train_station + building=service + wood=coniferous + aeroway=aerodrome + roof:shape=skillion + building=hangar + lock=yes + historic=ruins + sport=golf + aeroway=apron + piste:type=downhill + building=manufacture + building=semidetached_house + highway=raceway + building:material=glass + tourism=zoo + building=supermarket + highway=services + building:part=roof + tourism=hostel + building:material=stone + roof:material=slate + roof:shape=half-hipped + sport=volleyball + railway=preserved + aeroway=helipad + amenity=theatre + leisure=dog_park + railway=subway + sport=boules + building:material=concrete + military=barracks + building:material=wood + piste:difficulty=advanced + railway=miniature + railway=monorail + roof:material=glass + roof:material=gravel + aerialway=drag_lift + sport=climbing + route=ferry + building=shelter + building:material=metal + aeroway=terminal + natural=fell + amenity=college + roof:shape=gambrel + piste:difficulty=novice + roof:shape=round + roof:shape=mansard + roof:material=concrete + building=ruins + sport=baseball + roof:material=metal + sport=football + sport=skating + roof:material=eternit + building=transportation + roof:shape=dome + roof:material=grass + piste:type=sled + building=mosque + building=shop + sport=skiing + roof:material=stone + building=castle + building:material=sandstone + amenity=embassy + building:part=ramp + roof:material=copper + aerialway=gondola + railway=funicular + building=monastery + aerialway=chair_lift + aerialway=rope_tow + boundary=national_park + building=cathedral + building=museum + amenity=swimming_pool + building=factory + roof:shape=onion + aerialway=cable_car + railway=station + roof:material=wood + aerialway=magic_carpet + military=airfield + building=gym + building:part=tower + roof:shape=saltbox + roof:material=thatch + highway=bus_guideway + sport=cricket + sport=bowls + building:material=steel + roof:material=acrylic_glass + roof:material=plastic + roof:material=plants @@ -0,0 +1,273 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> + +typedef struct Coord Coord; +typedef struct BBox BBox; +typedef struct MFHeader MFHeader; +typedef struct Tag Tag; + +struct Coord { + double lat; + double lon; +}; + +struct BBox { + Coord min; + Coord max; +}; + +struct Tag { + int key; + char *val; +}; + +struct MFHeader { + char magic[21]; /* magic sequence */ + uint size; /* header size */ + uint fversion; /* file version */ + uvlong fsize; /* file size */ + uvlong dob; /* date of creation */ + BBox bbox; /* map boundaries */ + ushort tsize; /* tile size */ + char *projection; /* Mercator or nothing */ + uchar flags; + Coord pos0; /* map initial position */ + uchar zoom0; /* map initial zoom level */ + char *lang; /* language preference */ + char *comment; + char *author; + Tag *pois; /* places of interest */ + Tag *ways; /* ways */ +}; + +enum { + Fdebug = 0x80, + Fpos0 = 0x40, + Fzoom0 = 0x20, + Flang = 0x10, + Fcomment = 0x08, + Fauthor = 0x04 +}; + +void +usage(void) +{ + fprint(2, "usage: info [mapfile]\n"); + exits("usage"); +} + +ushort +get16(uchar *a) +{ + return (a[0]<<8) | a[1]; +} + +uint +get32(uchar *a) +{ + return (a[0]<<24) | (a[1]<<16) | (a[2]<<8) | a[3]; +} + +uvlong +get64(uchar *a) +{ + uvlong n; + + n = get32(a); + return n<<32 | get32(a+4); +} + +uint +readuvarint(Biobuf *b) +{ + uint n, shift; + uchar x; + + n = shift = 0; + + if(Bread(b, &x, 1) != 1) + sysfatal("readuvarint: %r"); + while(x & 0x80){ + n |= (x & ~0x80) << shift; + shift += 7; + Bread(b, &x, 1); + } + return n |= x; +} + +char * +readstr(Biobuf *b) +{ + uint len; + char *s; + + len = readuvarint(b); + s = malloc(len+1); + if(Bread(b, s, len) != len) + sysfatal("readstr: %r"); + s[len] = 0; + + return s; +} + +double +todeg(long μd) +{ + double d; + d = μd / 1000000.; + return d; +} + +Coord +getcoord(uchar *a) +{ + Coord c; + uchar *s; + + s = a; + c.lat = todeg(get32(s)); + s += 4; + c.lon = todeg(get32(s)); + + return c; +} + +BBox +getbbox(uchar *a) +{ + BBox bbox; + uchar *s; + + s = a; + bbox.min = getcoord(s); + s += 8; + bbox.max = getcoord(s); + + return bbox; +} + +Tag * +gettags(Biobuf *b) +{ + Tag *t; + uchar x[2]; + int len, i; + + if(Bread(b, x, 2) != 2) + sysfatal("gettags: %r"); + len = get16(x); + t = malloc((len+1)*sizeof(Tag)); + for(i = 0; i < len; i++) + t[i].val = readstr(b); + t[len].val = nil; + + return t; +} + +void +main(int argc, char *argv[]) +{ + Biobuf bin; + Tag *tp; + uchar buf[512]; + int fd; + + MFHeader h; + + if(argc < 2) + fd = 0; + else{ + fd = open(argv[1], OREAD); + if(fd < 0) + sysfatal("open: %r"); + } + + if(Binit(&bin, fd, OREAD) < 0) + sysfatal("Binit: %r"); + + if(Bread(&bin, buf, 20) != 20) + sysfatal("wrong magic value"); + strncpy(h.magic, (char *)buf, 20); + h.magic[20] = 0; + + if(Bread(&bin, buf, 4) != 4) + sysfatal("couldn't read header size"); + h.size = get32(buf); + + if(Bread(&bin, buf, 4) != 4) + sysfatal("couldn't read file version"); + h.fversion = get32(buf); + + if(Bread(&bin, buf, 8) != 8) + sysfatal("couldn't get file size"); + h.fsize = get64(buf); + + if(Bread(&bin, buf, 8) != 8) + sysfatal("couldn't get date of creation"); + h.dob = get64(buf); + + if(Bread(&bin, buf, 16) != 16) + sysfatal("couldn't get bbox"); + h.bbox = getbbox(buf); + + if(Bread(&bin, buf, 2) != 2) + sysfatal("couldn't get tile size"); + h.tsize = get16(buf); + + h.projection = readstr(&bin); + + if(Bread(&bin, &h.flags, 1) != 1) + sysfatal("couldn't get flags"); + if(h.flags & Fpos0){ + if(Bread(&bin, buf, 8) != 8) + sysfatal("couldn't get pos0"); + h.pos0 = getcoord(buf); + } + if(h.flags & Fzoom0) + Bread(&bin, &h.zoom0, 1); + if(h.flags & Flang) + h.lang = readstr(&bin); + if(h.flags & Fcomment) + h.comment = readstr(&bin); + if(h.flags & Fauthor) + h.author = readstr(&bin); + h.pois = gettags(&bin); + h.ways = gettags(&bin); + + Bterm(&bin); + + print("Mapsforge Header Information\n"); + print("magic: %s\n", h.magic); + print("header size: %d bytes\n", h.size); + print("version: %d\n", h.fversion); + print("file size: %llud bytes\n", h.fsize); + print("created: %s", ctime(h.dob)); + print("bbox: (%g°N, %g°E)(%g°N, %g°E)\n", + h.bbox.min.lat, h.bbox.min.lon, + h.bbox.max.lat, h.bbox.max.lon); + print("tile size: %d\n", h.tsize); + print("projection: %s\n", h.projection); + print("flags:"); + if(h.flags & Fdebug) print(" debug"); + if(h.flags & Fpos0) print(" pos0"); + if(h.flags & Fzoom0) print(" zoom0"); + if(h.flags & Flang) print(" lang"); + if(h.flags & Fcomment) print(" comment"); + if(h.flags & Fauthor) print(" author"); + print("\n"); + if(h.flags & Fpos0) print("pos0: (%g°N, %g°E)\n", h.pos0.lat, h.pos0.lon); + if(h.flags & Fzoom0) print("zoom0: %d\n", h.zoom0); + if(h.flags & Flang) print("lang: %s\n", h.lang); + if(h.flags & Fcomment) print("comment: %s\n", h.comment); + if(h.flags & Fauthor) print("author: %s\n", h.author); + print("pois:\n"); + for(tp = h.pois; tp->val != nil; tp++) + print("\t%s\n", tp->val); + print("ways:\n"); + for(tp = h.ways; tp->val != nil; tp++) + print("\t%s\n", tp->val); + + close(fd); + exits(0); +} diff --git a/malta.map b/malta.map Binary files differnew file mode 100644 index 0000000..1362efa --- /dev/null +++ b/malta.map @@ -0,0 +1,8 @@ +</$objtype/mkfile + +TARG=\ + info + +BIN=/$objtype/bin + +</sys/src/cmd/mkmany |