Skip to content

Instantly share code, notes, and snippets.

@gannebamm
Created June 16, 2019 11:39
Show Gist options
  • Save gannebamm/662ce7de6c3439c64c1740fed3fb2649 to your computer and use it in GitHub Desktop.
Save gannebamm/662ce7de6c3439c64c1740fed3fb2649 to your computer and use it in GitHub Desktop.
Get GeoPackage download to work for GeoNode 2.10
# GeoServer dockerfile for spc
# extende for downloading and unpacking community plugins
FROM openjdk:8-jre-alpine
ARG version=2.14.2
ARG branch=2.14.x
ARG plugins=
ARG commpluginfiles=geoserver-2.14-SNAPSHOT-geopkg-plugin.zip
# Install dependencies
RUN apk add --no-cache ca-certificates openssl curl postgresql-client fontconfig ttf-ubuntu-font-family
RUN update-ca-certificates
WORKDIR /
# Download Geoserver
# we first download vanilla geoserver, as it comes with preset jetty and launch scripts
# then we replace it with the geonode build
# TODO : this is a bit dirty..... can't we stat from vanilla Geoserver ?
# TODO : merge into on step
RUN echo "Download geoserver for geonode" && \
wget https://downloads.sourceforge.net/project/geoserver/GeoServer/$version/geoserver-$version-bin.zip && \
wget https://build.geo-solutions.it/geonode/geoserver/latest/geoserver-$branch.war --no-check-certificate && \
unzip geoserver-$version-bin.zip && \
mv geoserver-$version geoserver && \
rm /geoserver-$version-bin.zip && \
rm /geoserver-$version/webapps/geoserver/* -rf && \
unzip -o geoserver-$branch.war -d /geoserver/webapps/geoserver/ && \
rm /geoserver-$branch.war
# Plugins support
# Example:
# for core plugins (extensions)
# $ docker-compose build --build-arg plugins="csw" geoserver
RUN for plugin in $plugins; do \
wget https://downloads.sourceforge.net/project/geoserver/GeoServer/$version/extensions/geoserver-$version-$plugin-plugin.zip && \
unzip -o geoserver-$version-$plugin-plugin.zip -d /geoserver/webapps/geoserver/WEB-INF/lib && \
rm geoserver-$version-$plugin-plugin.zip; \
done
# for community plugins
# $ docker-compose build --build-arg commpluginfiles="geoserver-2.14-SNAPSHOT-geopkg-plugin.zip" geoserver
RUN for commpluginfile in $commpluginfiles; do \
echo "Download $commpluginfile for GeoServer" && \
echo "at: https://build.geoserver.org/geoserver/$branch/community-latest/$commpluginfile" && \
wget https://build.geoserver.org/geoserver/$branch/community-latest/$commpluginfile && \
unzip -o $commpluginfile -d /geoserver/webapps/geoserver/WEB-INF/lib && \
rm $commpluginfile; \
done
# Download initial data dir
RUN wget https://build.geo-solutions.it/geonode/geoserver/latest/data-$branch.zip --no-check-certificate
RUN unzip /data-$branch.zip
RUN ls /data
WORKDIR /geoserver/
# Add the entrypoint
ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
# Export ports
EXPOSE 8080
# Set environnment variables
ENV GEOSERVER_HOME=/geoserver
ENV GEOSERVER_DATA_DIR=/spcgeonode-geodatadir
# Run geoserver
CMD ["bin/startup.sh"]
<!--
172.30.218.212 is the local ip of my vm
http://172.30.218.212/catalogue/csw?outputschema=http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2Fcsdgm&service=CSW&request=GetRecordById&version=2.0.2&elementsetname=full&id=d22a278c-901f-11e9-bfb3-0242ac120003
-->
<!-- loads of html and: -->
<onlink type="WWW:DOWNLOAD-1.0-http--download">http://172.30.218.212/geoserver/ows?outputFormat=geopkg&service=WFS&srs=EPSG%3A25832&request=GetFeature&typename=geonode%3Ageb01_f&version=1.0.0</onlink>
def wfs_links(wfs_url, identifier, bbox=None, srid=None):
types = [
("zip", _("Zipped Shapefile"), "SHAPE-ZIP", {'format_options': 'charset:UTF-8'}),
("gml", _("GML 2.0"), "gml2", {}),
("gml", _("GML 3.1.1"), "text/xml; subtype=gml/3.1.1", {}),
("csv", _("CSV"), "csv", {}),
("excel", _("Excel"), "excel", {}),
("json", _("GeoJSON"), "json", {'srsName': srid or 'EPSG:4326'}),
# add geopackage as download format
("geopackage", _("Geopackage"), "geopkg", {}),
]
output = []
for ext, name, mime, extra_params in types:
url = _wfs_link(wfs_url, identifier, mime, extra_params, bbox=bbox, srid=srid)
output.append((ext, name, mime, url))
return output
DOWNLOAD_FORMATS_VECTOR = [
'JPEG', 'PDF', 'PNG', 'Zipped Shapefile', 'GML 2.0', 'GML 3.1.1', 'CSV',
'Excel', 'GeoJSON', 'KML', 'View in Google Earth', 'Tiles',
'QGIS layer file (.qlr)',
'QGIS project file (.qgs)',
# add geopackage as dl format
'GeoPackage (.gpkg)',
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment