简体   繁体   中英

Identation problem while switch to jupyter notebook

Have tried using the commands and changing the space and tabs but still, the error continues appearing

 1 import osmium
 2 import shapely.wkb as wkblib
 3 class StreetsHandler(osmium.SimpleHandler):
 4     def __init__(self):
 5         osmium.SimpleHandler.__init__(self)
 6         self.num_nodes = 0
 7         self.num_relations = 0
 8         self.num_ways = 0
 9         self.street_relations = []
10         self.street_relation_members = []
11         self.street_ways = []
12         # A global factory that creates WKB from a osmium geometry
13         self.wkbfab = osmium.geom.WKBFactory()
14 def way(self, w):
15         if w.tags.get("highway") is not None and w.tags.get("name") is no
16             try:
17                 wkb = self.wkbfab.create_linestring(w)
18                 geo = wkblib.loads(wkb, hex=True)
19             except:
20                 return
21 row = { "w_id": w.id, "geo": geo }
22            
23             for key, value in w.tags:
24                 row[key] = value
25                 
26             self.street_ways.append(row)
27             self.num_ways += 1 
28         
29     def relation(self, r):
30         if r.tags.get("type") == "associatedStreet" and r.tags.get("name"
31             row = { "r_id": r.id }
32             for key, value in r.tags:
33                 row[key] = value
34             self.street_relations.append(row)
35             
36             for member in r.members:
37                 self.street_relation_members.append({ 
38                     "r_id": r.id, 
39                     "ref": member.ref, 
40                     "role": member.role, 
41                     "type": member.type, })
42 self.num_relations += 1

This is what I get

  File "<tokenize>", line 29
    def relation(self, r):
    ^
IndentationError: unindent does not match any outer indentation level

The function way inside the class definition is not indented properly. Please indent it and it will solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM