MCPcopy Create free account
hub / github.com/comaps/comaps / convert

Method convert

tools/python/google_maps_bookmarks.py:251–270  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

249 tree.write(self.output_file)
250
251 def convert(self):
252 with open(self.input_file, 'r') as file:
253 content = file.read().strip()
254 if not content:
255 raise ValueError(f"The file {self.input_file} is empty or not a valid JSON file.")
256
257 mime_type, _ = mimetypes.guess_type(self.input_file)
258 if mime_type == 'application/geo+json' or mime_type == 'application/json':
259 self.process_geojson_features(content)
260 elif mime_type == 'text/csv':
261 self.process_csv_features(content)
262 else:
263 raise ValueError(f"Unsupported file format: {self.input_file}")
264
265 # Write to output file in the desired format, KML or GPX
266 if self.output_format == 'kml':
267 self.write_kml()
268 elif self.output_format == 'gpx':
269 self.write_gpx()
270 print("Exported Google Saved Places to " + path.abspath(self.output_file))
271
272if __name__ == "__main__":
273 parser = argparse.ArgumentParser(description="Convert Google Maps saved places to KML or GPX.")

Callers 1

Calls 5

process_csv_featuresMethod · 0.95
write_kmlMethod · 0.95
write_gpxMethod · 0.95
readMethod · 0.45

Tested by

no test coverage detected