@@ -315,19 +315,20 @@ def clearkml(self):
315
315
self .curtextlayers = []
316
316
self .menu_needs_refreshing = True
317
317
318
- def add_polygon (self , name , coords ):
318
+ def add_polygon (self , name , coords , line_colour = None ):
319
319
'''add a polygon to the KML list. coords is a list of lat/lng tuples in degrees'''
320
320
self .snap_points .extend (coords )
321
321
322
322
# print("Adding " + name)
323
- newcolour = (random .randint (0 , 255 ), 0 , random .randint (0 , 255 ))
323
+ if line_colour is None :
324
+ line_colour = (random .randint (0 , 255 ), 0 , random .randint (0 , 255 ))
324
325
layer_name = f"{ name } -{ self .counter } "
325
326
curpoly = mp_slipmap .SlipPolygon (
326
327
layer_name ,
327
328
coords ,
328
329
layer = 2 ,
329
330
linewidth = 2 ,
330
- colour = newcolour ,
331
+ colour = line_colour ,
331
332
)
332
333
self .add_map_object (curpoly )
333
334
self .allayers .append (curpoly )
@@ -337,7 +338,9 @@ def add_polygon(self, name, coords):
337
338
def loadkml (self , filename ):
338
339
'''Load a kml from file and put it on the map'''
339
340
# Open the zip file
340
- nodes = kmlread .readkmz (filename )
341
+ kml = kmlread .KMLRead (filename )
342
+ kml .parse ()
343
+ nodes = kml .placemark_nodes ()
341
344
342
345
self .snap_points = []
343
346
@@ -347,15 +350,15 @@ def loadkml(self, filename):
347
350
return
348
351
for n in nodes :
349
352
try :
350
- point = kmlread .readObject (n )
353
+ point = kml .readObject (n )
351
354
except Exception :
352
355
continue
353
356
if point is None :
354
357
continue
355
358
356
359
# and place any polygons on the map
357
360
if isinstance (point , kmlread .Polygon ):
358
- self .add_polygon (point .name , point .vertexes )
361
+ self .add_polygon (point .name , point .vertexes , point . line_colour )
359
362
360
363
# and points - barrell image and text
361
364
if isinstance (point , kmlread .Point ):
0 commit comments