https://github.com/adamfranco/openmapsamples
A library to generate and provide sample data for testing vector-based map renderings.
https://github.com/adamfranco/openmapsamples
maplibre openstreetmap osm vector-tiles
Last synced: about 1 year ago
JSON representation
A library to generate and provide sample data for testing vector-based map renderings.
- Host: GitHub
- URL: https://github.com/adamfranco/openmapsamples
- Owner: adamfranco
- License: lgpl-3.0
- Created: 2022-01-20T22:07:17.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-17T19:48:12.000Z (about 4 years ago)
- Last Synced: 2025-03-24T11:56:53.721Z (about 1 year ago)
- Topics: maplibre, openstreetmap, osm, vector-tiles
- Language: JavaScript
- Homepage: https://adamfranco.github.io/OpenMapSamples-examples/
- Size: 57.6 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenMapSamples
OpenMapSamples is a library to generate and provide sample data for testing vector-based map renderings. Sample data is returned as GeoJSON and can be rendered by mapping systems and styles to validate their coverage of combinations of data.
You can view a demonstration of this control at https://adamfranco.github.io/OpenMapSamples-examples/.
## Structure
### Library classes
OpenMapSamples allows the creation, registration, and return of a collection of `Sample`s for rendering. Each `Sample` has a name and description plus a list of 0 or more `Layer`s.
Each `Sample` has methods to return a starting zoom level, center coordinate, and can access the GeoJSON data of its layers.
Each `Layer` can have 0 or more `SampleData` added to it. The only requirement of `SampleData` classes that they implement a `getGeoJson(z)` method.
* A `SimpleSample` returns hand-coded GeoJSON.
* A `WayRowsSample` takes a list of tags for each row, and a list of tags for each column and applies those to dynamically generate GeoJSON for each zoom/center requested. (For example, showing different highway types with bridge, tunnel, embankment, etc tags applied at each level). Lengths and spacing are dynamically chosen based on the zoom requested.
* A `WayIntersectionSample` takes a list of tags for each row/column, then builds a cross-hatched grid that show each type of way intersecting with each other type.
* A `WayOverlapSample` is the same as the `WayIntersectionSample`, but with ways overlapping rather than intersecting on shared nodes (For example, showing tunnel and bridge levels overlapping).
* Other samples could auto generate overlapping or non-overlapping grids of areas, nodes, etc.
### Samples
The `samples/` directory contains a repository of samples with full data that can be used directly to test map renderings. While users are welcome to utilize the library classes to develop their own data-sets, consider contributing useful samples to back to this project.
#### OpenMapTiles
The `samples/OpenMapTiles/` directory contains samples with properties matching the [OpenMapTiles vector-data schema](https://openmaptiles.org/schema/).
Example screenshots of the OpenMapTiles samples as rendered by the MapTiler "OSM Standard" style:



## Controls and integrations
The OpenMapSamples classes and Samples are renderer agnostic and may be used by any map display system.
### MapLibre
See [adamfranco/OpenMapSamples-MapLibre](https://github.com/adamfranco/OpenMapSamples-MapLibre) for a MapLibre control that can be added to MapLibre based maps. This control provides a dialog selecting samples and temporarily replacing map content with sample data.
### OpenLayers
_To do..._
## Development
To add an additional sample data set in the OpenMapTiles schema:
1. Add a new script under `samples/OpenMapTiles/`. This script should export a `Sample` as default.
2. Add the new Sample to `samples/OpenMapTiles/index.js` to register it for use.
3. Run `npm run test` to ensure that your new sample is returning valid GeoJSON.
To test your sample in a browser, clone the [OpenMapTilesSamples-examples](https://github.com/adamfranco/OpenMapSamples-examples) repository in the same parent-directory as `OpenMapSamples/` and configure it:
cd ../
git clone git@github.com:adamfranco/OpenMapSamples-examples.git
cd OpenMapSamples-examples/
npm install
npm run config
# Edit config.js and add your MapTiler cloud key.
npm run dev-openmapsamples
npm start