GeoNode / geonode-mapstore-client

MapStore Client for GeoNode
http://geonode.org/geonode-mapstore-client/master
Other
15 stars 109 forks source link

mapstore client does not let download geopackage from geoserver #509

Closed lpasquali closed 2 years ago

lpasquali commented 3 years ago

GeoServer 2.19.x in current 3.3.x geonode and geonode-project branches is capable to export compatible layers in geopackage format (I used tiger_roads shapefile for test), once I upload layer through geonode, I can export it in geopackage format within geoserver Layer preview page. On the contrary as in the video attached if I do this on development geonode updated to latest 3.3.x:

Peek 2021-09-20 18-04

@tdipisa @giohappy

lpasquali commented 3 years ago

FYI @simboss

giohappy commented 3 years ago

@tdipisa who could invetigate this?

allyoucanmap commented 3 years ago

@giohappy @simboss After an investigation this is what I found out:

The LayerDownload makes a request to the WPS to understand if the gs:Download is available if so it uses WPS async download and if not it uses WFS sync download. The formats for the WPS download are not automatically updated by MapStore so if we need new formats we have to configure them in localConfig.json overriding the default ones that not include GeoPackage. Here an example of configuration with default formats in MapStore + geopackage

{
    "name": "LayerDownload",
    "cfg": {
        "formats": [
            {"name": "application/json", "label": "GeoJSON", "type": "vector", "validServices": ["wps"]},
            {"name": "application/arcgrid", "label": "ArcGrid", "type": "raster", "validServices": ["wps"]},
            {"name": "image/tiff", "label": "TIFF", "type": "raster", "validServices": ["wps"]},
            {"name": "image/png", "label": "PNG", "type": "raster", "validServices": ["wps"]},
            {"name": "image/jpeg", "label": "JPEG", "type": "raster", "validServices": ["wps"]},
            {"name": "application/wfs-collection-1.0", "label": "wfs-collection-1.0", "type": "vector", "validServices": ["wps"]},
            {"name": "application/wfs-collection-1.1", "label": "wfs-collection-1.1", "type": "vector", "validServices": ["wps"]},
            {"name": "application/zip", "label": "Shapefile", "type": "vector", "validServices": ["wps"]},
            {"name": "text/csv", "label": "CSV", "type": "vector", "validServices": ["wps"]},
            {"name": "application/x-gpkg", "label": "GeoPackage", "type": "vector", "validServices": ["wps"]}
        ]
    }
},

I tried the above configuration and I'm getting this error after trying to download a geopackage with WPS

org.geotools.process.ProcessException: Don't know how to encode in mime type application/x-gpkg
Don't know how to encode in mime type application/x-gpkg

and I find this commit in the wps-download that include the geopackage format with tag 2.20 for the GeoServer. Is the WPS download for GeoPackage working in the custom branch of GeoNode -> GeoServer 2.1.9?

https://github.com/geoserver/geoserver/commit/01cd8fe342893138f459fea08505a2f20ff27fd2

I think we need to:

possible improvements in MapStore/GeoServer:


I think that sometimes it was working because it was using WFS download instead where the formats are described by the capabilities (maybe the wps-download were not working)

giohappy commented 3 years ago

verify that the GeoServer 2.19 version of geonode support WPS download for GeoPackage

It's been backported, according to this commit

I tried the above configuration and I'm getting this error after trying to download a geopackage with WPS

The right MIME should be application/geopackage+sqlite3

Please @allyoucanmap make a test using the Development demo.

allyoucanmap commented 3 years ago

@giohappy I tried also using application/geopackage+sqlite3 with raster and vector layers but getting same error:

org.geotools.process.ProcessException: Don't know how to encode in mime type application/geopackage+sqlite3
Don't know how to encode in mime type application/geopackage+sqlite3

anyway once we are sure about the mime type we need to update geonode-mapstore-client with the correct configuration:

{
    "name": "LayerDownload",
    "cfg": {
        "disablePluginIf": "{!state('selectedLayerPermissions').includes('download_resourcebase')}",
        "formats": [
            {"name": "application/json", "label": "GeoJSON", "type": "vector", "validServices": ["wps"]},
            {"name": "application/arcgrid", "label": "ArcGrid", "type": "raster", "validServices": ["wps"]},
            {"name": "image/tiff", "label": "TIFF", "type": "raster", "validServices": ["wps"]},
            {"name": "image/png", "label": "PNG", "type": "raster", "validServices": ["wps"]},
            {"name": "image/jpeg", "label": "JPEG", "type": "raster", "validServices": ["wps"]},
            {"name": "application/wfs-collection-1.0", "label": "wfs-collection-1.0", "type": "vector", "validServices": ["wps"]},
            {"name": "application/wfs-collection-1.1", "label": "wfs-collection-1.1", "type": "vector", "validServices": ["wps"]},
            {"name": "application/zip", "label": "Shapefile", "type": "vector", "validServices": ["wps"]},
            {"name": "text/csv", "label": "CSV", "type": "vector", "validServices": ["wps"]},
            {"name": "application/geopackage+sqlite3", "label": "GeoPackage", "type": "vector", "validServices": ["wps"]},
            {"name": "application/geopackage+sqlite3", "label": "GeoPackage", "type": "raster", "validServices": ["wps"]}
        ]
    }
},
giohappy commented 3 years ago

@lpasquali @drumbsd do you confirm that the WPS Download with Geopacke support has been shipped with Geoserver 2.19.x for GeoNode?

lpasquali commented 3 years ago

@giohappy I can't confirm and must deny because I followed documentation and it was not mentioned anywhere, it says only WPS is needed which is present: https://docs.geoserver.org/latest/en/user/community/geopkg/

giohappy commented 3 years ago

from a chat with @lpasquali the support for GeoPackage should be already be inside GeoNode 2.19.x for GeoNode, since the commit is from August.

@afabiani could you please make a quick invetigation? Quick recap:

giohappy commented 3 years ago

@allyoucanmap GeoServer 2.19 for GeoNode has been fixed (also development demo). Can you please try again the GPKG WP download?

allyoucanmap commented 3 years ago

@giohappy @simboss Added the format geopackage to the LayerDownload configuration and it's working but I noticed:

The configuration update has been merged on master and 3.3.x so we could try to update development instance to test it Merged PR:

and just opened an issue in mapstore to add GeoPackage as default format https://github.com/geosolutions-it/MapStore2/issues/7350

giohappy commented 3 years ago

the name of the exported file is always result (we should verify if it's possible to change it maybe based on the name of the layer?)

@allyoucanmap AFAIK the respone can be controlled with the <ows:Identifier> inside the <wps:RawDataOutput> element. From the docs I see the following, which makes me think that it was also used in MapStore to implement WPS download:

<wps:ResponseForm>
    <wps:RawDataOutput mimeType="application/zip">
        <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
</wps:ResponseForm>

Could you make a test changing the defaults sent by MapStore? This improvement would be useful for the other formats too.

the file are generated with the .geopackage+sqlite3 extension and to make them work on QGIS 3.18.3-Zürich I need to rename the file with the .gpkg extension

I haven't found something about this inside the WPS spec. @simboss who should we ask about this?