Canadian-Geospatial-Platform / geoview

Canadian Geospatial Platform Viewer / Visualiseur de la Plateforme Géospatiale Canadienne
Other
22 stars 31 forks source link

[FEATURE] Pass layer data into cpgv.init as parameter #2411

Open G-Boyce opened 2 months ago

G-Boyce commented 2 months ago

Is there an existing issue for this?

Who request this Feature

Greg Boyce, Data Management Plan tool, NRCan

User Story

I'd like to be able to pass GeoJSON data (e.g. as a text string) into the cgpv.init function.

Implementation UI

Rather than being forced to read GeoJSON data from a fixed file on the web server, I'd like to dynamically build up the data using an SQL query in PHP, and pass that GeoJSON string into the cgpv.init function. (Instead of parsing the file, parse the passed string.)

Otherwise, I'll likely need to create files on the web server, which gets messy (disk space checks, regular file cleanup, etc).

Note: we already have a web page which creates HTML/JavaScript output from SQL queries, so setting up a new WFS server to also query this data, would presumably double the database query load.

Data passed into cgpv.init, should probably be in addition to layers already defined in the map Config section. (E.g. you have several layers well defined by WFS or other layer types in the map config section, and just want to add data for one dynamically constructed layer.)

So, using the following Config string (from GeoJSON layer page):

        "metadataAccessPath": {
          "en": "./datasets/geojson/metadata.json"
        },
        "geoviewLayerType": "GeoJSON",
        "listOfLayerEntryConfig": [
          {
            "layerId": "polygons.json",
            "layerName": {
              "en": "Polygons"
            },
            "layerFilter": "creationDate >= date '2020/02/15'"
          },

Basically allowing the contents of "polygons.json" to be passed into cgpv.init as a parameter.

The metadataAccessPath (metadata.json) could remain in the config (or be passed in, too).

jolevesq commented 1 month ago

Test

jolevesq commented 1 month ago

@G-Boyce Mention

G-Boyce commented 1 month ago

I have no requirement for the data to be a GeoJSON string. Any format of data can be passed, as long as I know what format I need to construct, that's OK.

fletour commented 1 month ago

To summarise our feature request. @G-Boyce, please edit if something is missing.

jolevesq commented 3 weeks ago

@G-Boyce The code is now ready to test: https://canadian-geospatial-platform.github.io/geoview/public/demo-geojson-inject.html

G-Boyce commented 1 week ago

Seems to be working so far. Thanks!