compassinformatics / cpsi-mapview

GNU General Public License v3.0
6 stars 14 forks source link

GeoStyler Integration issues in production builds #158

Closed geographika closed 4 years ago

geographika commented 4 years ago

Currently the following 2 files are used by the project/sub-projects:

olStyleParser and sldStyleParser.js

When using without minification these work correctly. When adding to a production build and with SenchaCmd errors occur.

TypeError: Number.prototype.toFixed requires that 'this' be a Number

Files are added to the "js" property in app.json as follows:

    {
      // "remote": true, // not included in output
      "includeInBundle": false,
      "path": "./lib/openlayers/ol-debug.js"
    },
    {
      "includeInBundle": false,
      "path": "./lib/geostyler/sldStyleParser.js"
    },
    {
      "includeInBundle": false,
      "path": "./lib/geostyler/olStyleParser.js"
    },

Even with the includeInBundle these appear to still be minified. What is the best way to get minified versions of sldStyleParser and olStyleParser and what other dependencies do they have?

chrismayer commented 4 years ago

I just tested the production build of this repo and it worked well (using sencha app build). It has the following config in the app.json:

        {
            "path": "./lib/geostyler/sld-style-parser/sldStyleParser.js"
        },
        {
            "path": "./lib/geostyler/ol-style-parser/olStyleParser.js"
        },

So no includeInBundle property. Or do you need to bundle the GeoStyler sources?

geographika commented 4 years ago

@chrismayer - I also got non-compressed files with the cpsi-mapiew project, but it was still happening on a separate mapview-based project. All app.json settings were the same, and I tried a lot of settings and configs until finally finding the reason.

The cpsi-mapview project has workspace settings in the .sencha folder. In my other project there was no .sencha folder. Setting the line at https://github.com/compassinformatics/cpsi-mapview/blob/master/.sencha/app/defaults.properties#L85 to app.output.js.compress=true caused the same compression and as it is set to false by default was the reason for the difference.

I then used the following settings in the other project's app.json file, and the files were no longer compressed (this setting appears to be undocumented..):

    {
      "path": "./lib/geostyler/sld/sldStyleParser.js",
      "compress": false
    },
    {
      "path": "./lib/geostyler/ol/olStyleParser.js",
      "compress":  false
    },

I have a few related questions you may be able to answer:

  1. Is the .sencha workspace folder required? On the other project everything works fine. Should this folder always be checked in as part of a project?

  2. Are the individual GeoStyler projects independent of requiring the full GeoStyler? For example the openlayers parser used in cpsi-mapview has the following link listed in the VERSION file: https://github.com/geostyler/geostyler-openlayers-parser/releases/tag/v0.19.1 and no mention of requiring the GeoStyler library.

  3. The releases on GitHub have the full source code (including TypeScript etc.). Are there ready-made minified builds available for download? If not are there build steps documented somewhere? Should we update to a newer version e.g. https://github.com/geostyler/geostyler-openlayers-parser/releases/tag/v1.1.4 (which uses OL 4.6.5).

chrismayer commented 4 years ago

I then used the following settings in the other project's app.json file, and the files were no longer compressed (this setting appears to be undocumented..):

Thanks for clarification @geographika! I was aware of the property in the workspace settings but not that it is possible to set them in the app.json.

Regarding your questions:

Is the .sencha workspace folder required? On the other project everything works fine. Should this folder always be checked in as part of a project?

It is not required, but usually I am checking it in for my projects. I experienced that this minimizes the problems when setting up the app on another computer / environment.

Are the individual GeoStyler projects independent of requiring the full GeoStyler? For example the openlayers parser used in cpsi-mapview has the following link listed in the VERSION file: https://github.com/geostyler/geostyler-openlayers-parser/releases/tag/v0.19.1 and no mention of requiring the GeoStyler library.

Yes, all parsers are independent software components. What they need as dependency is the geostyler-style format, which acts as "lingua franca" between the geostyler libs (e.g. parsers). The GeoStyler UI library itself is not needed. This loose coupling was by design since the beginning of GeoStyler. So it becomes possible to use the parsers without the UI, as we do here in CPSI-Mapview.

The releases on GitHub have the full source code (including TypeScript etc.). Are there ready-made minified builds available for download? If not are there build steps documented somewhere? Should we update to a newer version e.g. https://github.com/geostyler/geostyler-openlayers-parser/releases/tag/v1.1.4 (which uses OL 4.6.5).

GeoStyler and its surrounding libs / parsers are available at npm (see https://www.npmjs.com/search?q=keywords:geostyler) in the meantime. The builds include the browser build, which we use in CPS-Mapview. I created an issue for the switch to npm #182 .

chrismayer commented 4 years ago

@geographika: Is this good to be closed or does it need some more work / information?

geographika commented 4 years ago

These details are fine.

For the record to get the browser builds we just need to run:

npm i geostyler-openlayers-parser
npm i geostyler-sld-parser

And take the JS in: node_modules\geostyler-openlayers-parser\browser and node_modules\geostyler-sld-parser\browser