|
|
@ -94,29 +94,24 @@ def export_kml_file(dirname, fnames, kml_name):
|
|
|
|
kml = simplekml.Kml()
|
|
|
|
kml = simplekml.Kml()
|
|
|
|
|
|
|
|
|
|
|
|
for fname in fnames:
|
|
|
|
for fname in fnames:
|
|
|
|
try:
|
|
|
|
print('Reading {}...'.format(fname))
|
|
|
|
with Image.open(os.path.join(dirname, fname)) as image:
|
|
|
|
with Image.open(os.path.join(dirname, fname)) as image:
|
|
|
|
exif_data = get_exif_data(image)
|
|
|
|
exif_data = get_exif_data(image)
|
|
|
|
|
|
|
|
|
|
|
|
print('Reading {}...'.format(fname))
|
|
|
|
lat, lon = get_lat_lon(exif_data)
|
|
|
|
|
|
|
|
pnt = kml.newpoint(name=fname)
|
|
|
|
lat, lon = get_lat_lon(exif_data)
|
|
|
|
pnt.coords = [(lon, lat)]
|
|
|
|
pnt = kml.newpoint(name=fname)
|
|
|
|
|
|
|
|
pnt.coords = [(lon, lat)]
|
|
|
|
# Add content to popup window
|
|
|
|
|
|
|
|
pnt.description = ('<![CDATA[ <img src={} height="500px" />]]>'.format(
|
|
|
|
# Add content to popup window
|
|
|
|
os.path.join(dirname, fname)))
|
|
|
|
pnt.description = (
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.scale = 1
|
|
|
|
'<![CDATA[ <img src={} height="500px" />]]>'.format(
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.icon.href = (
|
|
|
|
os.path.join(dirname, fname)))
|
|
|
|
'http://maps.google.com/'
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.scale = 1
|
|
|
|
'mapfiles/kml/shapes/camera.png')
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.icon.href = (
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.scale = 2
|
|
|
|
'http://maps.google.com/'
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.icon.href = os.path.join(
|
|
|
|
'mapfiles/kml/shapes/camera.png')
|
|
|
|
dirname, fname)
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.scale = 2
|
|
|
|
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.icon.href = os.path.join(
|
|
|
|
|
|
|
|
dirname, fname)
|
|
|
|
|
|
|
|
except OSError:
|
|
|
|
|
|
|
|
print('Skipping {} (not a valid image).'.format(fname))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kml.save(kml_name)
|
|
|
|
kml.save(kml_name)
|
|
|
|
|
|
|
|
|
|
|
@ -128,8 +123,9 @@ def main():
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
# Get files in image directory
|
|
|
|
# Get files in image directory
|
|
|
|
|
|
|
|
ext = ['.jpg', '.jpeg', '.tif', '.tiff']
|
|
|
|
dirname = args.folder
|
|
|
|
dirname = args.folder
|
|
|
|
fnames = os.listdir(dirname)
|
|
|
|
fnames = [f for f in os.listdir(dirname) if os.path.splitext(f)[-1] in ext]
|
|
|
|
|
|
|
|
|
|
|
|
# Create kml file
|
|
|
|
# Create kml file
|
|
|
|
kml_name = dirname + '.kml'
|
|
|
|
kml_name = dirname + '.kml'
|
|
|
|