diff --git a/confd/production.tmpl b/confd/production.tmpl index 45d46406..5b188703 100644 --- a/confd/production.tmpl +++ b/confd/production.tmpl @@ -62,6 +62,11 @@ window._env_ = { WHATSNEW_URL: '{{getv "/configuration/whatsnew/url" "http://whatsnew-URL"}}', SITES_CONFIG: '{{ getv "/configuration/sites/config" "{\"masters\": [{ \"dns\": \"http://localhost:3000\", \"isAlias\": false }], \"slaves\": [{ \"dns\": \"http://localhost:8090\", \"isAlias\": false }], \"generics\": [{ \"dns\": \"https://catalog.mapcolonies.net\", \"isAlias\": false }]}"}}', BFF_PATH: '{{getv "/configuration/bff/path" "/graphql"}}', - POLYGON_PARTS_FEATURE_TYPE_PREFIX: '{{getv "/configuration/polygon/parts/feature/type/prefix" "polygonParts:"}}', - POLYGON_PARTS_MAX_PER_SHAPE: {{getv "/configuration/polygon/parts/maxpershape" "300"}} + POLYGON_PARTS: { + featureTypePrefix: '{{getv "/configuration/polygonparts/featuretypeprefix" "polygonParts:"}}', + max: { + perShape: {{getv "/configuration/polygonparts/max/pershape" "300"}}, + vertices: {{getv "/configuration/polygonparts/max/vertices" "300000"}} + } + } }; diff --git a/confd/production.toml b/confd/production.toml index 267ad9a8..96ecec81 100644 --- a/confd/production.toml +++ b/confd/production.toml @@ -47,6 +47,7 @@ keys = [ "/configuration/whatsnew/url", "/configuration/sites/config", "/configuration/bff/path", - "/configuration/polygon/parts/feature/type/prefix", - "/configuration/polygon/parts/maxpershape" + "/configuration/polygonparts/featuretypeprefix", + "/configuration/polygonparts/max/pershape", + "/configuration/polygonparts/max/vertices" ] diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 1c4e8143..873055ab 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -56,8 +56,9 @@ CONFIGURATION_WHATSNEW_URL: {{ quote .Values.env.whatsnewUrl }} CONFIGURATION_SITES_CONFIG: {{ quote .Values.env.sitesConfig }} CONFIGURATION_BFF_PATH: {{ quote .Values.env.bffPath }} - CONFIGURATION_POLYGON_PARTS_FEATURE_TYPE_PREFIX: {{ quote .Values.env.polygonPartsFeatureTypePrefix }} - CONFIGURATION_POLYGON_PARTS_MAXPERSHAPE: {{ quote .Values.env.polygonPartsMaxPerShape }} + CONFIGURATION_POLYGONPARTS_FEATURETYPEPREFIX: {{ quote .Values.env.polygonParts.featureTypePrefix }} + CONFIGURATION_POLYGONPARTS_MAX_PERSHAPE: {{ quote .Values.env.polygonParts.max.perShape }} + CONFIGURATION_POLYGONPARTS_MAX_VERTICES: {{ quote .Values.env.polygonParts.max.vertices }} {{- end -}} {{ include "mc-chart.configmap" (dict "MAIN_OBJECT_BLOCK" $MAIN_OBJECT_BLOCK "COMPONENT_NAME" $COMPONENT_NAME "DATA" $DATA "WITH_TELEMETRY_TRACING" false "WITH_TELEMETRY_METRICS" false "context" .)}} diff --git a/helm/values.yaml b/helm/values.yaml index 85e9990e..19a226e5 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -148,8 +148,11 @@ env: projection: '' sitesConfig: '{"masters": [{ "dns": "http://localhost:3000", "isAlias": "false" }], "slaves": [{ "dns": "http://localhost:8090", "isAlias": "false" }], "generics": []}' bffPath: '' - polygonPartsFeatureTypePrefix: '' - polygonPartsMaxPerShape: 300 + polygonParts: + featureTypePrefix: '' + max: + perShape: 300 + vertices: 300000 route: enabled: true annotations: diff --git a/src/__mocks__/confEnvShim.js b/src/__mocks__/confEnvShim.js index 0e1fe9b3..6153db4e 100644 --- a/src/__mocks__/confEnvShim.js +++ b/src/__mocks__/confEnvShim.js @@ -65,8 +65,13 @@ if (!window._env_) { WHATSNEW_URL: 'http://whatsnew-URL', SITES_CONFIG: '{"masters": [{ "dns": "http://localhost:3000", "isAlias": false }], "slaves": [{ "dns": "http://localhost:8090", "isAlias": false }], "generics": [{ "dns": "https://catalog.mapcolonies.net", "isAlias": false }]}', BFF_PATH: '/graphql', - POLYGON_PARTS_FEATURE_TYPE_PREFIX: 'polygonParts:', - POLYGON_PARTS_MAX_PER_SHAPE: 300 + POLYGON_PARTS: { + featureTypePrefix: 'polygonParts:', + max: { + perShape: 300, + vertices: 3, + } + } }; })(void 0); } diff --git a/src/common/config/index.ts b/src/common/config/index.ts index be2b8b75..5d103b98 100644 --- a/src/common/config/index.ts +++ b/src/common/config/index.ts @@ -30,8 +30,7 @@ const PROJECT_VERSION = (window as any)._env_.PROJECT_VERSION; const WHATSNEW_URL = (window as any)._env_.WHATSNEW_URL; const SITES_CONFIG = JSON.parse((window as any)._env_.SITES_CONFIG); const BFF_PATH = (window as any)._env_.BFF_PATH; -const POLYGON_PARTS_FEATURE_TYPE_PREFIX = (window as any)._env_.POLYGON_PARTS_FEATURE_TYPE_PREFIX; -const POLYGON_PARTS_MAX_PER_SHAPE = (window as any)._env_.POLYGON_PARTS_MAX_PER_SHAPE; +const POLYGON_PARTS = (window as any)._env_.POLYGON_PARTS; const enrichBaseMaps = (baseMaps: IBaseMaps): IBaseMaps => { return { @@ -195,8 +194,13 @@ const APP_CONFIG = { WHATSNEW_URL: WHATSNEW_URL, SITES_CONFIG: SITES_CONFIG, BFF_PATH: BFF_PATH, - POLYGON_PARTS_FEATURE_TYPE_PREFIX: POLYGON_PARTS_FEATURE_TYPE_PREFIX, - POLYGON_PARTS_MAX_PER_SHAPE: POLYGON_PARTS_MAX_PER_SHAPE, + POLYGON_PARTS: { + FEATURE_TYPE_PREFIX: POLYGON_PARTS.featureTypePrefix, + MAX: { + PER_SHAPE: POLYGON_PARTS.max.perShape, + VERTICES: POLYGON_PARTS.max.vertices, + } + } }; export default APP_CONFIG; diff --git a/src/common/i18n/en.json b/src/common/i18n/en.json index df28d832..10c87051 100644 --- a/src/common/i18n/en.json +++ b/src/common/i18n/en.json @@ -494,6 +494,7 @@ "validation-general.number": "{fieldName} is required and numeric", "validation-general.date.future": "{fieldName} cannot be future date", "validation-general.shapeFile.too-many-features": "Number of features exceeds {maxPPNumber}", + "validation-general.shapeFile.too-many-vertices": "Vertices number exceeds the limit of {maxVerticesPP}. Number defined polygons: {ppNumber}, total vertices {verticesNumber}", "validation-general.shapeFile.generic": "Please select zip file with only shape or related files, or a single shape file", "validation-general.shapeFile.polygonParts.not-in-gpkg-extent": "Polygon Parts from shape file are not in GPKG extent", "validation-general.polygonParts.hasErrors": "Marked {numErrorParts} Plygon Parts has errors. Complete missing data or fix the SHAPE file.", diff --git a/src/common/i18n/he.json b/src/common/i18n/he.json index bcc491bb..d47e5d89 100644 --- a/src/common/i18n/he.json +++ b/src/common/i18n/he.json @@ -498,6 +498,7 @@ "validation-general.number": "{fieldName} הוא שדה חובה ומספרי", "validation-general.date.future": "{fieldName} לא יכול להיות תאריך עתידי", "validation-general.shapeFile.too-many-features": "מס' חלקי תיחום חורג מ {maxPPNumber}", + "validation-general.shapeFile.too-many-vertices": "מספר נקודות חורג מ {maxVerticesPP}. {ppNumber} פוליגונים מורכבים מ {verticesNumber} נקודות", "validation-general.shapeFile.generic": "יש לוודא שבחרת בקובץ zip המכיל קבצי shape ונלווים בלבד, או קובץ shape בודד", "validation-general.shapeFile.polygonParts.not-in-gpkg-extent": "חלקי תיחום מחוץ לGPKG", "validation-general.polygonParts.hasErrors": "{numErrorParts} חלקי תיחום שגויים, נדרש להשלים מידע על חלקי תיחום או לתקן קובץ shape", diff --git a/src/discrete-layer/components/layer-details/raster/layer-datails-form.raster.tsx b/src/discrete-layer/components/layer-details/raster/layer-datails-form.raster.tsx index 43c4deb6..235a3b63 100644 --- a/src/discrete-layer/components/layer-details/raster/layer-datails-form.raster.tsx +++ b/src/discrete-layer/components/layer-details/raster/layer-datails-form.raster.tsx @@ -143,6 +143,7 @@ export const InnerRasterForm = ( type POLYGON_PARTS_MODE = 'FROM_SHAPE' | 'MANUAL'; const POLYGON_PARTS_STATUS_ERROR = 'pp_status_errors'; + const ppConfig = CONFIG.POLYGON_PARTS; const intl = useIntl(); const ZOOM_LEVELS = useZoomLevels(); @@ -373,12 +374,27 @@ export const InnerRasterForm = ( // } // }, [sourceExtent, outlinedPerimeter]); - const excidedFeaturesNumberError = useMemo(() => new Error( + + const exceededFeaturesNumberError = useMemo(() => new Error( intl.formatMessage( { id: 'validation-general.shapeFile.too-many-features'}, - { maxPPNumber: emphasizeByHTML(`${CONFIG.POLYGON_PARTS_MAX_PER_SHAPE}`)} + { maxPPNumber: emphasizeByHTML(`${ppConfig.MAX.PER_SHAPE}`)} ) ), []); + + const exceededVertexNumberError = useCallback((numberOfPP: number, numberOfVertexes: number) => { + return new Error( + intl.formatMessage( + { id: 'validation-general.shapeFile.too-many-vertices' }, + { + maxVerticesPP: emphasizeByHTML(`${ppConfig.MAX.VERTICES}`), + ppNumber: emphasizeByHTML(`${numberOfPP}`), + verticesNumber: emphasizeByHTML(`${numberOfVertexes}`) + } + ) + ); + }, []); + const shapeFileGenericError = useMemo(() => new Error(`validation-general.shapeFile.generic`), []); // const shapeFilePerimeterVSGpkgExtentError = useMemo(() => new Error(`validation-general.shapeFile.polygonParts.not-in-gpkg-extent`), []); @@ -533,11 +549,19 @@ export const InnerRasterForm = ( }; const isShapeFileValid = (featuresArr: unknown[] | undefined): boolean | Error => { + let verticesNum = 0; + featuresArr?.forEach(f => { + //@ts-ignore + verticesNum += f.geometry.coordinates.length; + }); if (typeof featuresArr === 'undefined') { return shapeFileGenericError; } - if (featuresArr && featuresArr.length > CONFIG.POLYGON_PARTS_MAX_PER_SHAPE) { - return excidedFeaturesNumberError; + if (featuresArr && featuresArr.length > ppConfig.MAX.PER_SHAPE) { + return exceededFeaturesNumberError; + } + if(verticesNum > ppConfig.MAX.VERTICES){ + return exceededVertexNumberError(featuresArr.length, verticesNum) } return true; } diff --git a/src/discrete-layer/components/layer-details/raster/pp-map.utils.ts b/src/discrete-layer/components/layer-details/raster/pp-map.utils.ts index 286bea69..13196ce3 100644 --- a/src/discrete-layer/components/layer-details/raster/pp-map.utils.ts +++ b/src/discrete-layer/components/layer-details/raster/pp-map.utils.ts @@ -87,7 +87,7 @@ export const getWFSFeatureTypeName = (layerRecord: LayerRasterRecordModelType | // Naming convension of polygon parts feature typeName // polygonParts:{productId}-{productType} return layerRecord ? - `${CONFIG.POLYGON_PARTS_FEATURE_TYPE_PREFIX}${layerRecord.productId}-${enums[layerRecord.productType as string].realValue}` : + `${CONFIG.POLYGON_PARTS.FEATURE_TYPE_PREFIX}${layerRecord.productId}-${enums[layerRecord.productType as string].realValue}` : 'SHOULD_BE_CALCULATED_FROM_UPDATED_LAYER'; }