Change Layer API
See original GitHub issueRelated with https://github.com/CartoDB/cartoframes/pull/586
Context
We want to change how we currently use the different layers we have:
QueryLayer
LocalLayer
Layer
First Approach
We’ve thought the following solution as a starting point to address this issue. We (backend team) are already working on a Dataset
class. This class is going to handle local/remote datasets, but for this issue, I’m going to talk about it as a black box.
Since a Dataset
is one of the source types we’ve in CARTO VL, we could have, additionally a SQL
or Query
class and a GeoJSON
class. These clases aren’t our priority for this task at this point, but let’s just imagine we’ll have these “source” classes.
Each layer will have a source class. We’d have a main Layer
class, that will receive this source class and a context (we’ll talk later about the contexts).
Then, we’d have three classes that’d inherit from Layer
: PointLayer
, LineLayer
and PolygonLayer
. What’s the advantage of having a class per geometry type? First, that we know at first glance the geometry of the layer. But also, that we could implement specific helper methods depending on the geometry, and that’d be very cool.
- Contexts TBD
It’d be useful to provide a context per source, so you can combine both local and remote datasets, for instance. By declaring the context in the map, this is the context the layer would use, but you’d be able to use an specific context for a layer.
For example:
vl.Map([
vl.PointLayer('dataset_1'),
vl.PolygonLayer('dataset_2')
],
context=context
)
vl.Map([
vl.PointLayer('SELECT * FROM dataset_1 WHERE cat = "cat"'),
vl.PolygonLayer(vl.GeoJSON('file_name.geojson'))
],
context=context
)
To Do
Note: Front + Back should be involved in this task
- Refactor base Layer class
- ~Create PointLayer, LineLayer and PolygonLayer~ ❄️
- Define how to integrate the Source (Dataset)
- Create SQL & GeoJSON sources
Other ToDos moved to https://github.com/CartoDB/cartoframes/issues/629
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (14 by maintainers)
After the yesterday talk, @elenatorro and I have talked and we thought there are 2 different tasks/parts in this issue:
vl.source.SQL
,vl.source.GeoJSON
, …VL way
to render the map. To do this, if I am not wrong, we don’t have to integrate anything between backend and frontend.pandas.DataFrame
to VL. To do this, we have to integrate backend and frontend (find a way to send apandas.DataFrames
to VL). The yestarday proposal was talking about this case, because I think having a full local way to render a map is powerful. I want to talk about it with @javitonino & @alrocar. But of course, any feedback is welcome.From CARTOFrames documentation, it’s a GeoDataFrame --> http://geopandas.org/reference/geopandas.GeoDataFrame.html
I’m ok with this, let’s freeze
Create PointLayer, LineLayer and PolygonLayer
for now. Just pointing that these layers would be a syntax sugar for theLayer
class, they wouldn’t require a lot of extra implementation.