diff --git a/README.md b/README.md index 4063ea1..79532d4 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ Preview map layer files in your web browser using [Sublime Text 3](https://www.s ## Supported Formats - [GeoJSON](https://geojson.org/) + + Currently support the following types: + - [Features](https://tools.ietf.org/html/rfc7946#section-3.2) + - [FeatureCollections](https://tools.ietf.org/html/rfc7946#section-3.3) + - [TopoJSON](https://github.com/topojson/topojson/wiki) ## Installation diff --git a/map_preview.py b/map_preview.py index 92e38b0..e99f5e8 100644 --- a/map_preview.py +++ b/map_preview.py @@ -45,18 +45,23 @@ def run(self, edit): # check if json valid spatial type if "type" in validateJson: # check if valid GeoJSON - if validateJson["type"] == "FeatureCollection": + if validateJson["type"] == "FeatureCollection" or validateJson["type"] == "Feature": type = "geojson" html = wm.render(viewText, type) - else: + elif validateJson["type"] == "Topology": type = "topojson" html = wm.render(viewText, type) - # update output HTML file - tmp_fullpath = get_temp_preview_path(view) - save_utf8(tmp_fullpath, html) + try: + html + except NameError: + sublime.error_message("Could not convert file.\n\n Not valid GeoJSON or TopoJSON") + else: + # update output HTML file + tmp_fullpath = get_temp_preview_path(view) + save_utf8(tmp_fullpath, html) - webbrowser.open_new_tab("file:///" + tmp_fullpath) + webbrowser.open_new_tab("file:///" + tmp_fullpath) else: sublime.error_message("Could not convert file.\n\n Not valid spatial type")