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

Issues with tutorial and documentation #302

Closed
davidblasby opened this issue Nov 18, 2021 · 5 comments
Closed

Issues with tutorial and documentation #302

davidblasby opened this issue Nov 18, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@davidblasby
Copy link

Bug

I am a JS tool-chain beginner. I'm trying to follow the beginner tutorial and the github documentation.

Beginner Tutorial

https://geostyler.github.io/geostyler-beginner-workshop/

I installed the latest node 12, and then tried to run the big code block in the "Parsing SLD" section.

However, I get an error (in the browser) when i do this:

"Error: Objects are not valid as a React child (found: object with keys {errors}). If you meant to render a collection of children, use an array instead."

I did some digging and the error is in the sldParser.writeStyle(style) method.

"Cannot read properties of undefined (reading 'map')"

http://localhost:3000/static/js/vendors~main.chunk.js:4433:31
    at new Promise (<anonymous>)
    at SldStyleParser.writeStyle (http://localhost:3000/static/js/vendors~main.chunk.js:4424:12)
    at http://localhost:3000/static/js/main.chunk.js:81:15
    at invokePassiveEffectCreate (http://localhost:3000/static/js/vendors~main.chunk.js:33831:24)
    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/vendors~main.chunk.js:14447:18)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/vendors~main.chunk.js:14496:20)
    at invokeGuardedCallback (http://localhost:3000/static/js/vendors~main.chunk.js:14556:35)
    at flushPassiveEffectsImpl (http://localhost:3000/static/js/vendors~main.chunk.js:33913:13)
   at unstable_runWithPriority (http://localhost:3000/static/js/vendors~main.chunk.js:47944:16)
    at runWithPriority$1 (http://localhost:3000/static/js/vendors~main.chunk.js:21853:14)
    at flushPassiveEffects (http://localhost:3000/static/js/vendors~main.chunk.js:33790:18)
    at http://localhost:3000/static/js/vendors~main.chunk.js:33671:15
    at workLoop (http://localhost:3000/static/js/vendors~main.chunk.js:47894:38)
    at flushWork (http://localhost:3000/static/js/vendors~main.chunk.js:47868:18)
   at MessagePort.performWorkUntilDeadline (http://localhost:3000/static/js/vendors~main.chunk.js:47634:31)"

Sorry I cannot give more details, but that's the best info I could get with my knowledge.

Trying to Install Geostyler with npm

I noticed that the advanced workshop used node v6. I went to another machine, and installed the latest node (brew install node@16).

npm i geostyler

This failed.

I went to node v14 (brew install node@14).

npm i geostyler

This worked. Perhaps the documentation should indicate which node version to run.

Trying to get SLD parser working

I then moved on to https://github.com/geostyler/geostyler-sld-parser so I could try to get the tutorial code working.

I wasn't sure how to run the sample code (README).

The documentation shows this;
const parser = new SLDParser();

The code seems to indicate that this should be SldStyleParser - see https://github.com/geostyler/geostyler-sld-parser/blob/master/src/SldStyleParser.ts#L69

The second example in the README uses;
var parser = new GeoStylerSLDParser.SldStyleParser();

I was able to get this working (code in app.js node app.js):

const geostyler_sld_parser = require("geostyler-sld-parser")
var parser = new geostyler_sld_parser.SldStyleParser();
const pointSimplePoint = {
                   ...
};

parser
  .writeStyle(pointSimplePoint)
  .then(function(sld) {
    console.log(sld);
  })
  .catch(function(error) {
    console.log(error);
  });

I think the README should be updated to use SldStyleParser and perhaps add an easy-to-run node command (as above).

I will try to add a doc update to the Git repo, but I have no idea what's wrong with the tutorial.

@davidblasby davidblasby added the bug Something isn't working label Nov 18, 2021
@davidblasby
Copy link
Author

@jansule
Copy link
Contributor

jansule commented Nov 19, 2021

Thanks for the info @davidblasby!

I installed the latest node 12, and then tried to run the big code block in the "Parsing SLD" section.

We introduced a breaking change with geostyler-style@5, which changes the usage of the readStyle and writeStyle methods. In the tutorial, geostyler@7 will be installed (which uses the old API), but there is no explicit version set for the parsers. So these use the new API.

The tutorials need to be updated to describe how to work GeoStyler with the new API.

As a workaround for you, there are two options:

  1. Follow the tutorial with the old API. To do so, you have to install the different GeoStyler libraries in the versions as described here. Then, following the steps as described in the tutorial should work.

  2. Follow the tutorial with the new API. To do so, you have to install the latest version of GeoStyler, i.e. npm i geostyler (please note the missing version number). However, as the tutorial does not yet reflect the changes, you will have to change the readStyle and writeStyle sections to fit the new API. Everything else should still work just fine then.

@jansule
Copy link
Contributor

jansule commented Nov 19, 2021

Trying to get SLD parser working

I then moved on to https://github.com/geostyler/geostyler-sld-parser so I could try to get the tutorial code working.

I wasn't sure how to run the sample code (README).

The documentation shows this; const parser = new SLDParser();

The code seems to indicate that this should be SldStyleParser - see https://github.com/geostyler/geostyler-sld-parser/blob/master/src/SldStyleParser.ts#L69

The second example in the README uses; var parser = new GeoStylerSLDParser.SldStyleParser();

I was able to get this working (code in app.js node app.js):

const geostyler_sld_parser = require("geostyler-sld-parser")
var parser = new geostyler_sld_parser.SldStyleParser();
const pointSimplePoint = {
                   ...
};

In JavaScript, you are free to name imports/requires as you like, as you are actually just assigning a variable.
So when writing

const geostyler_sld_parser = require("geostyler-sld-parser")

or

import geostyler_sld_parser from 'geostyler-sld-parser

the parser will be assigned to the variable geostyler_sld_parser.

@jansule
Copy link
Contributor

jansule commented Nov 19, 2021

Trying to Install Geostyler with npm

I noticed that the advanced workshop used node v6. I went to another machine, and installed the latest node (brew install node@16).

npm i geostyler

This failed.

I went to node v14 (brew install node@14).

npm i geostyler

This worked. Perhaps the documentation should indicate which node version to run.

I can reproduce the error. There seems to be a version mismatch. Until this is fixed, it is better to use Node<16. Thanks for the info!

@KaiVolland
Copy link
Contributor

solved with geostyler/geostyler#1524

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants