Skip to content

Commit

Permalink
Merge pull request #197 from emilhe/flatgeobuf
Browse files Browse the repository at this point in the history
Flatgeobuf
  • Loading branch information
emilhe authored Aug 30, 2023
2 parents 9198e2c + 379d0dd commit ed82ab7
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 21 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [1.0.8] - 2023-08-27

### Added

- Add support for `flatgeobuf` file format, including bounding box filtering
- Add extra optional options (`svg`, `geobuf`, `all`)

### Changed

- Restored support for `geobuf` file format

## [1.0.7] - 2023-08-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion dash_leaflet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

# region Async modifications

async_resources = ["LocateControl", "MeasureControl", "EditControl.ts", "GeoJSON"]
async_resources = ["LocateControl", "MeasureControl", "EditControl.ts", "GeoJSON", "geobuf", "flatgeobuf"]

_js_dist.extend(
[
Expand Down
22 changes: 22 additions & 0 deletions dash_leaflet/express.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import logging

import dash_leaflet as dl
import base64


def _try_import_geobuf():
install_txt = "e.g. via pip by running 'pip install dash-leaflet[geobuf]' or 'pip install dash-leaflet[all]'."
try:
import geobuf
import google.protobuf
except ImportError as ex:
logging.error(f"Unable to import [geobuf/protobuf]. Please install it, {install_txt}")
raise ex
if google.protobuf.__version__ != "3.20.0":
version_txt = f"The recommended protobuf version is 3.20.0 (you have {google.protobuf.__version__})"
logging.warning(f"{version_txt}. You can fix it {install_txt}")
return geobuf


def categorical_colorbar(*args, categories, colorscale, **kwargs):
Expand All @@ -16,3 +33,8 @@ def dicts_to_geojson(dicts, lat="lat", lon="lon"):
feature["properties"] = {prop: d[prop] for prop in props}
geojson["features"].append(feature)
return geojson


def geojson_to_geobuf(geojson):
geobuf = _try_import_geobuf()
return base64.b64encode(geobuf.encode(geojson)).decode()
Loading

0 comments on commit ed82ab7

Please sign in to comment.