Ejemplo n.º 1
0
 def generate_osm(compact_formatting):
     stream = StringIO()
     xml = OSMWriter(fp=stream,
                     compact_formatting=compact_formatting)
     xml.node(1, 10, 30, {"highway": "yes"}, version=2)
     xml.way(1, {'pub': 'yes'}, [123])
     xml.relation(1, {'type': 'boundary'}, [('node', 1),
                                            ('way', 2, 'outer')])
     xml.close(close_file=False)
     return stream.getvalue()
Ejemplo n.º 2
0
    def testSimple(self):

        string = StringIO()

        xml = OSMWriter(fp=string)
        xml.node(1, 10, 30, {"highway": "yes"}, version=2)
        xml.way(1, {'pub': 'yes'}, [123])
        xml.relation(1, {'type': 'boundary'}, [('node', 1), ('way', 2, 'outer')])
        xml.close(close_file=False)

        # Different python versions can write XML in different ways, (eg order
        # of attributes). This makes simple string comparison fail. So simple
        # parse & dump canonicalises it
        output = ET.tostring(ET.fromstring(string.getvalue()))
        exected_output = ET.tostring(ET.fromstring('<?xml version="1.0" encoding="utf-8"?>\n<osm version="0.6" generator="osmwriter">\n  <node lat="10" version="2" lon="30" id="1">\n    <tag k="highway" v="yes"></tag>\n  </node>\n  <way id="1">\n    <nd ref="123"></nd>\n    <tag k="pub" v="yes"></tag>\n  </way>\n  <relation id="1">\n    <member ref="1" type="node" />\n    <member ref="2" role="outer" type="way" />\n    <tag k="type" v="boundary" />\n  </relation>\n</osm>'))

        self.assertEqual(output, exected_output)
Ejemplo n.º 3
0
    def testSimple(self):

        string = StringIO()

        xml = OSMWriter(fp=string)
        xml.node(1, 10, 30, {"highway": "yes"}, version=2)
        xml.way(1, {'pub': 'yes'}, [123])
        xml.relation(1, {'type': 'boundary'}, [('node', 1),
                                               ('way', 2, 'outer')])
        xml.close(close_file=False)

        # Different python versions can write XML in different ways, (eg order
        # of attributes). This makes simple string comparison fail. So simple
        # parse & dump canonicalises it
        output = ET.tostring(ET.fromstring(string.getvalue()))
        exected_output = ET.tostring(
            ET.fromstring(
                '<?xml version="1.0" encoding="utf-8"?>\n<osm version="0.6" generator="osmwriter">\n  <node lat="10" version="2" lon="30" id="1">\n    <tag k="highway" v="yes"></tag>\n  </node>\n  <way id="1">\n    <nd ref="123"></nd>\n    <tag k="pub" v="yes"></tag>\n  </way>\n  <relation id="1">\n    <member ref="1" type="node" />\n    <member ref="2" role="outer" type="way" />\n    <tag k="type" v="boundary" />\n  </relation>\n</osm>'
            ))

        self.assertEqual(output, exected_output)
Ejemplo n.º 4
0
    # Ziskam jmeno
    name_box = soup.find('h1', attrs={'class': 'menu5 small-h1'})
    name = name_box.text.strip()

    # Ziskma souradnice
    coordinates_box = soup.find('a', attrs={'class': 'map mapycz'})
    if (coordinates_box == None):
        print(i, ':  ', name, sep='')
        continue

    coordinates = coordinates_box.attrs['href']
    m = re.search('y=([0-9]+.[0-9]+)&x=([0-9]+.[0-9]+)', coordinates)
    coordinates = (m.group(1), m.group(2))

    # Vytisknu vysledek a pridam ho do vystupniho souboru
    print(i,
          ':  ',
          name,
          '  (N ',
          coordinates[0],
          ' E ',
          coordinates[1],
          ')',
          sep='')
    xml.node(10000000000 + i, coordinates[0], coordinates[1], {
        'name': name,
        'rock': 'chs'
    })

xml.close()