Skip to content

Commit 882b358

Browse files
committed
fix an issue with unicode data from OSM
1 parent 91a246b commit 882b358

18 files changed

+484
-26
lines changed

examples/bruxelles_tram_station_test.svg

+1-1
Loading

examples/bruxelles_tram_ways_test.svg

+1-1
Loading

examples/londres_subway_station_test.svg

+1-1
Loading

examples/londres_subway_ways_test.svg

+1-1
Loading

examples/milan_tram_station_test.svg

+1-1
Loading

examples/milan_tram_ways_test.svg

+1-1
Loading

examples/nantes_tram_ways_test.svg

+1-1
Loading

examples/prague_tram_station_test.svg

+1-1
Loading

examples/prague_tram_ways_test.svg

+1-1
Loading

examples/rennes_bus_station_test.svg

+1-1
Loading

examples/rennes_bus_ways_test.svg

+1-1
Loading

osm/OSMprocess.py

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def GetTransportDataLineList (self):
4141
# sort data
4242
transport_lines.sort(key=lambda x: x["name"])
4343
result = {"city":self.CityName, "lines":[line["name"] for line in transport_lines]}
44+
4445
return result
4546

4647

osm/application_OSM_extraction.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def osm_extract_data (transport_info, transport_type):
316316
# check duplicate station and ensure there is a name
317317
if node["id"] not in station_doublon and station["name"] != "":
318318
print ("station:", station["id"], station["name"])
319-
print (node)
319+
#print (node)
320320
stations.append(station)
321321
station_doublon[node["id"]] = True
322322

@@ -679,7 +679,7 @@ def lines_ways_extraction_from_datta(data): # => ok
679679
# group by relation (line id)
680680
dic_line_segments = {}
681681

682-
json.dump (data, open("data.json", "w"), indent=4)
682+
#json.dump (data, open("data.json", "w"), indent=4)
683683
# get line list
684684
df_line_list = lines_list_extraction_from_data(data)
685685

osm2touch.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def load_file(self, dialogtitle, filterstring, filter=["(*.brp)", "(*.*)"]):
300300

301301
def GetISO639_country_code (self):
302302
list = OSMutils.omsutils_get_iso639_code ()
303-
print(list)
303+
304304
return list
305305

306306
def ReadTransportData (self, city, transport_type, iso639_city_code, place_id):
@@ -312,9 +312,10 @@ def ReadTransportData (self, city, transport_type, iso639_city_code, place_id):
312312
def GetTransportLines (self):
313313
#ret = self.osmt.GetTransportLineList ()
314314
ret = self.osmt.GetTransportDataLineList ()
315-
316-
print ("GetTransportLineList", ret)
317-
return ret
315+
print ("ret", ret, type(ret))
316+
resstr = json.dumps (ret, ensure_ascii=False)
317+
print ("GetTransportLineList", resstr)
318+
return resstr
318319

319320
def GetTransportDataSvg (self, linelist, drawstation, linestrategy, polygon):
320321
print ("GetTransportSVG", linelist, drawstation, int(linestrategy), type(linestrategy))
@@ -324,10 +325,13 @@ def GetTransportDataSvg (self, linelist, drawstation, linestrategy, polygon):
324325
return svg
325326

326327
def GetTransportData (self, linelist, drawstation, linestrategy, polygon):
327-
svg = self.GetTransportDataSvg (linelist, drawstation, linestrategy, polygon)
328-
liststation = self.osmt.GetTransportDataStations (linelist)
328+
linearray = json.loads (linelist)
329+
#print ("json decoded", linearray )
330+
svg = self.GetTransportDataSvg (linearray, drawstation, linestrategy, polygon)
331+
liststation = self.osmt.GetTransportDataStations (linearray)
329332

330-
return json.dumps({"svg": svg, "stations": liststation})
333+
str = json.dumps({"svg": svg, "stations": liststation}, ensure_ascii=False)
334+
return str
331335

332336
def GetTransportSVGbase64 (self):
333337
svg = self.osmt.get_svg ()
@@ -389,9 +393,15 @@ def delete_splash(window):
389393
api = Api()
390394
debugihm = False
391395

396+
# redirect stdout to file for debug purpose
397+
#f = open("output.log", 'w')
398+
f = open(os.devnull, 'w')
399+
sys.stdout = f
400+
392401
#print(sys.argv)
393402
dir, script = os.path.splitext(sys.argv[0])
394-
if len(sys.argv) > 1 and script == ".py":
403+
#if len(sys.argv) > 1 and script == ".py":
404+
if len(sys.argv) > 1:
395405
if sys.argv[1] == "--debug":
396406
debugihm = True
397407

0 commit comments

Comments
 (0)