Skip to content

Commit

Permalink
added and change in the cli script
Browse files Browse the repository at this point in the history
  • Loading branch information
romer8 committed May 7, 2024
1 parent 77edc9c commit f290c68
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 47 deletions.
64 changes: 49 additions & 15 deletions cli/convert_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,66 @@ def publish_geojson_layer_to_geoserver(

def main():
parser = argparse.ArgumentParser(
description="Convert a GeoPackage layer to GeoJSON format with projection to EPSG:4326."
description="Tool for converting and publishing geospatial data"
)
parser.add_argument("gpkg_path", help="Path to the GeoPackage file.")
parser.add_argument("layer_name", help="Name of the layer to convert.")
parser.add_argument("output_path", help="Output path for the GeoJSON file.")
parser.add_argument(
"--publish", action="store_true", help="Publish the layer to GeoServer."
"--convert_to_geojson",
action="store_true",
help="Convert GeoPackage to GeoJSON",
)
parser.add_argument(
"--publish", action="store_true", help="Publish the layer to GeoServer"
)
parser.add_argument("--shp_path", help="Path to save the shapefile for GeoServer.")
parser.add_argument("--geoserver_host", help="GeoServer host.")
parser.add_argument("--geoserver_port", help="GeoServer port.")
parser.add_argument("--geoserver_username", help="GeoServer username.")
parser.add_argument("--geoserver_password", help="GeoServer password.")
parser.add_argument(
"--publish_geojson",
action="store_true",
help="Publish the GeoJSON layer to GeoServer.",
help="Publish the GeoJSON layer to GeoServer",
)
parser.add_argument("geojson_path", help="Path to the GeoJSON file.")

args = parser.parse_args()
# Optional Arguments
parser.add_argument(
"--gpkg_path", help="Path to the GeoPackage file", required=False
)
parser.add_argument(
"--layer_name",
help="Name of the layer in the GeoPackage to convert",
required=False,
)
parser.add_argument(
"--output_path", help="Output path for the GeoJSON file", required=False
)
parser.add_argument(
"--geojson_path", help="Path to the GeoJSON file", required=False
)
parser.add_argument(
"--shp_path", help="Path to save the shapefile for GeoServer", required=False
)
parser.add_argument("--geoserver_host", help="GeoServer host", required=False)
parser.add_argument("--geoserver_port", help="GeoServer port", required=False)
parser.add_argument(
"--geoserver_username", help="GeoServer username", required=False
)
parser.add_argument(
"--geoserver_password", help="GeoServer password", required=False
)

result = convert_gpkg_to_geojson(args.gpkg_path, args.layer_name, args.output_path)
args = parser.parse_args()

if result != 0:
if args.convert_to_geojson:
if not args.gpkg_path or not args.layer_name or not args.output_path:
parser.error(
"--convert_to_geojson requires --gpkg_path, --layer_name, and --output_path."
)
result = convert_gpkg_to_geojson(
args.gpkg_path, args.layer_name, args.output_path
)
exit(result)

if args.publish:
if not args.gpkg_path or not args.layer_name or not args.shp_path:
parser.error(
"--publish requires --gpkg_path, --layer_name, and --shp_path."
)
result = publish_gpkg_layer_to_geoserver(
args.gpkg_path,
args.layer_name,
Expand All @@ -148,6 +180,8 @@ def main():
exit(result)

if args.publish_geojson:
if not args.geojson_path or not args.shp_path:
parser.error("--publish_geojson requires --geojson_path and --shp_path.")
result = publish_geojson_layer_to_geoserver(
args.geojson_path,
args.shp_path,
Expand Down
64 changes: 32 additions & 32 deletions reactapp/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const webpack = require('webpack');
// const WebpackBundleAnalyzer = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; // Uncomment to analyze bundle size
const Dotenv = require('dotenv-webpack');
const TerserPlugin = require("terser-webpack-plugin");
// const TerserPlugin = require("terser-webpack-plugin");

module.exports = (env, argv) => {
const dotEnvPath = `./reactapp/config/${argv.mode}.env`;
Expand All @@ -29,12 +29,12 @@ module.exports = (env, argv) => {
// new WebpackBundleAnalyzer(), // Uncomment to analyze bundle size
],

externals: ({context, request}, callback) => {
if (/xlsx|canvg|pdfmake/.test(request)) {
return callback(null, "commonjs " + request);
}
callback();
},
// externals: ({context, request}, callback) => {
// if (/xlsx|canvg|pdfmake/.test(request)) {
// return callback(null, "commonjs " + request);
// }
// callback();
// },
module: {
rules: [
{
Expand Down Expand Up @@ -87,39 +87,39 @@ module.exports = (env, argv) => {
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
// minimizer: [new TerserPlugin()],
splitChunks: {

minSize: 17000,
minRemainingSize: 0,
minChunks: 1,
minChunks: 2,
maxAsyncRequests: 30,
maxInitialRequests: 30,
automaticNameDelimiter: "_",
enforceSizeThreshold: 30000,
cacheGroups: {
common: {
test: /[\\/]node_modules[\\/]/,
priority: -5,
reuseExistingChunk: true,
chunks: "all",
name: "common_app",
minSize: 0,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
// we are opting out of defaultVendors, so rest of the node modules will be part of default cacheGroup
// defaultVendors: false,
reactPackage: {
test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom)[\\/]/,
name: 'vendor_react',
chunks: "all",
priority: 10,
}
},
// cacheGroups: {
// common: {
// test: /[\\/]node_modules[\\/]/,
// priority: -5,
// reuseExistingChunk: true,
// chunks: "all",
// name: "common_app",
// minSize: 0,
// },
// // default: {
// // minChunks: 2,
// // priority: -20,
// // reuseExistingChunk: true,
// // },
// // we are opting out of defaultVendors, so rest of the node modules will be part of default cacheGroup
// // defaultVendors: false,
// // reactPackage: {
// // test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom)[\\/]/,
// // name: 'vendor_react',
// // chunks: "all",
// // priority: 10,
// // }
// },

}
},
Expand Down

0 comments on commit f290c68

Please sign in to comment.