From d9b34d308945814e0a6cd8adfeed96fccd994b35 Mon Sep 17 00:00:00 2001 From: yanxiong Date: Fri, 29 Mar 2024 11:26:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=BB=E9=99=A4=20geojsonhint=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 - src/pages/components/editor.tsx | 15 ++------------- src/recoil/feature.ts | 26 ++++++-------------------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 91aceb2..7a270dd 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "@antv/larkmap": "^1.4.4", "@antv/sam": "^0.1.0", "@emotion/css": "^11.11.2", - "@mapbox/geojsonhint": "^3.3.0", "@mapbox/togeojson": "^0.16.0", "@turf/turf": "^6.5.0", "ahooks": "^3.7.0", diff --git a/src/pages/components/editor.tsx b/src/pages/components/editor.tsx index 5d66184..d198fa8 100644 --- a/src/pages/components/editor.tsx +++ b/src/pages/components/editor.tsx @@ -1,5 +1,3 @@ -//@ts-ignore -import { hint } from '@mapbox/geojsonhint'; import { useAsyncEffect, useUpdateEffect } from 'ahooks'; import { ConfigProvider, theme as antdTheme, message } from 'antd'; import classNames from 'classnames'; @@ -57,17 +55,8 @@ export const Editor: React.FC = (props) => { )) as string | null; if (newEditorText && scene && !props.features) { try { - const errors = hint(JSON.parse(newEditorText)).filter( - (item: { message: string }) => - item.message !== - 'Polygons and MultiPolygons should follow the right-hand rule', - ); - if (errors.length > 0) { - message.error(t('import_btn.file_upload.qingJianChaShuJu')); - } else { - const newFeatures = JSON.parse(newEditorText).features; - bboxAutoFit(newFeatures); - } + const newFeatures = JSON.parse(newEditorText).features; + bboxAutoFit(newFeatures); } catch (error) { message.error(t('import_btn.file_upload.qingJianChaShuJu')); } diff --git a/src/recoil/feature.ts b/src/recoil/feature.ts index 19db9d7..1fbbb8d 100644 --- a/src/recoil/feature.ts +++ b/src/recoil/feature.ts @@ -1,8 +1,5 @@ -//@ts-ignore -import { hint } from '@mapbox/geojsonhint'; import type { Feature } from '@turf/turf'; import { bbox, featureCollection, getType } from '@turf/turf'; -import { message } from 'antd'; import { cloneDeep, flatMap, max, min } from 'lodash-es'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -72,23 +69,12 @@ export default function useFeature() { ); let newFeatures: Feature[] = []; if (editorText || value) { - try { - const errors = hint(JSON.parse(value ?? editorText)).filter( - (item: { message: string }) => - item.message !== - 'Polygons and MultiPolygons should follow the right-hand rule', - ); - if (errors.length > 0) { - message.warning(t('recoil.feature.shuJuJiaZaiYou')); - } else { - newFeatures = transformFeatures(value ?? editorText, t); - if (value) { - setEditorText(value); - } - setSavedText(value ?? editorText); - setFeatures(newFeatures as IFeatures); - } - } catch (error) {} + newFeatures = transformFeatures(value ?? editorText, t); + if (value) { + setEditorText(value); + } + setSavedText(value ?? editorText); + setFeatures(newFeatures as IFeatures); } else { setEditorText(emptyFeatures); setSavedText(emptyFeatures);