Skip to content

A library to generate and provide sample data for testing vector-based map renderings.

License

Notifications You must be signed in to change notification settings

claysmalley/OpenMapSamples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Samples for rendering. Each Sample has a name and description plus a list of 0 or more Layers.

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.

Example screenshots of the OpenMapTiles samples as rendered by the MapTiler "OSM Standard" style:

Highway Attributes

Highway Intersections

Highway Bridge & Tunnel

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 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 repository in the same parent-directory as OpenMapSamples/ and configure it:

cd ../
git clone [email protected]: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

About

A library to generate and provide sample data for testing vector-based map renderings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%