if sub.tag != 'nd':
            continue
        ref = int(sub.attrib['ref'])
        if ref not in waynodes:
            continue
        way.append(waynodes[ref])
        refs.append(ref)
        j += 1
        lat += waynodes[ref][0]
        lon += waynodes[ref][1]
    lat /= j
    lon /= j
    if refs[0] != refs[-1]:
        outroot.append(elem)
        continue
    if rhr.is_rhr(way[1:]):
        nway = way
    else:
        nway = [] + way
        nway.reverse()
    eway = expand(nway, 1.5 * 360 / 40000000)
    eeway = expand(nway, 4.0 * 360 / 40000000)
    bldgs.append(( lat, lon, way, eway, eeway, refs, tags, elem.attrib, [] ))
bldgroot = None # Make python release the XML structure


# Read the address nodes data
for elem in addrroot:
    if 'id' not in elem.attrib:
        continue
    tags = {}
Ejemplo n.º 2
0
        ref = int(sub.attrib['ref'])
        if ref not in waynodes:
            continue
        way.append(waynodes[ref])
        refs.append(ref)
        if len(refs) == 1:
            continue
        j += 1
        lat += waynodes[ref][0]
        lon += waynodes[ref][1]
    lat /= j
    lon /= j
    if refs[0] != refs[-1]:
        continue
    try:
        is_rhr = rhr.is_rhr(way[1:])
    except:
        is_rhr = True
        ElementTree.SubElement(elem, 'tag', { 'k': 'fixme3', 'v': 'shape' })
        print(id)
    if is_rhr:
        nway = way
    else:
        nway = [] + way
        nway.reverse()
        subs = [ sub for sub in elem if sub.tag == 'nd' ]
        for sub in subs:
            elem.remove(sub)
	    elem.insert(0, sub)
    eway = expand(nway, 4.0 * 360 / 40000000)
    eeway = expand(nway, 9.0 * 360 / 40000000)
Ejemplo n.º 3
0
        if sub.tag != 'nd':
            continue
        ref = int(sub.attrib['ref'])
        if ref not in waynodes:
            continue
        way.append(waynodes[ref])
        refs.append(ref)
        j += 1
        lat += waynodes[ref][0]
        lon += waynodes[ref][1]
    lat /= j
    lon /= j
    if refs[0] != refs[-1]:
        outroot.append(elem)
        continue
    if rhr.is_rhr(way[1:]):
        nway = way
    else:
        nway = [] + way
        nway.reverse()
    eway = expand(nway, 1.5 * 360 / 40000000)
    eeway = expand(nway, 4.0 * 360 / 40000000)
    bldgs.append((lat, lon, way, eway, eeway, refs, tags, elem.attrib, []))
bldgroot = None  # Make python release the XML structure

# Read the address nodes data
for elem in addrroot:
    if 'id' not in elem.attrib:
        continue
    tags = {}
    for sub in elem:
Ejemplo n.º 4
0
		for px in range(1, tile.size[1]):
			for py in range(0, tile.size[1]):
				if not iswall(px, py) or \
						not isempty(px - 1, py):
					continue
				marks = []
				try:
					shapes.append(walk(( px - 1, py ),
						marks))
				except Exception as e:
					remove += marks
		for px, py in remove:
			markclean(px, py)
		tile.save('ctiles/' + str(x) + '/' + str(y) + '.png')

		shapes = [ shape for shape in shapes if rhr.is_rhr(shape) ]
		shapes = [ douglaspeucker.simplify_poly(shape, 1.4)
			for shape in shapes ]
		shapes = [ shape for shape in shapes if len(shape) > 2 ]
		shapes = [ shape for shape in shapes if area.area(shape) > 150 ]

		for shape in shapes:
			orthogonalise()

		shapes = [ douglaspeucker.simplify_poly(shape, 1.0)
			for shape in shapes ]

		for shape in shapes:
			fixcorners()

		shapes = [ area.expand(shape, 1.5) for shape in shapes ]