Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layers Fail When Loading from CDN #109

Closed
jaredlander opened this issue Feb 27, 2024 · 34 comments · Fixed by #111
Closed

Layers Fail When Loading from CDN #109

jaredlander opened this issue Feb 27, 2024 · 34 comments · Fixed by #111

Comments

@jaredlander
Copy link

Loving the abilities that geoarrow gives us and I'm trying to use it as much as possible. I managed to use Geoarrow layers with a deck.gl map when importing the packages in the JS code. But when trying to load the JS packages from CDNs, I get this error.

dist.dev.js:31311 deck: initialization of GeoArrowScatterplotLayer({id: 'scatter'}): Cannot read properties of undefined (reading 'isPointVector') TypeError: Cannot read properties of undefined (reading 'isPointVector')
    at wt._renderLayersPoint (trips-layer.ts:190:4)
    at wt.renderLayers (trips-layer.ts:190:4)
    at wt._postUpdate (dist.dev.js:35778:36)
    at wt._update (dist.dev.js:35413:14)
    at wt._initialize (dist.dev.js:35368:12)
    at Nd._initializeLayer (dist.dev.js:27809:15)
    at Nd._updateSublayersRecursively (dist.dev.js:27784:18)
    at Nd._updateLayers (dist.dev.js:27758:12)
    at Nd.setLayers (dist.dev.js:27729:12)
    at Nd.updateLayers (dist.dev.js:27735:14)

Here is the code when loading from CDNs. I suspect the error may be caused by const geoarrowLayers = window['@geoarrow/deck']['gl-layers']; and new geoarrowLayers.GeoArrowScatterplotLayer({...}), but I'm far from certain.

I tried to make it as self-contained as possible, the only thing you'll need to change is the URL for the data files, since my server is not setup for CORS. For instance, download the files at https://jaredlander.com/data/hood_centers.arrow and https://jaredlander.com/data/hood_polys.geojson then put them somewhere accessible to your code and edit the corresponding lines.

The GeoJsonLayer layer is just there to help make sure things are working and can be removed for debugging purposes.

<head>
    <meta charset='UTF-8' />
    <title>Recreating Leaflet</title>
    <script src="https://cdn.jsdelivr.net/npm/apache-arrow@15.0.0/Arrow.es2015.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/deck.gl@8.9.34/dist/dist.dev.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@geoarrow/deck.gl-layers@0.3.0-beta.14/dist/dist.umd.min.js"></script>
    <style>
        map {
            position: absolute;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
        }

        body {
            font-family: Helvetica, Arial, sans-serif;
            width: 100vw;
            height: 100vh;
            margin: 0;
        }

        #holder {
            border-color: red;
            border-width: 1px;
            border-style: solid;
            position: relative;
            height: 600px;
            width: 95%;
        }
    </style>
</head>

<body>
    <div id="holder"></div>
    <script type="module">
        const geoarrowLayers = window['@geoarrow/deck']['gl-layers'];

        const GEOARROW_POINT_DATA = "https://jaredlander.com/data/hood_centers.arrow";
        const GEOJSON_POLY_DATA = "https://jaredlander.com/data/hood_polys.geojson";

        const hoods = await Arrow.tableFromIPC(fetch(GEOARROW_POINT_DATA));

        const INITIAL_VIEW_STATE = {
            latitude: 40.72875,
            longitude: -74.00005,
            zoom: 10,
            bearing: 0,
            pitch: 0
        };

        const mainMap = new deck.DeckGL({
            initialViewState: INITIAL_VIEW_STATE,
            id: 'mainMap',
            controller: true,
            container: "holder",
            layers: [
                new deck._WMSLayer({
                    data: `https://basemap.nationalmap.gov:443/arcgis/services/USGSImageryTopo/MapServer/WmsServer`,
                    layers: ['0'],
                    pickable: true,
                }),
                new deck.GeoJsonLayer({
                    id: 'poly',
                    data: GEOJSON_POLY_DATA,
                    pickable: true,
                    getFillColor: [80, 0, 200],
                    getPointRadius: 100,
                    autoHighlight: true
                }),
                new geoarrowLayers.GeoArrowScatterplotLayer({
                    id: 'scatter',
                    data: hoods,
                    pickable: true,
                    getFillColor: [80, 0, 200],
                    getPosition: d => d.getChild('geometry'),
                    getRadius: 300,
                })
            ]
        });
    </script>
</body>

</html>

When I use import statements in the JS code, as below, everything works. I'm not sure if my code above had an error or if there is an issue with the CDN.

<!doctype html>
<html>

<head>
    <meta charset='UTF-8' />
    <title>Recreating Leaflet</title>
</head>

<body>
    <div id="holder">
    </div>
    <script src="out/reprex_app.js" type="module"></script>
</body>
</html>
import { GeoJsonLayer } from '@deck.gl/layers'
import { _WMSLayer } from '@deck.gl/geo-layers'
import { Deck } from '@deck.gl/core'
import * as arrow from "apache-arrow";
import { GeoArrowScatterplotLayer } from '@geoarrow/deck.gl-layers'

const GEOARROW_POINT_DATA = "https://jaredlander.com/data/hood_centers.arrow";
const GEOJSON_POLY_DATA = "https://jaredlander.com/data/hood_polys.geojson";

const hoods = await arrow.tableFromIPC(fetch(GEOARROW_POINT_DATA));

const INITIAL_VIEW_STATE = {
    latitude: 40.72875,
    longitude: -74.00005,
    zoom: 10,
    bearing: 0,
    pitch: 0
};

const mainMap = new Deck({
    initialViewState: INITIAL_VIEW_STATE,
    id: 'mainMap',
    controller: true,
    container: "holder",
    layers: [
        new _WMSLayer({
            data: `https://basemap.nationalmap.gov:443/arcgis/services/USGSImageryTopo/MapServer/WmsServer`,
            layers: ['0'],
            pickable: true,
        }),
        new GeoJsonLayer({
            id: 'poly',
            data: GEOJSON_POLY_DATA,
            // Styles
            // Interactive props
            pickable: true,
            getFillColor: [80, 0, 200],
            getPointRadius: 100,
            autoHighlight: true
        }),
        new GeoArrowScatterplotLayer({
            id: 'scatter',
            data: hoods,
            pickable: true,
            getFillColor: [180, 0, 100],
            getPosition: d => d.getChild('geometry'),
            getRadius: 300,
        })
    ]
});
@kylebarron
Copy link
Member

Cannot read properties of undefined (reading 'isPointVector')

isPointVector is defined in geoarrow-js, and so it looks like somehow it's missing geoarrow-js in the bundle? I'm really bad at JS bundling, so I'm very receptive to changes if you figure out what's going wrong.

@jaredlander
Copy link
Author

I guarantee I know less than you, but I don't see that file listed at the CDN https://cdn.jsdelivr.net/npm/@geoarrow/deck.gl-layers@0.3.0-beta.14/dist/. So I'm guessing somehow it didn't make it in there.

@kylebarron
Copy link
Member

It's listed as a dependency though, shouldn't it be bundled automatically?

"@geoarrow/geoarrow-js": "^0.3.0",

@jaredlander
Copy link
Author

jaredlander commented Feb 27, 2024

In fairness, I could be completely misreading that site. I just checked the minified file that is served (https://cdn.jsdelivr.net/npm/@geoarrow/geoarrow-js@0.3.0/dist/geoarrow.umd.min.js) and I think the function is in there.

If it's not in there, that's one problem. If it is in there, then why doesn't it work in the HTML?

@kylebarron
Copy link
Member

Potentially a rollup bundling issue/misconfiguration? Probably the first place I'd check

@jaredlander
Copy link
Author

I don't even know where to begin with that. I'll ask some JS friends.

@joemarlo
Copy link

joemarlo commented Mar 4, 2024

I just cloned and built it locally. I'm seeing unresolved dependencies for GeoArrow and a few other modules. I'm not an expert here either but I did try (with no luck) adding resolve() to the rollup.config.js to see if it could bundle GeoArrow into it. I also tried adding GeoArrow to the external dependencies. Again, with no luck.

Here are the unresolved dependencies warnings:

npm run build

> @geoarrow/deck.gl-layers@0.3.0-beta.14 build
> npm run build:tsc && npm run build:rollup


> @geoarrow/deck.gl-layers@0.3.0-beta.14 build:tsc
> tsc


> @geoarrow/deck.gl-layers@0.3.0-beta.14 build:rollup
> rollup -c rollup.config.js


./src/index.ts → dist/dist.es.mjs...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@geoarrow/geoarrow-js (imported by "src/arc-layer.ts", "src/column-layer.ts", "src/heatmap-layer.ts", "src/path-layer.ts", "src/point-cloud-layer.ts", "src/polygon-layer.ts", "src/scatterplot-layer.ts", "src/solid-polygon-layer.ts", "src/text-layer.ts", "src/trips-layer.ts" and "src/utils.ts")
@deck.gl/geo-layers/typed (imported by "src/h3-hexagon-layer.ts" and "src/trips-layer.ts")
@deck.gl/aggregation-layers/typed (imported by "src/heatmap-layer.ts")
threads (imported by "src/solid-polygon-layer.ts")
created dist/dist.es.mjs in 3.1s

./src/index.ts → dist/index.d.ts...
created dist/index.d.ts in 2.2s

./src/index.ts → dist/dist.cjs...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@geoarrow/geoarrow-js (imported by "src/arc-layer.ts", "src/column-layer.ts", "src/heatmap-layer.ts", "src/path-layer.ts", "src/point-cloud-layer.ts", "src/polygon-layer.ts", "src/scatterplot-layer.ts", "src/solid-polygon-layer.ts", "src/text-layer.ts", "src/trips-layer.ts" and "src/utils.ts")
@deck.gl/geo-layers/typed (imported by "src/h3-hexagon-layer.ts" and "src/trips-layer.ts")
@deck.gl/aggregation-layers/typed (imported by "src/heatmap-layer.ts")
threads (imported by "src/solid-polygon-layer.ts")
created dist/dist.cjs in 1.8s

./src/index.ts → dist/dist.umd.js...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@geoarrow/geoarrow-js (imported by "src/arc-layer.ts", "src/column-layer.ts", "src/heatmap-layer.ts", "src/path-layer.ts", "src/point-cloud-layer.ts", "src/polygon-layer.ts", "src/scatterplot-layer.ts", "src/solid-polygon-layer.ts", "src/text-layer.ts", "src/trips-layer.ts" and "src/utils.ts")
@deck.gl/geo-layers/typed (imported by "src/h3-hexagon-layer.ts" and "src/trips-layer.ts")
@deck.gl/aggregation-layers/typed (imported by "src/heatmap-layer.ts")
threads (imported by "src/solid-polygon-layer.ts")
(!) Missing global variable names
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to external modules:
@geoarrow/geoarrow-js (guessing "ga")
threads (guessing "threads")
created dist/dist.umd.js in 2.1s

@kylebarron
Copy link
Member

kylebarron commented Mar 4, 2024

Hmm. I suppose I never hit the downstream effects of these errors, since the only place I've used deck.gl-layers so far is in webpack esbuild in lonboard. (I've tried and failed to get geoarrow/deck.gl-layers to work in observable, so maybe it's similar issues).

Looking at the link at https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency, apparently rollup does not bundle external code by default??? What an annoying default.

So it turns out with your umd import, you do also need geoarrow.js and threads as well. Maybe there should be two UMD exports?

I tried to use nodeResolve from @rollup/plugin-node-resolve but got an error from earcut, presumably this mapbox/earcut#126. Maybe this is a good reason to switch to deck.gl's fork of earcut? https://github.com/uber-web/math.gl/blob/186e34918eadb4a7466085deee02e6ccf8372a23/modules/polygon/src/earcut.ts

Thoughts? I figure deck.gl is good to keep as an external but maybe the rest should be bundled?

@joemarlo
Copy link

joemarlo commented Mar 4, 2024

Right -- I thought sourcing GeoArrow within the <head> of Jared's reprex would solve the issue but I had no luck with including it before or after sourcing gl-layers. So perhaps somehow it's a namespace error?

I did also go down the route of including GeoArrow and threads within external properties and globals for the umd output (within rollup.config.js). Unfortunately I still had issues.

My naive take is to include them as external but I'm just not sure if it will still play nice if there is some sort of namespace error/issue.

@kylebarron
Copy link
Member

So perhaps somehow it's a namespace error?

It's probably this?

@geoarrow/geoarrow-js (guessing "ga")

When you add geoarrow-js to the <head>, does it add anything onto the global scope? I figure it's probably good to export geoarrow-js as a name like geoarrow, but presumably that's not happening right now either on the producer or the consumer side.

@kylebarron
Copy link
Member

Unfortunately I still had issues

What issues did you have with UMD and bundling?

@joemarlo
Copy link

joemarlo commented Mar 4, 2024

The namespace idea is more of hunch than anything concrete.

When adding geoarrow-js to <head> I can then access it via window['@geoarrow/geoarrow-js'].

Bear with me re: the bundling issues:

  1. Modified rollup.config.js to include '@geoarrow/geoarrow-js', 'threads' in external.
  2. Modified rollup.config.js to include '@geoarrow/geoarrow-js': 'GeoArrow', 'threads': 'Threads' to the umd globals output.
  3. In Jared's reprex, replaced the <script src=....> to the deck.gl-layers cdn with <script src="dist.umd.js"...> where dist.umd.js is the output of npm run build
  4. Throws the same error as Jared's above. If I include <script src="https://cdn.jsdelivr.net/npm/@geoarrow/geoarrow-js@0.3.0/dist/geoarrow.umd.min.js"></script> to include geoarrow then the below error is also thrown in addition to the original error.
transferable.ts:77 Uncaught TypeError: Cannot read properties of undefined (reading 'WINDING')
    at transferable.ts:77:1
    at transferable.ts:77:1
    at transferable.ts:77:1
    at transferable.ts:77:1
(anonymous) @ transferable.ts:77
(anonymous) @ transferable.ts:77
(anonymous) @ transferable.ts:77
(anonymous) @ transferable.ts:77

Thanks for helping sort this out. It's a real headache.

@joemarlo
Copy link

joemarlo commented Mar 4, 2024

A couple more items I tried with rollup.config.js:

  • I tried the variants '@geoarrow/geoarrow-js': 'ga' and '@geoarrow/geoarrow-js': 'geoarrow' in the umd globals output. This yields the same error
  • I tried including the plugins resolve(), nodeResolve(), and commonjs()
    • This leads to a circular dependencies error when npm run build

@kylebarron
Copy link
Member

When adding geoarrow-js to <head> I can then access it via window['@geoarrow/geoarrow-js'].

I would guess that we need to change the geoarrow-js bundling to expose it on the window as geoarrow and then here in @deck.gl-layers we can set '@geoarrow/geoarrow-js': 'geoarrow'

@joemarlo
Copy link

joemarlo commented Mar 4, 2024

That makes sense to me, I think? I'm definitely happy to test any changes if needed.

@kylebarron
Copy link
Member

Presumably this line needs to be changed in geoarrow-js. If you build that and then change the build config here to expect the name geoarrow, does it work then?

@joemarlo
Copy link

joemarlo commented Mar 5, 2024

Still no luck. Here are the steps I took and the error message below:

  1. Changed this line to geoarrow then rebundled using npm run build
  2. Added a line to to include '@geoarrow/geoarrow-js': 'geoarrow', and added a line to to include '@geoarrow/geoarrow-js',
  3. Moved over the respective umd.js and umd.js.map files to Jared's reprex and source those instead of the CDN
winding.ts:8 Uncaught TypeError: Cannot read properties of undefined (reading 'WINDING')
    at winding.ts:8:15
    at winding.ts:7:1
    at geoarrow.umd.js:1:504
    at geoarrow.umd.js:1:658
(anonymous) @ winding.ts:8
(anonymous) @ winding.ts:7
(anonymous) @ geoarrow.umd.js:1
(anonymous) @ geoarrow.umd.js:1

dist.dev.js:10414 WebGL: this extension has very low support on mobile devices; do not rely on it for rendering effects: WEBGL_polygon_mode

(anonymous) @ dist.dev.js:10414
globalThis.polyfillContext @ dist.dev.js:10399
zi @ dist.dev.js:10964
tr @ dist.dev.js:11176
$i @ dist.dev.js:11158
onCreateContext @ dist.dev.js:31620
onCreateContext @ dist.dev.js:16834
_createWebGLContext @ dist.dev.js:16974
(anonymous) @ dist.dev.js:16755
Promise.then (async)
start @ dist.dev.js:16751
lp @ dist.dev.js:31391
IR @ dist.dev.js:67076
(anonymous) @ (index):57
dist.dev.js:31311 deck: initialization of GeoArrowScatterplotLayer({id: 'scatter'}): Cannot read properties of undefined (reading 'isPointVector') TypeError: Cannot read properties of undefined (reading 'isPointVector')
    at It._renderLayersPoint (scatterplot-layer.ts:146:24)
    at It.renderLayers (scatterplot-layer.ts:111:19)
    at It._postUpdate (dist.dev.js:35778:36)
    at It._update (dist.dev.js:35413:14)
    at It._initialize (dist.dev.js:35368:12)
    at Nd._initializeLayer (dist.dev.js:27809:15)
    at Nd._updateSublayersRecursively (dist.dev.js:27784:18)
    at Nd._updateLayers (dist.dev.js:27758:12)
    at Nd.setLayers (dist.dev.js:27729:12)
    at Nd.updateLayers (dist.dev.js:27735:14)

I'm a bit out of my element so rather than bang my head against it I'll try later this week when I have time to take a deeper dive and understand what these changes actually do.

@kylebarron
Copy link
Member

I took a quick look at this.

One error is probably that geoarrow-js itself wasn't including node dependencies in the bundle. You can try from this PR geoarrow/geoarrow-js#26.

Another issue seems to be threads, which I can't get to load as an ESM module in observable.

I think traceback in your error might be fixed by the first PR. Let me know if you get a chance to test that

@joemarlo
Copy link

joemarlo commented Mar 5, 2024

Excellent, that PR fixed the TypeError. Now I'm getting a slightly different variation of the original error:

(anonymous) @ dist.dev.js:10414
dist.dev.js:31311 deck: initialization of GeoArrowScatterplotLayer({id: 'scatter'}): Right-hand side of 'instanceof' is not an object TypeError: Right-hand side of 'instanceof' is not an object
    at m (validate.ts:14:11)
    at It._renderLayersPoint (scatterplot-layer.ts:147:7)
    at It.renderLayers (scatterplot-layer.ts:111:19)
    at It._postUpdate (dist.dev.js:35778:36)
    at It._update (dist.dev.js:35413:14)
    at It._initialize (dist.dev.js:35368:12)
    at Nd._initializeLayer (dist.dev.js:27809:15)
    at Nd._updateSublayersRecursively (dist.dev.js:27784:18)
    at Nd._updateLayers (dist.dev.js:27758:12)
    at Nd.setLayers (dist.dev.js:27729:12)

This makes me think its missing a class or import statement somewhere.

@kylebarron
Copy link
Member

Hmm. That's coming from this line

if (accessorValue instanceof arrow.Vector) {

First, are you sure you have apache-arrow loaded? And it's set to arrow on the window?

If so, I believe the issue could be in the use of instanceof itself. In particular, if you had two versions of arrow, the instanceof check would only work with one of those versions. I.e. if geoarrow-js were bundling a separate version of arrow than your code, that instanceof check would fail (though I thought it would return false, not error...)

Maybe a better way to handle this would be to use duck typing to determine what's an arrow vector? As it is, in geoarrow-js I switched to using duck typing. E.g. the "data" attribute only exists on arrow.Vector not arrow.Data.

Maybe try switching that line in validate.ts here to use a duck-typed check?

@atmorling
Copy link
Contributor

Found this thread after running into similar issues.

After switching the above line and this one:

if (propInput instanceof arrow.Vector) {

I was able to get Jared's example working.

@kylebarron
Copy link
Member

Thanks! What did you use instead of that line?

@atmorling
Copy link
Contributor

For the check I used:
if (typeof propInput === 'object' && propInput !== null && "data" in propInput) {

which led to needing a type assertion on the line below:
const columnData = (propInput as arrow.Vector).data[chunkIdx];

Seems a bit dirty. I'm no js expert but I'd wager there's almost certainly a better way to handle it.

@joemarlo
Copy link

Thanks @kylebarron and @atmorling.

I've successfully been able to get @jaredlander's example working by taking these steps:

@kylebarron
Copy link
Member

deck.gl-layers/tree/kyle/bundling-fix
geoarrow-js/tree/kyle/fix-bundling

Clearly I can't decide on consistent branch naming 😄.

@jaredlander
Copy link
Author

After building based on @joemarlo's instructions on those branches, it looks like it is working by sourcing the right files. Thanks everyone!

@atmorling
Copy link
Contributor

I've been playing around some more with Geoarrow layers and ran into a similar issue when trying to create a GeoArrowPolygonLayer.

The error in this case is

deck: initialization of GeoArrowPolygonLayer({id: 'polys'}): c.List is not a constructor TypeError: c.List is not a constructor
    ut dist.umd.js:1
    ut dist.umd.js:1
    ut dist.umd.js:1
    _renderLayers dist.umd.js:1
    renderLayers dist.umd.js:1
    _postUpdate dist.dev.js:35778
    _update dist.dev.js:35413
    _initialize dist.dev.js:35368
    _initializeLayer dist.dev.js:27809

Which is hitting this line

It seems like an issue with the arrow object but I don't quite understand why it doesn't break when we hit arrow.Vector in the same function.

I've shamelessly repurposed Jared's repex into my own as below using the parquet file in this this zip as the data input.
The local geoarrow and deck.gl-layers imports are built from the branches mentioned above.

<html>
    <head>
        <meta charset='UTF-8' />
        <title>Poly Test</title>
        <script type="importmap">
            {"imports": {"parquet-wasm": "https://unpkg.com/parquet-wasm@0.6.0-beta.2/esm/parquet_wasm.js"}}
        </script>
        <script src="https://cdn.jsdelivr.net/npm/apache-arrow@15.0.0/Arrow.es2015.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/deck.gl@8.9.34/dist/dist.dev.min.js"></script>
        <script src='http://localhost/geoarrow.umd.js'></script>
        <script src='http://localhost/dist.umd.js'></script>
        <style>
            map {
                position: absolute;
                top: 0;
                left: 0;
                width: 100vw;
                height: 100vh;
            }

            body {
                font-family: Helvetica, Arial, sans-serif;
                width: 100vw;
                height: 100vh;
                margin: 0;
            }
            #holder {
                position: relative;
                height: 600px;
                width: 95%;
            }
        </style>
    </head>

    <body>
        <div id="holder"></div>
        <script type="module">
            import initSync, {readParquet} from 'parquet-wasm';

            const geoarrowLayers = window['@geoarrow/deck']['gl-layers'];

            async function loadData() {
                await initSync();

                const resp = await fetch("http://localhost/nepal.parquet");
                const arrayBuffer = await resp.arrayBuffer();
                const wasmTable = readParquet(new Uint8Array(arrayBuffer));
                const jsTable = Arrow.tableFromIPC(wasmTable.intoIPCStream());

                return jsTable;
            }

            const polys = await loadData();

            const INITIAL_VIEW_STATE = {
                latitude: 27.42,
                longitude: 85.19,
                zoom: 5,
                bearing: 0,
                pitch: 0
            };

            const mainMap = new deck.DeckGL({
                initialViewState: INITIAL_VIEW_STATE,
                id: 'mainMap',
                controller: true,
                container: "holder",
                layers: [
                    new deck.TileLayer({
                        data: 'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png',
                        
                            renderSubLayers: props => {
                                const {
                                    bbox: {west, south, east, north}
                                } = props.tile;
                        
                                return new deck.BitmapLayer(props, {
                                    data: null,
                                    image: props.data,
                                    bounds: [west, south, east, north]
                                });
                            }
                        }),

                    /* this works
                    new geoarrowLayers.GeoArrowSolidPolygonLayer({
                        id: 'polys',
                        data: polys,
                        getFillColor: [80, 0, 200]
                    })*/

                    new geoarrowLayers.GeoArrowPolygonLayer({
                        id: 'polys',
                        data: polys,
                        filled: true,
                        stroked: true,
                        getFillColor: [80, 0, 200],
                        getLineColor: [255, 255, 255],
                        getLineWidth: 10
                    })
                ]
            });
        </script>
    </body>
</html>

@kylebarron
Copy link
Member

I've been pretty packed with other projects recently. I'd like to get #111 merged and tested. It sounds like it works for you?

deck: initialization of GeoArrowPolygonLayer({id: 'polys'}): c.List is not a constructor TypeError: c.List is not a constructor

Hmm.. it's weird that it's failing on the constructor. I was originally thinking it might have to do with postMessaging the data back and forth, where it was losing a prototype after being sent back from the worker. But if it's the top-level arrow.List, I don't know if that would be related?

@atmorling
Copy link
Contributor

Happy if you want to merge #111 and close this. I'll look more into my issue this week and will raise a separate issue if I find anything.

@kylebarron
Copy link
Member

Feel free to make new issues for any new bugs!

@jaredlander
Copy link
Author

Hmm.. it's weird that it's failing on the constructor. I was originally thinking it might have to do with postMessaging the data back and forth, where it was losing a prototype after being sent back from the worker. But if it's the top-level arrow.List, I don't know if that would be related?

I'm getting the same error for GeoArrowPolygonLayer but it works for GeoArrowSolidPolygonLayer.

@kylebarron
Copy link
Member

if you could track it down to an unminified line of code that would be helpful

@atmorling
Copy link
Contributor

I spent some time yesterday trying to figure out where the issue lies. Since I'm a complete novice when it comes to bundling, the approach was a little bit 'blind man shoots from the hip', but here's where it led:

  • As mentioned, the call to the arrow.Vector() constructor on this line is fine, the arrow.List() constructor here is where it breaks.
  • I tried a build of deck.gl-layers with a call to arrow.DurationSecond() inserted (around line 72 of polygon-layer.ts) which also presented the same not a constructor issue. So it looks like an issue with what's exported from types.ts in arrow?
  • I also built geoarrow-js with the same arrow.DurationSecond() call inserted and had the same error there.
  • I then tried the same constructor in the <script> block of my repex above which did not error.
  • I also tried a build of deck.gl-layers with apache-arrow removed from the external list in rollup.config.js, this fixed the issue but it's obviously not ideal.

As I was writing all that, I realised that Arrow.es2015.min.js exports as global.Arrow, not global.arrow so tested the repex with a build of deck.gl-layers using "apache-arrow": "Arrow" in the globals of the rollup config and the error goes away.

TL;DR I guess that's the change? Update rollup.config.js to use "apache-arrow": "Arrow"

@kylebarron
Copy link
Member

kylebarron commented Apr 5, 2024

Wow that's an annoying error. Thanks for digging into it!

Would you be able to submit that one line fix as a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants