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.