Skip to content

feat(core): Add public stringifyGeoJSON to mbgl::style::conversion#4345

Open
yuiseki wants to merge 1 commit into
maplibre:mainfrom
yuiseki:add-mbgl-stringify-geojson
Open

feat(core): Add public stringifyGeoJSON to mbgl::style::conversion#4345
yuiseki wants to merge 1 commit into
maplibre:mainfrom
yuiseki:add-mbgl-stringify-geojson

Conversation

@yuiseki

@yuiseki yuiseki commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects. This only adds a small mbgl::* wrapper around geojson-cpp. geojson-cpp is ISC-licensed, already vendored in maplibre-native-base, and already used directly in src/mbgl (the within and distance expressions, and rapidjson_conversion.hpp). No code is copied from any Mapbox project.
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs. Not a visual change.
  • Write tests for all new functionality. Happy to add a round-trip test if you want it. The function is a one-line wrapper around mapbox::geojson::stringify.
  • Document any changes to public APIs.
  • Post benchmark scores. N/A.
  • Add an entry to CHANGELOG.md. Can add on request.

What this does

Adds std::string mbgl::style::conversion::stringifyGeoJSON(const GeoJSON&). It is the serialize counterpart to the existing parseGeoJSON, and it just calls mapbox::geojson::stringify.

Why

The core amalgam is built with armerge --keep-symbols 'mbgl.*', so only mbgl::* symbols are exported and the bundled mapbox::geojson::* functions are hidden on purpose. A consumer that links the amalgam can already parse GeoJSON through the public parseGeoJSON, but there is no public way to turn a GeoJSON back into a string. This adds that missing piece, so downstream bindings do not have to reach into mapbox::geojson or bundle their own JSON writer.

This is what maplibre-native-rs needs in order to bring back its GeoJson::to_json_string (see maplibre/maplibre-native-rs#237).

Related

@github-actions

Copy link
Copy Markdown
Contributor

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +616  +0.0%    +136    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4345-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +51% +59.1Mi  +467% +27.9Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4345-compared-to-legacy.txt

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0167         -0.0167             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-4345-compared-to-main.txt

@yuiseki yuiseki changed the title Add public stringifyGeoJSON to mbgl::style::conversion feat: Add public stringifyGeoJSON to mbgl::style::conversion Jun 15, 2026
@yuiseki yuiseki changed the title feat: Add public stringifyGeoJSON to mbgl::style::conversion feat(core): Add public stringifyGeoJSON to mbgl::style::conversion Jun 15, 2026
ciscorn added a commit to maplibre/maplibre-native-rs that referenced this pull request Jun 19, 2026
I found `MLN_PRECOMPILE=1` builds are currently broken, but this was not
caught by CI. This PR updates the precompiled MapLibre Native release
and fixes the link setup:

(Some of these changes are based on #237 by @yuiseki - thanks!)

- Update the precompiled MLN release to the [latest core
release](https://github.com/maplibre/maplibre-native/releases/tag/core-fa8a9c8e3261ce64940127aecc1d52f540c21c57)
- Restore the vendored bridge include path
- Link required system libraries for precompiled builds (`libuv` on
non-Apple targets, `sqlite3` on Apple targets)
- Avoid direct `mapbox::geojson` symbols from the Rust bridge, since
they are hidden in the amalgam
- Comment out now-unused `GeoJson::to_json_string()` - no public mbgl
API yet maplibre/maplibre-native#4345
- Add precompiled CI coverage to prevent regressions

Note: macOS still does not work with `MLN_PRECOMPILE=1` because the
amalgam (built with `armerge --keep-symbols 'mbgl.*'`) also hides the
C++ exception RTTI symbols.

---------

Co-authored-by: yuiseki <yui.matsumura@geolonia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes that affect the C++ core of MapLibre Native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant