Code Monkey home page Code Monkey logo

basemap-layers's Introduction

basemap-layers (WIP)

This module is intended to contain basemap layers for deck.gl.

See the online documentation for more information.

basemap-layers's People

Contributors

dependabot[bot] avatar ibgreen avatar kylebarron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mapsgeek

basemap-layers's Issues

PathMarkerLayer

This old PR (visgl/deck.gl#1003) contained a PathMarkerLayer, which rendered symbols along a path. I might end up reimplementing this layer anyways, for e.g. text labels along roads.

screen shot 2017-10-09 at 7 44 31 pm

How to retain property information in rendered deck layers?

If I combine multiple source layers into a single deck layer for performance reasons, then by default when you pick any line within the PathLayer, you'd pick the entire collection. However, there must be some way for picking to pick a subset, since a GeoJSON layer and Path Layer already do this... You can add many objects but pick one

Filter key

Use the mapbox style spec's filter!

var ff = require('@mapbox/mapbox-gl-style-spec').featureFilter;

// will match a feature with class of street_limited,
// AND an admin_level less than or equal to 3,
// that's NOT a polygon.
var filter = [
    "all",
    ["==", "class", "street_limited"],
    ["<=", "admin_level", 3],
    ["!=", "$type", "Polygon"]
]

// will match a feature that has a class of
// wetland OR wetland_noveg.
// ["in", "class", "wetland", "wetland_noveg"]

// testFilter will be a function that returns a boolean
var testFilter = ff(filter);

// Layer feature that you're testing. Must have type
// and properties keys.
var feature = {
    type: 2,
    properties: {
       class: "street_limited",
       admin_level: 1
    }
};

// will return a boolean based on whether the feature matched the filter
return testFilter({zoom: 0}, feature);

Note that to validate filter, you'll probably need to pass the filter keys to validateFilter manually, because the rest of the specification won't be a valid Mapbox GL style.

Shared layer attributes

What shared deck.gl layer attributes do you need to include, i.e.

  • id

And what mapbox-style-spec-like attributes?

  • source
  • source-layer

Ideas about rendering

How should layers be created from the spec?

new DeckglStyleSpecLayer({...})

Props:

  • Style JSON
  • features (optional, because I can download them from the style json sources section. If provided, layer names must match.)

Then inside renderSubLayers I render individual layers.

How should the data process work?

  • Render individual deck.gl layer for every layer object in the Style JSON? I'm not sure what the overhead is on number of layers, but that seems like a lot, especially if rendered as a sublayer of a tile layer. You could have 20+, 50+ layers per tile. That seems like too much.
  • Then the other option is to combine Style JSON layers into a single Deck.gl layer per type of data. I.e. only ~3 layers would be rendered as sublayers of the style spec layer, one PathLayer, one SymbolLayer, one TextLayer (though start with the PathLayer).

I think the latter option makes more sense, so the following will pertain to that.

Use unchanged portion of mapbox style spec

It's worth exploring whether you can use a portion of the Mapbox style spec, without additions within the Style JSON.

Advantages

  • Can use the entire breadth of Mapbox Style expressions, etc
  • Don't have to do any of my own parsing
  • Can define specific fields that I use, while ignoring all other fields.

Expressions

To parse expressions:

arr = [ '==', 'brunnel', 'tunnel' ]
stylespec.expression.isExpression(arr)
// true
exp = stylespec.expression.createExpression(arr)
{
  result: 'success',
  value: StyleExpression {
    expression: Literal { type: [Object], value: false },
    _warningHistory: {},
    _evaluator: EvaluationContext {
      globals: undefined,
      feature: null,
      featureState: null,
      formattedSection: null,
      _parseColorCache: {},
      availableImages: null
    },
    _defaultValue: null,
    _enumValues: null
  }
}

Note that value is a StyleExpression object, which has an evaluate() method.

Note that an expression must begin with one of these keys:
https://github.com/mapbox/mapbox-gl-js/blob/9489d7654ef9bb36a44c9b98446b84eccb98628a/src/style-spec/expression/definitions/index.js#L49-L83

Properties

Need to do a deeper dive here. This seems to be the best way to loop over properties. Look closer at the flow types for help

stylespec.visit.eachProperty(style, {paint: true}, x => console.log(x))

Implement my own MVTLoader

This could have several performance improvements:

  • Deal with single web worker. Instead of loading/parsing the MVT in one worker, returning the data, and then passing to this package in another web worker, loading, parsing, and styling happens in the same worker.
  • Use TypedArrays. In the current MVTLoader, everything is parsed as regular JS objects and arrays. If you parse the MVT at the same time as you're creating binary objects to return to Deck.gl, maybe you'd be able to always use TypedArrays
  • Load directly to dict/Map. Currently, loaders.gl parses to a flat array, which I then need to loop over again when searching for features pertaining to a particular source layer. Could theoretically always work directly with the pbf, but would it take time to parse features every time you iterate over the pbf? Could be better to parse the mvt once for the layers you know you'll be looking at later.

Use binary attributes

For now while developing I'll just stick with geojson features/js objects, but eventually you should support binary attributes for performance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.