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

GeoArrowScatterplotLayer throws 'c.vector is undefined' #126

Closed
tim-salabim opened this issue May 24, 2024 · 22 comments
Closed

GeoArrowScatterplotLayer throws 'c.vector is undefined' #126

tim-salabim opened this issue May 24, 2024 · 22 comments

Comments

@tim-salabim
Copy link

tim-salabim commented May 24, 2024

As alluded to on Mastodon, I am still having issues with getting GeoArrowScatterplotLayer to work. A reproducible example is below. This seems a very similar issue to what @jaredlander reported here, in fact, I've modified his example in the reprex below. This uses some .arrow data hosted on a CORS enabled public bucket on AWS S3.

<head>
    <meta charset='UTF-8' />
    <title>GeoArrowScatterplotLayer issue</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/Arrow.es2015.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dist.dev.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@geoarrow/[email protected]/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://geoarrow-test.s3.eu-central-1.amazonaws.com/test1_layer.arrow";

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

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

        const mainMap = new deck.DeckGL({
            initialViewState: INITIAL_VIEW_STATE,
            id: 'mainMap',
            controller: true,
            container: "holder",
            layers: [
                new geoarrowLayers.GeoArrowScatterplotLayer({
                    id: 'scatter',
                    data: arrow_table,
                    pickable: true,
                    getFillColor: [80, 0, 200],
                    getPosition: d => d.getChild('geometry'),
                    getRadius: 300,
                })
            ]
        });
    </script>
</body>

</html>

This is the error in the console

image

Any ideas as to what might cause this?

@kylebarron
Copy link
Member

As a general note, I'd suggest testing with the PathLayer before testing with the TripsLayer. The TripsLayer is more complex.

This is probably due to the Arrow name not correctly getting found. We found recently that the name of arrow-js on the page has to be Arrow with a capital A. This was recently fixed in this repo in #122 but hasn't been released yet

@tim-salabim
Copy link
Author

tim-salabim commented May 30, 2024

Thanks for the clarification. I saw that PR but assumed it was already released. I'll wait until then.

As a general note, I'd suggest testing with the PathLayer before testing with the TripsLayer. The TripsLayer is more complex.

This example is using ScatterplotLayer. Am I missing something?

@kylebarron
Copy link
Member

Huh... When I copied your code into an HTML file and ran it on localhost, the error traceback has trips-layer in it, which made me confused. Maybe the sourcemaps are incorrect?
image

@tim-salabim
Copy link
Author

tim-salabim commented May 31, 2024

Strange, if I serve it in firefox via localhost I get

image

In Chromium I get the same as you

image

@kylebarron
Copy link
Member

Yeah must be an issue with the source maps...

@kylebarron
Copy link
Member

I published @geoarrow/[email protected] with the latest main

@tim-salabim
Copy link
Author

Unfortunately, I am still getting the same error...
image

@kylebarron
Copy link
Member

I'm not a JS expert, and personally I always use React with a bundler. Based on the previous issue in #109, it seemed like people were able to get something working directly from a CDN.

I don't have a lot of spare time right now, so I'm not able to try and dig in and debug this.

@jaredlander
Copy link

Maybe @joemarlo can help write CI/CD pipelines for that?

@tim-salabim
Copy link
Author

I'm not a JS expert, and personally I always use React with a bundler. Based on the previous issue in #109, it seemed like people were able to get something working directly from a CDN.

@jaredlander did you ever get this working? If so, how?

@jaredlander
Copy link

I didn't think we looked at it yet, but I'll remind my folks to take a look.

@tim-salabim
Copy link
Author

Thanks!

@joemarlo
Copy link

This does look similar to #109. I don't think we ever got it working straight from a CDN. We cloned the branches, ran npm run build on them, and copied over the static files to the project we were working on. Specifically:

  1. npm run build deck.gl-layers/tree/kyle/bundling-fix branch
  2. npm run build geoarrow-js/tree/kyle/fix-bundling branch
  3. Source both of these new local umd.js files in the head of the example's index.html

Not a clue how to get this on a CDN. Do you have to submit to CDNs or do they just scan and pull the repos' main branch?

It looks like the fix for deck.gl-layers has been merged but not the geoarrow-js fix. So perhaps that is the issue?

@kylebarron
Copy link
Member

I merged the geoarrow-js pr. If you need me to create a patch release I can

@joemarlo
Copy link

Thanks, @kylebarron. I think a release is necessary. Do you submit it to npm? I did a little poking around and the CDNs apparently just pull the latest version from there.

@kylebarron
Copy link
Member

@tim-salabim
Copy link
Author

tim-salabim commented Jun 28, 2024

Thanks everyone! When using the latest versions, we get rid of the JS errors, but we get a webgl warning (this is in Firefox):

WebGL warning: drawArraysInstanced: Instance fetch requires 100, but attribs only supply 0.

<!DOCTYPE html>

<head>
    <meta charset='UTF-8' />
    <title>GeoArrowScatterplotLayer issue</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/Arrow.es2015.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dist.dev.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@geoarrow/[email protected]/dist/geoarrow.umd.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@geoarrow/[email protected]/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://geoarrow-test.s3.eu-central-1.amazonaws.com/test1_layer.arrow";

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

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

        const mainMap = new deck.DeckGL({
            initialViewState: INITIAL_VIEW_STATE,
            id: 'mainMap',
            controller: true,
            container: "holder",
            layers: [
                new geoarrowLayers.GeoArrowScatterplotLayer({
                    id: 'scatter',
                    data: arrow_table,
                    pickable: true,
                    getFillColor: [80, 0, 200],
                    getPosition: arrow_table.getChild('geometry'),
                    getRadius: 30,
                    radiusMinPixels: 3
                })
            ]
        });
    </script>
</body>

</html>

@kylebarron
Copy link
Member

WebGL warning: drawArraysInstanced: Instance fetch requires 100, but attribs only supply 0.

That could be a bug in deck.gl v9

@tim-salabim
Copy link
Author

@felixpalmer this is the issue we just talked about in the morning session of sdsl2024. Maybe you can have a look at what the problem could be with the above example?

@felixpalmer
Copy link

felixpalmer commented Sep 18, 2024

It's best if you don't use the minified scripts, so go with:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dist.dev.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@geoarrow/[email protected]/dist/geoarrow.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@geoarrow/[email protected]/dist/dist.umd.js"></script>

With this in place I tried to debug, but something seems off with your Arrow file, I tried loading it in https://arrowviewer.pages.dev/ and it also gives an error:

Abort(): Could not load arrow column of type `struct`

Could you try with another arrow file?

At any rate the issue seems to be with the Arrow handling rather than anything related to the v9 migration

@kylebarron
Copy link
Member

Yeah this is a "separated" GeoArrow column, which deck.gl-layers does not yet support. See #3

image

@tim-salabim
Copy link
Author

tim-salabim commented Sep 26, 2024

Great success! With the help of @paleolimbot I was able to write interleaved coordinates and the example now works:

image

Thanks for all your patience, everyone!

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

No branches or pull requests

5 participants