geostyler 10.1.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/geostyler.css +1 -1
- package/browser/geostyler.js +1 -1
- package/dist/Component/DataInput/DataLoader/DataLoader.d.ts +3 -0
- package/dist/Component/DataInput/DataLoader/DataLoader.js +3 -3
- package/dist/Component/DataInput/DataLoader/DataLoader.js.map +1 -1
- package/dist/Component/DataInput/WfsParserInput/WfsParserInput.js +25 -16
- package/dist/Component/DataInput/WfsParserInput/WfsParserInput.js.map +1 -1
- package/dist/Component/Filter/ComparisonFilter/ComparisonFilter.js +1 -1
- package/dist/Component/Filter/ComparisonFilter/ComparisonFilter.js.map +1 -1
- package/dist/Component/PreviewMap/PreviewMap.js +5 -3
- package/dist/Component/PreviewMap/PreviewMap.js.map +1 -1
- package/dist/Component/RuleGenerator/ColorRampCombo/ColorRampCombo.css +3 -0
- package/dist/Component/UploadButton/UploadButton.d.ts +2 -2
- package/dist/Component/UploadButton/UploadButton.js +4 -27
- package/dist/Component/UploadButton/UploadButton.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/locale/de_DE.js +2 -1
- package/dist/locale/de_DE.js.map +1 -1
- package/dist/locale/en_US.js +2 -1
- package/dist/locale/en_US.js.map +1 -1
- package/dist/locale/es_ES.js +2 -1
- package/dist/locale/es_ES.js.map +1 -1
- package/dist/locale/fr_FR.js +2 -1
- package/dist/locale/fr_FR.js.map +1 -1
- package/dist/locale/locale.d.ts +1 -0
- package/dist/locale/locale.js.map +1 -1
- package/dist/locale/zh_CN.js +2 -1
- package/dist/locale/zh_CN.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { VectorData, DataParser } from 'geostyler-data';
|
|
3
|
+
import { UploadButtonProps } from '../../UploadButton/UploadButton';
|
|
3
4
|
import { GeoStylerLocale } from '../../../locale/locale';
|
|
4
5
|
interface DataLoaderDefaultProps {
|
|
5
6
|
/** The callback method that is triggered when the state changes */
|
|
@@ -10,6 +11,8 @@ interface DataLoaderDefaultProps {
|
|
|
10
11
|
export interface DataLoaderProps extends Partial<DataLoaderDefaultProps> {
|
|
11
12
|
/** List of data parsers to use */
|
|
12
13
|
parsers: DataParser[];
|
|
14
|
+
/** Properties that get passed to the UploadButton. */
|
|
15
|
+
uploadButtonProps?: UploadButtonProps;
|
|
13
16
|
}
|
|
14
17
|
export declare const DataLoader: React.FC<DataLoaderProps>;
|
|
15
18
|
declare const _default: {
|
|
@@ -73,7 +73,7 @@ var WfsParserInput_1 = __importDefault(require("../WfsParserInput/WfsParserInput
|
|
|
73
73
|
var LocaleWrapper_1 = require("../../LocaleWrapper/LocaleWrapper");
|
|
74
74
|
var en_US_1 = __importDefault(require("../../../locale/en_US"));
|
|
75
75
|
var DataLoader = function (_a) {
|
|
76
|
-
var parsers = _a.parsers, _b = _a.locale, locale = _b === void 0 ? en_US_1.default.DataLoader : _b, _c = _a.onDataRead, onDataRead = _c === void 0 ? function () {
|
|
76
|
+
var parsers = _a.parsers, _b = _a.locale, locale = _b === void 0 ? en_US_1.default.DataLoader : _b, uploadButtonProps = _a.uploadButtonProps, _c = _a.onDataRead, onDataRead = _c === void 0 ? function () {
|
|
77
77
|
return;
|
|
78
78
|
} : _c;
|
|
79
79
|
var _d = React.useState(false), modalVisible = _d[0], setModalVisible = _d[1];
|
|
@@ -144,9 +144,9 @@ var DataLoader = function (_a) {
|
|
|
144
144
|
if (activeParser) {
|
|
145
145
|
switch (activeParser.title) {
|
|
146
146
|
case 'GeoJSON Data Parser':
|
|
147
|
-
return (React.createElement(UploadButton_1.default, { customRequest: parseGeoJsonUploadData }));
|
|
147
|
+
return (React.createElement(UploadButton_1.default, __assign({ customRequest: parseGeoJsonUploadData }, uploadButtonProps)));
|
|
148
148
|
case 'Shapefile Data Parser':
|
|
149
|
-
return (React.createElement(UploadButton_1.default, { customRequest: parseShapefileUploadData }));
|
|
149
|
+
return (React.createElement(UploadButton_1.default, __assign({ customRequest: parseShapefileUploadData }, uploadButtonProps)));
|
|
150
150
|
case 'WFS Data Parser':
|
|
151
151
|
return (React.createElement(antd_1.Modal, { className: "wfs-parser-modal", title: activeParser.title, visible: modalVisible, onCancel: closeModal, onOk: closeModal },
|
|
152
152
|
React.createElement(WfsParserInput_1.default, { onClick: parseWfsData })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLoader.js","sourceRoot":"","sources":["../../../../src/Component/DataInput/DataLoader/DataLoader.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA+B;AAE/B,6BAAqC;AAGrC,IAAM,MAAM,GAAG,aAAM,CAAC,MAAM,CAAC;AAU7B,iFAA2D;AAC3D,oFAA8D;AAE9D,mEAA6D;AAE7D,gEAA0C;AAiBnC,IAAM,UAAU,GAA8B,UAAC,EAMrD;QALC,OAAO,aAAA,EACP,cAAyB,EAAzB,MAAM,mBAAG,eAAK,CAAC,UAAU,KAAA,EACzB,kBAEC,EAFD,UAAU,mBAAG;QACX,OAAO;IACT,CAAC,KAAA;IAGK,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,EAA/D,YAAY,QAAA,EAAE,eAAe,QAAkC,CAAC;IACjE,IAAA,KAAmC,KAAK,CAAC,QAAQ,EAAc,EAA9D,YAAY,QAAA,EAAE,gBAAgB,QAAgC,CAAC;IAEtE,IAAM,sBAAsB,GAAG,UAAC,YAAsC;QACpE,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QACD,IAAM,IAAI,GAAG,YAAY,CAAC,IAAY,CAAC;QACvC,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,C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pB,IAAI,EAAE,UAAU;wBAEhB,oBAAC,wBAAc,IACb,OAAO,EAAE,YAAY,GACrB,CACI,CACT,CAAC;gBACJ;oBACE,OAAO,CACL,oBAAC,sBAAY,IACX,aAAa,EAAE,sBAAsB,GACrC,CACH,CAAC;aACL;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;QACtD,MAAM,CAAC,KAAK;QACb,oBAAC,aAAM,IACL,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EACrB,QAAQ,EAAE,QAAQ,IAEjB,aAAa,CACP;QACR,kBAAkB,EAAE,CACjB,CACP,CAAC;AACJ,CAAC,CAAC;AAvIW,QAAA,UAAU,cAuIrB;AAEF,kBAAe,IAAA,wBAAQ,EAAC,kBAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport * as React from 'react';\n\nimport { Select, Modal } from 'antd';\nimport { UploadRequestOption } from 'rc-upload/lib/interface';\n\nconst Option = Select.Option;\n\nimport {\n VectorData,\n DataParser,\n Data\n} from 'geostyler-data';\n\nimport { ReadParams } from 'geostyler-wfs-parser';\n\nimport UploadButton from '../../UploadButton/UploadButton';\nimport WfsParserInput from '../WfsParserInput/WfsParserInput';\n\nimport { localize } from '../../LocaleWrapper/LocaleWrapper';\nimport { GeoStylerLocale } from '../../../locale/locale';\nimport en_US from '../../../locale/en_US';\n\n\n// default props\ninterface DataLoaderDefaultProps {\n /** The callback method that is triggered when the state changes */\n onDataRead: (data: VectorData) => void;\n /** Locale object containing translated text snippets */\n locale: GeoStylerLocale['DataLoader'];\n}\n\n// non default props\nexport interface DataLoaderProps extends Partial<DataLoaderDefaultProps> {\n /** List of data parsers to use */\n parsers: DataParser[];\n}\n\nexport const DataLoader: React.FC<DataLoaderProps> = ({\n parsers,\n locale = en_US.DataLoader,\n onDataRead = () => {\n return;\n }\n}) => {\n\n const [modalVisible, setModalVisible] = React.useState<boolean>(false);\n const [activeParser, setActitveParser] = React.useState<DataParser>();\n\n const parseGeoJsonUploadData = (uploadObject: UploadRequestOption<any>) => {\n if (!activeParser) {\n return;\n }\n const file = uploadObject.file as File;\n const reader = new FileReader();\n reader.readAsText(file);\n reader.onload = () => {\n const fileContent = reader.result.toString();\n\n // TODO: Remove JSON.parse when type of readData is more precise\n activeParser.readData(JSON.parse(fileContent))\n .then(data => {\n onDataRead(data as VectorData);\n uploadObject.onSuccess(data);\n })\n .catch((e) => {\n uploadObject.onError(e, 'Upload failed. Invalid Data.');\n });\n };\n };\n\n const parseShapefileUploadData = (uploadObject: UploadRequestOption<any>) => {\n if (!activeParser) {\n return;\n }\n const file = uploadObject.file as File;\n const reader = new FileReader();\n reader.readAsArrayBuffer(file);\n reader.onload = () => {\n activeParser.readData(reader.result)\n .then(data => {\n onDataRead(data as VectorData);\n uploadObject.onSuccess(data);\n })\n .catch((e) => {\n uploadObject.onError(e, 'Upload failed. Invalid Data.');\n });\n };\n };\n\n const parseWfsData = (wfsReadParams: ReadParams) => {\n if (!activeParser) {\n return;\n }\n // The dataProjection of the Preview\n activeParser.readData({\n ...wfsReadParams,\n srsName: 'EPSG:4326'\n })\n .then((data: Data) => {\n onDataRead(data as VectorData);\n setModalVisible(false);\n });\n };\n\n const parserOptions = parsers.map((parser: any) =>\n <Option key={parser.title} value={parser.title}>{parser.title}</Option>\n );\n\n const onSelect = (selection: string) => {\n const newActiveParser = parsers.find(parser => parser.title === selection);\n if (newActiveParser) {\n setActitveParser(newActiveParser);\n setModalVisible(newActiveParser.title === 'WFS Data Parser');\n }\n };\n\n const closeModal = () => {\n setModalVisible(false);\n };\n\n const getInputFromParser = () => {\n if (activeParser) {\n switch (activeParser.title) {\n case 'GeoJSON Data Parser':\n return (\n <UploadButton\n customRequest={parseGeoJsonUploadData}\n />\n );\n case 'Shapefile Data Parser':\n return (\n <UploadButton\n customRequest={parseShapefileUploadData}\n />\n );\n case 'WFS Data Parser':\n return (\n <Modal\n className=\"wfs-parser-modal\"\n title={activeParser.title}\n visible={modalVisible}\n onCancel={closeModal}\n onOk={closeModal}\n >\n <WfsParserInput\n onClick={parseWfsData}\n />\n </Modal>\n );\n default:\n return (\n <UploadButton\n customRequest={parseGeoJsonUploadData}\n />\n );\n }\n }\n return null;\n };\n\n return (\n <div className={activeParser ? 'gs-dataloader-right' : ''}>\n {locale.label}\n <Select\n style={{ width: 300 }}\n onSelect={onSelect}\n >\n {parserOptions}\n </Select>\n {getInputFromParser()}\n </div>\n );\n};\n\nexport default localize(DataLoader, 'DataLoader');\n"]}
|
|
1
|
+
{"version":3,"file":"DataLoader.js","sourceRoot":"","sources":["../../../../src/Component/DataInput/DataLoader/DataLoader.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA+B;AAE/B,6BAAqC;AAGrC,IAAM,MAAM,GAAG,aAAM,CAAC,MAAM,CAAC;AAU7B,iFAAkF;AAClF,oFAA8D;AAE9D,mEAA6D;AAE7D,gEAA0C;AAmBnC,IAAM,UAAU,GAA8B,UAAC,EAOrD;QANC,OAAO,aAAA,EACP,cAAyB,EAAzB,MAAM,mBAAG,eAAK,CAAC,UAAU,KAAA,EACzB,iBAAiB,uBAAA,EACjB,kBAEC,EAFD,UAAU,mBAAG;QACX,OAAO;IACT,CAAC,KAAA;IAGK,IAAA,KAAkC,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,EAA/D,YAAY,QAAA,EAAE,eAAe,QAAkC,CAAC;IACjE,IAAA,KAAmC,KAAK,CAAC,QAAQ,EAAc,EAA9D,YAAY,QAAA,EAAE,gBAAgB,QAAgC,CAAC;IAEtE,IAAM,sBAAsB,GAAG,UAAC,YAAsC;QACpE,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QACD,IAAM,IAAI,GAAG,YAAY,CAAC,IAAY,CAAC;QACvC,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,CAAC,MAAM,GAAG;YACd,IAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAE7C,gEAAgE;YAChE,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAA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AAsB,GACrC,CACH,CAAC;aACL;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;QACtD,MAAM,CAAC,KAAK;QACb,oBAAC,aAAM,IACL,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EACrB,QAAQ,EAAE,QAAQ,IAEjB,aAAa,CACP;QACR,kBAAkB,EAAE,CACjB,CACP,CAAC;AACJ,CAAC,CAAC;AA1IW,QAAA,UAAU,cA0IrB;AAEF,kBAAe,IAAA,wBAAQ,EAAC,kBAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport * as React from 'react';\n\nimport { Select, Modal } from 'antd';\nimport { UploadRequestOption } from 'rc-upload/lib/interface';\n\nconst Option = Select.Option;\n\nimport {\n VectorData,\n DataParser,\n Data\n} from 'geostyler-data';\n\nimport { ReadParams } from 'geostyler-wfs-parser';\n\nimport UploadButton, { UploadButtonProps } from '../../UploadButton/UploadButton';\nimport WfsParserInput from '../WfsParserInput/WfsParserInput';\n\nimport { localize } from '../../LocaleWrapper/LocaleWrapper';\nimport { GeoStylerLocale } from '../../../locale/locale';\nimport en_US from '../../../locale/en_US';\n\n\n// default props\ninterface DataLoaderDefaultProps {\n /** The callback method that is triggered when the state changes */\n onDataRead: (data: VectorData) => void;\n /** Locale object containing translated text snippets */\n locale: GeoStylerLocale['DataLoader'];\n}\n\n// non default props\nexport interface DataLoaderProps extends Partial<DataLoaderDefaultProps> {\n /** List of data parsers to use */\n parsers: DataParser[];\n /** Properties that get passed to the UploadButton. */\n uploadButtonProps?: UploadButtonProps;\n}\n\nexport const DataLoader: React.FC<DataLoaderProps> = ({\n parsers,\n locale = en_US.DataLoader,\n uploadButtonProps,\n onDataRead = () => {\n return;\n }\n}) => {\n\n const [modalVisible, setModalVisible] = React.useState<boolean>(false);\n const [activeParser, setActitveParser] = React.useState<DataParser>();\n\n const parseGeoJsonUploadData = (uploadObject: UploadRequestOption<any>) => {\n if (!activeParser) {\n return;\n }\n const file = uploadObject.file as File;\n const reader = new FileReader();\n reader.readAsText(file);\n reader.onload = () => {\n const fileContent = reader.result.toString();\n\n // TODO: Remove JSON.parse when type of readData is more precise\n activeParser.readData(JSON.parse(fileContent))\n .then(data => {\n onDataRead(data as VectorData);\n uploadObject.onSuccess(data);\n })\n .catch((e) => {\n uploadObject.onError(e, 'Upload failed. Invalid Data.');\n });\n };\n };\n\n const parseShapefileUploadData = (uploadObject: UploadRequestOption<any>) => {\n if (!activeParser) {\n return;\n }\n const file = uploadObject.file as File;\n const reader = new FileReader();\n reader.readAsArrayBuffer(file);\n reader.onload = () => {\n activeParser.readData(reader.result)\n .then(data => {\n onDataRead(data as VectorData);\n uploadObject.onSuccess(data);\n })\n .catch((e) => {\n uploadObject.onError(e, 'Upload failed. Invalid Data.');\n });\n };\n };\n\n const parseWfsData = (wfsReadParams: ReadParams) => {\n if (!activeParser) {\n return;\n }\n // The dataProjection of the Preview\n activeParser.readData({\n ...wfsReadParams,\n srsName: 'EPSG:4326'\n })\n .then((data: Data) => {\n onDataRead(data as VectorData);\n setModalVisible(false);\n });\n };\n\n const parserOptions = parsers.map((parser: any) =>\n <Option key={parser.title} value={parser.title}>{parser.title}</Option>\n );\n\n const onSelect = (selection: string) => {\n const newActiveParser = parsers.find(parser => parser.title === selection);\n if (newActiveParser) {\n setActitveParser(newActiveParser);\n setModalVisible(newActiveParser.title === 'WFS Data Parser');\n }\n };\n\n const closeModal = () => {\n setModalVisible(false);\n };\n\n const getInputFromParser = () => {\n if (activeParser) {\n switch (activeParser.title) {\n case 'GeoJSON Data Parser':\n return (\n <UploadButton\n customRequest={parseGeoJsonUploadData}\n {...uploadButtonProps}\n />\n );\n case 'Shapefile Data Parser':\n return (\n <UploadButton\n customRequest={parseShapefileUploadData}\n {...uploadButtonProps}\n />\n );\n case 'WFS Data Parser':\n return (\n <Modal\n className=\"wfs-parser-modal\"\n title={activeParser.title}\n visible={modalVisible}\n onCancel={closeModal}\n onOk={closeModal}\n >\n <WfsParserInput\n onClick={parseWfsData}\n />\n </Modal>\n );\n default:\n return (\n <UploadButton\n customRequest={parseGeoJsonUploadData}\n />\n );\n }\n }\n return null;\n };\n\n return (\n <div className={activeParser ? 'gs-dataloader-right' : ''}>\n {locale.label}\n <Select\n style={{ width: 300 }}\n onSelect={onSelect}\n >\n {parserOptions}\n </Select>\n {getInputFromParser()}\n </div>\n );\n};\n\nexport default localize(DataLoader, 'DataLoader');\n"]}
|
|
@@ -75,23 +75,25 @@ var en_US_1 = __importDefault(require("../../../locale/en_US"));
|
|
|
75
75
|
* WfsParserInput
|
|
76
76
|
*/
|
|
77
77
|
var WfsParserInput = function (_a) {
|
|
78
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
78
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
79
|
+
var _r = _a.locale, locale = _r === void 0 ? en_US_1.default.WfsParserInput : _r, onClickProp = _a.onClick;
|
|
80
|
+
var _s = (0, react_1.useState)('https://ows-demo.terrestris.de/geoserver/terrestris/ows'), url = _s[0], setUrl = _s[1];
|
|
81
|
+
var _t = (0, react_1.useState)('1.1.0'), version = _t[0], setVersion = _t[1];
|
|
82
|
+
var _u = (0, react_1.useState)('terrestris:bundeslaender'), typeName = _u[0], setTypeName = _u[1];
|
|
83
|
+
var _v = (0, react_1.useState)(), featureID = _v[0], setFeatureID = _v[1];
|
|
84
|
+
var _w = (0, react_1.useState)(), propertyName = _w[0], setPropertyName = _w[1];
|
|
85
|
+
var _x = (0, react_1.useState)(), srsName = _x[0], setSrsName = _x[1];
|
|
86
|
+
var _y = (0, react_1.useState)(), maxFeatures = _y[0], setMaxFeatures = _y[1];
|
|
87
|
+
var _z = (0, react_1.useState)({
|
|
87
88
|
url: undefined,
|
|
88
89
|
version: undefined,
|
|
89
90
|
typeName: undefined,
|
|
90
91
|
featureID: undefined,
|
|
91
92
|
propertyName: undefined,
|
|
92
93
|
maxFeatures: undefined,
|
|
93
|
-
fetchParams: undefined
|
|
94
|
-
|
|
94
|
+
fetchParams: undefined,
|
|
95
|
+
srsName: undefined
|
|
96
|
+
}), validation = _z[0], setValidation = _z[1];
|
|
95
97
|
var onUrlChange = function (event) {
|
|
96
98
|
var newUrl = event.target.value;
|
|
97
99
|
var urlValidation = {};
|
|
@@ -130,6 +132,9 @@ var WfsParserInput = function (_a) {
|
|
|
130
132
|
var onFeatureIDChange = function (event) {
|
|
131
133
|
setFeatureID(event.target.value);
|
|
132
134
|
};
|
|
135
|
+
var onSrsNameChange = function (event) {
|
|
136
|
+
setSrsName(event.target.value);
|
|
137
|
+
};
|
|
133
138
|
var onPropertyNameChange = function (newPropertyName) {
|
|
134
139
|
setPropertyName(newPropertyName);
|
|
135
140
|
};
|
|
@@ -144,7 +149,8 @@ var WfsParserInput = function (_a) {
|
|
|
144
149
|
typeName: typeName,
|
|
145
150
|
maxFeatures: maxFeatures,
|
|
146
151
|
featureID: featureID,
|
|
147
|
-
propertyName: propertyName
|
|
152
|
+
propertyName: propertyName,
|
|
153
|
+
srsName: srsName
|
|
148
154
|
};
|
|
149
155
|
}
|
|
150
156
|
else {
|
|
@@ -153,7 +159,8 @@ var WfsParserInput = function (_a) {
|
|
|
153
159
|
typeNames: typeName,
|
|
154
160
|
count: maxFeatures,
|
|
155
161
|
featureID: featureID,
|
|
156
|
-
propertyName: propertyName
|
|
162
|
+
propertyName: propertyName,
|
|
163
|
+
srsName: srsName
|
|
157
164
|
};
|
|
158
165
|
}
|
|
159
166
|
onClickProp({
|
|
@@ -170,11 +177,13 @@ var WfsParserInput = function (_a) {
|
|
|
170
177
|
react_1.default.createElement(antd_1.Select, { className: 'wfs-version-input', style: { width: '100%' }, value: version, onChange: onVersionChange },
|
|
171
178
|
react_1.default.createElement(Option, { value: "1.1.0" }, "1.1.0"),
|
|
172
179
|
react_1.default.createElement(Option, { value: "2.0.0" }, "2.0.0"))),
|
|
173
|
-
react_1.default.createElement(antd_1.Form.Item, { label: locale.
|
|
180
|
+
react_1.default.createElement(antd_1.Form.Item, { label: locale.srsNameLabel, validateStatus: (_h = validation === null || validation === void 0 ? void 0 : validation.srsName) === null || _h === void 0 ? void 0 : _h.status, help: (_j = validation === null || validation === void 0 ? void 0 : validation.srsName) === null || _j === void 0 ? void 0 : _j.message, hasFeedback: true },
|
|
181
|
+
react_1.default.createElement(antd_1.Input, { className: 'wfs-srsName-input', value: srsName, onChange: onSrsNameChange })),
|
|
182
|
+
react_1.default.createElement(antd_1.Form.Item, { label: locale.featureIDLabel, validateStatus: (_k = validation === null || validation === void 0 ? void 0 : validation.featureID) === null || _k === void 0 ? void 0 : _k.status, help: (_l = validation === null || validation === void 0 ? void 0 : validation.featureID) === null || _l === void 0 ? void 0 : _l.message, hasFeedback: true },
|
|
174
183
|
react_1.default.createElement(antd_1.Input, { className: 'wfs-featureid-input', value: featureID, onChange: onFeatureIDChange })),
|
|
175
|
-
react_1.default.createElement(antd_1.Form.Item, { label: locale.propertyNameLabel, validateStatus: (
|
|
184
|
+
react_1.default.createElement(antd_1.Form.Item, { label: locale.propertyNameLabel, validateStatus: (_m = validation === null || validation === void 0 ? void 0 : validation.propertyName) === null || _m === void 0 ? void 0 : _m.status, help: (_o = validation === null || validation === void 0 ? void 0 : validation.propertyName) === null || _o === void 0 ? void 0 : _o.message, hasFeedback: true },
|
|
176
185
|
react_1.default.createElement(antd_1.Select, { className: 'wfs-propertyname-input', style: { width: '100%' }, mode: "tags", value: propertyName, onChange: onPropertyNameChange })),
|
|
177
|
-
react_1.default.createElement(antd_1.Form.Item, { label: locale.maxFeaturesLabel, validateStatus: (
|
|
186
|
+
react_1.default.createElement(antd_1.Form.Item, { label: locale.maxFeaturesLabel, validateStatus: (_p = validation === null || validation === void 0 ? void 0 : validation.maxFeatures) === null || _p === void 0 ? void 0 : _p.status, help: (_q = validation === null || validation === void 0 ? void 0 : validation.maxFeatures) === null || _q === void 0 ? void 0 : _q.message, hasFeedback: true },
|
|
178
187
|
react_1.default.createElement(antd_1.InputNumber, { className: 'wfs-maxfeatures-input', style: { width: '100%' }, min: 0, value: maxFeatures, onChange: onMaxFeaturesChange, precision: 0 })),
|
|
179
188
|
react_1.default.createElement(antd_1.Form.Item, null,
|
|
180
189
|
react_1.default.createElement(antd_1.Button, { className: "wfs-parser-submit-button", type: "primary", onClick: onClick }, locale.requestButtonText))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WfsParserInput.js","sourceRoot":"","sources":["../../../../src/Component/DataInput/WfsParserInput/WfsParserInput.tsx"],"names":[],"mappings":";AAAA,8BAA8B;AAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwC;AAIxC,6BAMc;AACd,IAAM,MAAM,GAAG,aAAM,CAAC,MAAM,CAAC;AAE7B,iCAA+B;AAE/B,gEAA0C;AAgB1C;;GAEG;AACI,IAAM,cAAc,GAAkC,UAAC,EAG7D;;QAFC,cAA6B,EAA7B,MAAM,mBAAG,eAAK,CAAC,cAAc,KAAA,EACpB,WAAW,aAAA;IAGd,IAAA,KAAgB,IAAA,gBAAQ,EAAS,yDAAyD,CAAC,EAA1F,GAAG,QAAA,EAAE,MAAM,QAA+E,CAAC;IAC5F,IAAA,KAAwB,IAAA,gBAAQ,EAAa,OAAO,CAAC,EAApD,OAAO,QAAA,EAAE,UAAU,QAAiC,CAAC;IACtD,IAAA,KAA0B,IAAA,gBAAQ,EAAS,0BAA0B,CAAC,EAArE,QAAQ,QAAA,EAAE,WAAW,QAAgD,CAAC;IACvE,IAAA,KAA4B,IAAA,gBAAQ,GAAU,EAA7C,SAAS,QAAA,EAAE,YAAY,QAAsB,CAAC;IAC/C,IAAA,KAAkC,IAAA,gBAAQ,GAAU,EAAnD,YAAY,QAAA,EAAE,eAAe,QAAsB,CAAC;IACrD,IAAA,KAAgC,IAAA,gBAAQ,GAAU,EAAjD,WAAW,QAAA,EAAE,cAAc,QAAsB,CAAC;IACnD,IAAA,KAA8B,IAAA,gBAAQ,EAAC;QAC3C,GAAG,EAAE,SAAS;QACd,OAAO,EAAE,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Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport React, { useState } from 'react';\n\nimport { ReadParams, RequestParams } from 'geostyler-wfs-parser';\n\nimport {\n Form,\n Button,\n Input,\n Select,\n InputNumber\n} from 'antd';\nconst Option = Select.Option;\n\nimport './WfsParserInput.less';\nimport { GeoStylerLocale } from '../../../locale/locale';\nimport en_US from '../../../locale/en_US';\n\ntype WfsVersion = RequestParams['version'];\n\n// default props\ninterface WfsParserInputDefaultProps {\n /** Locale object containing translated text snippets */\n locale: GeoStylerLocale['WfsParserInput'];\n}\n\n// non default props\nexport interface WfsParserInputProps extends Partial<WfsParserInputDefaultProps> {\n /** The callback method that is triggered when the state changes */\n onClick: (wfsParams: ReadParams) => void;\n}\n\n/**\n * WfsParserInput\n */\nexport const WfsParserInput: React.FC<WfsParserInputProps> = ({\n locale = en_US.WfsParserInput,\n onClick: onClickProp\n}) => {\n\n const [url, setUrl] = useState<string>('https://ows-demo.terrestris.de/geoserver/terrestris/ows');\n const [version, setVersion] = useState<WfsVersion>('1.1.0');\n const [typeName, setTypeName] = useState<string>('terrestris:bundeslaender');\n const [featureID, setFeatureID] = useState<string>();\n const [propertyName, setPropertyName] = useState<string>();\n const [maxFeatures, setMaxFeatures] = useState<number>();\n const [validation, setValidation] = useState({\n url: undefined,\n version: undefined,\n typeName: undefined,\n featureID: undefined,\n propertyName: undefined,\n maxFeatures: undefined,\n fetchParams: undefined\n });\n\n const onUrlChange = (event: any) => {\n const newUrl = event.target.value;\n let urlValidation = {};\n if (newUrl.length <= 0) {\n urlValidation = {\n status: 'error',\n message: 'Url is required'\n };\n }\n setUrl(newUrl);\n setValidation({\n ...validation,\n url: urlValidation\n });\n };\n\n const onTypeNameChange = (event: any) => {\n const newTypeName = event.target.value;\n let typeNameValidation = {};\n if (newTypeName.length <= 0) {\n typeNameValidation = {\n status: 'error',\n message: 'TypeName is required'\n };\n }\n setTypeName(newTypeName);\n setValidation({\n ...validation,\n typeName: typeNameValidation\n });\n };\n\n const onVersionChange = (newVersion: WfsVersion) => {\n let versionValidation = {};\n if (newVersion.length <= 0) {\n versionValidation = {\n status: 'error',\n message: 'Version is required'\n };\n }\n setVersion(newVersion);\n setValidation({\n ...validation,\n version: versionValidation\n });\n };\n\n const onFeatureIDChange = (event: any) => {\n setFeatureID(event.target.value);\n };\n\n const onPropertyNameChange = (newPropertyName: string) => {\n setPropertyName(newPropertyName);\n };\n\n const onMaxFeaturesChange = (newMaxFeatures: number) => {\n setMaxFeatures(newMaxFeatures);\n };\n\n const onClick = () => {\n let requestParams;\n if (version === '1.1.0') {\n requestParams = {\n version,\n typeName,\n maxFeatures,\n featureID,\n propertyName\n };\n } else {\n requestParams = {\n version,\n typeNames: typeName,\n count: maxFeatures,\n featureID,\n propertyName\n };\n }\n onClickProp({\n url,\n requestParams\n });\n };\n\n return (\n <div className=\"wfs-parser-input\">\n <Form.Item\n label={locale.urlLabel}\n validateStatus={validation?.url?.status}\n help={validation?.url?.message}\n hasFeedback={true}\n required={true}\n >\n <Input\n className='wfs-url-input'\n value={url}\n onChange={onUrlChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.typeNameLabel}\n validateStatus={validation?.typeName?.status}\n help={validation?.typeName?.message}\n hasFeedback={true}\n required={true}\n >\n <Input\n className='wfs-typename-input'\n value={typeName}\n onChange={onTypeNameChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.versionLabel}\n validateStatus={validation?.version?.status}\n help={validation?.version?.message}\n hasFeedback={true}\n required={true}\n >\n <Select\n className='wfs-version-input'\n style={{width: '100%'}}\n value={version}\n onChange={onVersionChange}\n >\n <Option value=\"1.1.0\">1.1.0</Option>\n <Option value=\"2.0.0\">2.0.0</Option>\n </Select>\n </Form.Item>\n <Form.Item\n label={locale.featureIDLabel}\n validateStatus={validation?.featureID?.status}\n help={validation?.featureID?.message}\n hasFeedback={true}\n >\n <Input\n className='wfs-featureid-input'\n value={featureID}\n onChange={onFeatureIDChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.propertyNameLabel}\n validateStatus={validation?.propertyName?.status}\n help={validation?.propertyName?.message}\n hasFeedback={true}\n >\n <Select\n className='wfs-propertyname-input'\n style={{width: '100%'}}\n mode=\"tags\"\n value={propertyName}\n onChange={onPropertyNameChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.maxFeaturesLabel}\n validateStatus={validation?.maxFeatures?.status}\n help={validation?.maxFeatures?.message}\n hasFeedback={true}\n >\n <InputNumber\n className='wfs-maxfeatures-input'\n style={{width: '100%'}}\n min={0}\n value={maxFeatures}\n onChange={onMaxFeaturesChange}\n precision={0}\n />\n </Form.Item>\n <Form.Item>\n <Button\n className=\"wfs-parser-submit-button\"\n type=\"primary\"\n onClick={onClick}\n >\n {locale.requestButtonText}\n </Button>\n </Form.Item>\n </div>\n );\n};\n\nexport default WfsParserInput;\n"]}
|
|
1
|
+
{"version":3,"file":"WfsParserInput.js","sourceRoot":"","sources":["../../../../src/Component/DataInput/WfsParserInput/WfsParserInput.tsx"],"names":[],"mappings":";AAAA,8BAA8B;AAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAwC;AAIxC,6BAMc;AACd,IAAM,MAAM,GAAG,aAAM,CAAC,MAAM,CAAC;AAE7B,iCAA+B;AAE/B,gEAA0C;AAgB1C;;GAEG;AACI,IAAM,cAAc,GAAkC,UAAC,EAG7D;;QAFC,cAA6B,EAA7B,MAAM,mBAAG,eAAK,CAAC,cAAc,KAAA,EACpB,WAAW,aAAA;IAGd,IAAA,KAAgB,IAAA,gBAAQ,EAAS,yDAAyD,CAAC,EAA1F,GAAG,QAAA,EAAE,MAAM,QAA+E,CAAC;IAC5F,IAAA,KAAwB,IAAA,gBAAQ,EAAa,OAAO,CAAC,EAApD,OAAO,QAAA,EAAE,UAAU,QAAiC,CAAC;IACtD,IAAA,KAA0B,IAAA,gBAAQ,EAAS,0BAA0B,CAAC,EAArE,QAAQ,QAAA,EAAE,WAAW,QAAgD,CAAC;IACvE,IAAA,KAA4B,IAAA,gBAAQ,GAAU,EAA7C,SAAS,QAAA,EAAE,YAAY,QAAsB,CAAC;IAC/C,IAAA,KAAkC,IAAA,gBAAQ,GAAU,EAAnD,YAAY,QAAA,EAAE,eAAe,QAAsB,CAAC;IACrD,IAAA,KAAwB,IAAA,gBAAQ,GAAU,EAAzC,OAAO,QAAA,EAAE,UAAU,QAAsB,CAAC;IAC3C,IAAA,KAAgC,IAAA,gBAAQ,GAAU,E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AAc,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,0CAAE,MAAM,EAC/C,IAAI,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,0CAAE,OAAO,EACtC,WAAW,EAAE,IAAI;YAEjB,8BAAC,kBAAW,IACV,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,EACtB,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,CAAC,GACZ,CACQ;QACZ,8BAAC,WAAI,CAAC,IAAI;YACR,8BAAC,aAAM,IACL,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAC,SAAS,EACd,OAAO,EAAE,OAAO,IAEf,MAAM,CAAC,iBAAiB,CAClB,CACC,CACR,CACP,CAAC;AACJ,CAAC,CAAC;AA9NW,QAAA,cAAc,kBA8NzB;AAEF,kBAAe,sBAAc,CAAC","sourcesContent":["/* eslint-disable camelcase */\n/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport React, { useState } from 'react';\n\nimport { ReadParams, RequestParams } from 'geostyler-wfs-parser';\n\nimport {\n Form,\n Button,\n Input,\n Select,\n InputNumber\n} from 'antd';\nconst Option = Select.Option;\n\nimport './WfsParserInput.less';\nimport { GeoStylerLocale } from '../../../locale/locale';\nimport en_US from '../../../locale/en_US';\n\ntype WfsVersion = RequestParams['version'];\n\n// default props\ninterface WfsParserInputDefaultProps {\n /** Locale object containing translated text snippets */\n locale: GeoStylerLocale['WfsParserInput'];\n}\n\n// non default props\nexport interface WfsParserInputProps extends Partial<WfsParserInputDefaultProps> {\n /** The callback method that is triggered when the state changes */\n onClick: (wfsParams: ReadParams) => void;\n}\n\n/**\n * WfsParserInput\n */\nexport const WfsParserInput: React.FC<WfsParserInputProps> = ({\n locale = en_US.WfsParserInput,\n onClick: onClickProp\n}) => {\n\n const [url, setUrl] = useState<string>('https://ows-demo.terrestris.de/geoserver/terrestris/ows');\n const [version, setVersion] = useState<WfsVersion>('1.1.0');\n const [typeName, setTypeName] = useState<string>('terrestris:bundeslaender');\n const [featureID, setFeatureID] = useState<string>();\n const [propertyName, setPropertyName] = useState<string>();\n const [srsName, setSrsName] = useState<string>();\n const [maxFeatures, setMaxFeatures] = useState<number>();\n const [validation, setValidation] = useState({\n url: undefined,\n version: undefined,\n typeName: undefined,\n featureID: undefined,\n propertyName: undefined,\n maxFeatures: undefined,\n fetchParams: undefined,\n srsName: undefined\n });\n\n const onUrlChange = (event: any) => {\n const newUrl = event.target.value;\n let urlValidation = {};\n if (newUrl.length <= 0) {\n urlValidation = {\n status: 'error',\n message: 'Url is required'\n };\n }\n setUrl(newUrl);\n setValidation({\n ...validation,\n url: urlValidation\n });\n };\n\n const onTypeNameChange = (event: any) => {\n const newTypeName = event.target.value;\n let typeNameValidation = {};\n if (newTypeName.length <= 0) {\n typeNameValidation = {\n status: 'error',\n message: 'TypeName is required'\n };\n }\n setTypeName(newTypeName);\n setValidation({\n ...validation,\n typeName: typeNameValidation\n });\n };\n\n const onVersionChange = (newVersion: WfsVersion) => {\n let versionValidation = {};\n if (newVersion.length <= 0) {\n versionValidation = {\n status: 'error',\n message: 'Version is required'\n };\n }\n setVersion(newVersion);\n setValidation({\n ...validation,\n version: versionValidation\n });\n };\n\n const onFeatureIDChange = (event: any) => {\n setFeatureID(event.target.value);\n };\n\n const onSrsNameChange = (event: any) => {\n setSrsName(event.target.value);\n };\n\n const onPropertyNameChange = (newPropertyName: string) => {\n setPropertyName(newPropertyName);\n };\n\n const onMaxFeaturesChange = (newMaxFeatures: number) => {\n setMaxFeatures(newMaxFeatures);\n };\n\n const onClick = () => {\n let requestParams: RequestParams;\n if (version === '1.1.0') {\n requestParams = {\n version,\n typeName,\n maxFeatures,\n featureID,\n propertyName,\n srsName\n };\n } else {\n requestParams = {\n version,\n typeNames: typeName,\n count: maxFeatures,\n featureID,\n propertyName,\n srsName\n };\n }\n onClickProp({\n url,\n requestParams\n });\n };\n\n return (\n <div className=\"wfs-parser-input\">\n <Form.Item\n label={locale.urlLabel}\n validateStatus={validation?.url?.status}\n help={validation?.url?.message}\n hasFeedback={true}\n required={true}\n >\n <Input\n className='wfs-url-input'\n value={url}\n onChange={onUrlChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.typeNameLabel}\n validateStatus={validation?.typeName?.status}\n help={validation?.typeName?.message}\n hasFeedback={true}\n required={true}\n >\n <Input\n className='wfs-typename-input'\n value={typeName}\n onChange={onTypeNameChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.versionLabel}\n validateStatus={validation?.version?.status}\n help={validation?.version?.message}\n hasFeedback={true}\n required={true}\n >\n <Select\n className='wfs-version-input'\n style={{width: '100%'}}\n value={version}\n onChange={onVersionChange}\n >\n <Option value=\"1.1.0\">1.1.0</Option>\n <Option value=\"2.0.0\">2.0.0</Option>\n </Select>\n </Form.Item>\n <Form.Item\n label={locale.srsNameLabel}\n validateStatus={validation?.srsName?.status}\n help={validation?.srsName?.message}\n hasFeedback={true}\n >\n <Input\n className='wfs-srsName-input'\n value={srsName}\n onChange={onSrsNameChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.featureIDLabel}\n validateStatus={validation?.featureID?.status}\n help={validation?.featureID?.message}\n hasFeedback={true}\n >\n <Input\n className='wfs-featureid-input'\n value={featureID}\n onChange={onFeatureIDChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.propertyNameLabel}\n validateStatus={validation?.propertyName?.status}\n help={validation?.propertyName?.message}\n hasFeedback={true}\n >\n <Select\n className='wfs-propertyname-input'\n style={{width: '100%'}}\n mode=\"tags\"\n value={propertyName}\n onChange={onPropertyNameChange}\n />\n </Form.Item>\n <Form.Item\n label={locale.maxFeaturesLabel}\n validateStatus={validation?.maxFeatures?.status}\n help={validation?.maxFeatures?.message}\n hasFeedback={true}\n >\n <InputNumber\n className='wfs-maxfeatures-input'\n style={{width: '100%'}}\n min={0}\n value={maxFeatures}\n onChange={onMaxFeaturesChange}\n precision={0}\n />\n </Form.Item>\n <Form.Item>\n <Button\n className=\"wfs-parser-submit-button\"\n type=\"primary\"\n onClick={onClick}\n >\n {locale.requestButtonText}\n </Button>\n </Form.Item>\n </div>\n );\n};\n\nexport default WfsParserInput;\n"]}
|
|
@@ -196,7 +196,7 @@ var ComparisonFilter = function (_a) {
|
|
|
196
196
|
if (filter) {
|
|
197
197
|
val = filter[filterIndex];
|
|
198
198
|
}
|
|
199
|
-
return React.createElement(NumberFilterField_1.default, { size: size, value: val, onValueChange: onValueChange, validateStatus: validateStatus.value, help: valueValidationHelpString });
|
|
199
|
+
return React.createElement(NumberFilterField_1.default, { size: size, value: val, onValueChange: function (newValue) { return onValueChange(newValue, filterIndex); }, validateStatus: validateStatus.value, help: valueValidationHelpString });
|
|
200
200
|
}
|
|
201
201
|
function getTextField(filterIndex) {
|
|
202
202
|
if (filterIndex === void 0) { filterIndex = 2; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComparisonFilter.js","sourceRoot":"","sources":["../../../../src/Component/Filter/ComparisonFilter/ComparisonFilter.tsx"],"names":[],"mappings":";AAAA,uDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA+B;AAE/B,oFAA8D;AAC9D,iFAA2D;AAC3D,uFAAiE;AACjE,6FAAuE;AAQvE,mCAAiC;AACjC,uFAAiE;AAMjE,mDAA8B;AAC9B,+DAA0C;AAC1C,2DAAsC;AACtC,6DAAwC;AAuDjC,IAAM,gCAAgC,GAAG,UAC9C,QAAsB,EACtB,eAAqB,EACrB,iBAAyB;IAGzB,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,0BAA0B;IAC1B,IAAM,QAAQ,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,WAAQ,CAAC,CAAC;IAEvF,QAAQ,QAAQ,EAAE;QAChB,KAAK,QAAQ;YACX,+BAA+B;YAC/B,IAAM,MAAM,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,cAAW,CAAC,CAAC;YACxF,IAAM,MAAM,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,cAAW,CAAC,CAAC;YAExF,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MA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AAA,gBAAgB,oBA6N3B;AAEF,kBAAe,wBAAgB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport * as React from 'react';\n\nimport AttributeCombo from '../AttributeCombo/AttributeCombo';\nimport OperatorCombo from '../OperatorCombo/OperatorCombo';\nimport TextFilterField from '../TextFilterField/TextFilterField';\nimport NumberFilterField from '../NumberFilterField/NumberFilterField';\n\nimport {\n ComparisonFilter as GsComparisonFilter,\n ComparisonOperator,\n PropertyType\n} from 'geostyler-style';\n\nimport './ComparisonFilter.less';\nimport BoolFilterField from '../BoolFilterField/BoolFilterField';\n\nimport {\n Data as Data\n} from 'geostyler-data';\n\nimport _get from 'lodash/get';\nimport _cloneDeep from 'lodash/cloneDeep';\nimport _isEmpty from 'lodash/isEmpty';\nimport _isString from 'lodash/isString';\n\ntype ValidationResult = {\n isValid: boolean;\n errorMsg: string;\n};\n\ninterface Validators {\n attribute: (attrName: string) => boolean;\n operator: (operator: string) => boolean;\n value: (value: PropertyType, internalDataDef?: Data, selectedAttribute?: string)\n => ValidationResult;\n}\n\n// default props\nexport interface ComparisonFilterProps {\n /** Initial comparison filter object */\n filter?: GsComparisonFilter;\n /** Set true to hide the attribute's type in the AttributeCombo select options */\n hideAttributeType?: boolean;\n /**\n * A custom filter function which is passed each attribute.\n * Should return true to accept each attribute or false to reject it.\n */\n attributeNameFilter?: (attributeName: string) => boolean;\n /** Mapping function for attribute names of underlying AttributeCombo */\n attributeNameMappingFunction?: (originalAttributeName: string) => string;\n /** Label for the underlying OperatorCombo */\n operatorLabel?: string;\n /** Show title of selected item in underlying OperatorCombo */\n showOperatorTitles?: boolean;\n /** Placeholder for the underlying OperatorCombo */\n operatorPlaceholderString?: string;\n /** Validation help text for the underlying OperatorCombo */\n operatorValidationHelpString?: string;\n /** Mapping function for operator names of underlying OperatorCombo */\n operatorNameMappingFunction?: (originalOperatorName: string) => string;\n /** Mapping function for operator title in underlying OperatorCombo */\n operatorTitleMappingFunction?: (originalOperatorName: string) => string;\n /** Object aggregating validation functions for attribute, operator and value */\n validators?: Validators;\n /** Show ui in micro mode. Which disables labels etc. */\n microUI?: boolean;\n /** Reference to internal data object (holding schema and example features) */\n internalDataDef?: Data;\n /** Callback function for onFilterChange */\n onFilterChange?: ((compFilter: GsComparisonFilter) => void);\n}\n\ninterface ValidationStatus {\n attribute: 'success' | 'warning' | 'error' | 'validating';\n operator: 'success' | 'warning' | 'error' | 'validating';\n value: 'success' | 'warning' | 'error' | 'validating';\n}\n\nexport const ComparisonFilterDefaultValidator = (\n newValue: PropertyType,\n internalDataDef: Data,\n selectedAttribute: string\n): ValidationResult => {\n\n let isValid = true;\n let errorMsg = '';\n // read out attribute type\n const attrType = _get(internalDataDef, `schema.properties[${selectedAttribute}].type`);\n\n switch (attrType) {\n case 'number':\n // detect min / max from schema\n const minVal = _get(internalDataDef, `schema.properties[${selectedAttribute}].minimum`);\n const maxVal = _get(internalDataDef, `schema.properties[${selectedAttribute}].maximum`);\n\n if (!isNaN(minVal) && !isNaN(maxVal)) {\n if (typeof newValue !== 'number') {\n isValid = false;\n errorMsg = 'Please enter a number';\n } else if (newValue < minVal) {\n isValid = false;\n errorMsg = 'Minimum Value is ' + minVal;\n } else if (newValue > maxVal) {\n isValid = false;\n errorMsg = 'Maximum Value is ' + maxVal;\n }\n }\n break;\n default:\n break;\n }\n\n return {\n isValid: isValid,\n errorMsg: errorMsg\n };\n};\n\nconst operatorsMap = {\n 'string': ['==', '*=', '!='],\n 'number': ['==', '!=', '<', '<=', '>', '>=', '<=x<='],\n 'boolean': ['==', '!=']\n};\n\n/**\n * UI for a ComparisonFilter consisting of\n *\n * - A combo to select the attribute\n * - A combo to select the operator\n * - An input field for the value\n */\nexport const ComparisonFilter: React.FC<ComparisonFilterProps> = ({\n attributeNameFilter = () => true,\n attributeNameMappingFunction = n => n,\n filter = ['==', '', null],\n hideAttributeType = false,\n internalDataDef,\n microUI = false,\n onFilterChange,\n operatorLabel,\n operatorNameMappingFunction = n => n,\n operatorPlaceholderString,\n operatorTitleMappingFunction = t => t,\n operatorValidationHelpString,\n showOperatorTitles = true,\n validators = {\n attribute: attributeName => !_isEmpty(attributeName),\n operator: operatorName => !_isEmpty(operatorName),\n value: ComparisonFilterDefaultValidator\n }\n}) => {\n\n /**\n * Handler function, which is executed, when to underlying filter attribute changes.\n *\n * Changes the input field for the filter value and stores the appropriate attribute name as member.\n */\n const onAttributeChange = (newAttrName: string) => {\n let newFilter = _cloneDeep(filter);\n newFilter[1] = newAttrName;\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n /**\n * Handler function, which is executed, when to underlying filter operator changes.\n *\n * Stores the appropriate operator as member.\n */\n const onOperatorChange = (newOperator: ComparisonOperator) => {\n let newFilter = _cloneDeep(filter);\n newFilter[0] = newOperator;\n if (newOperator !== '<=x<=' && newFilter.length > 3) {\n newFilter.splice(3, 1);\n }\n if (newOperator === '<=x<=' && !newFilter[3]) {\n newFilter[3] = 0;\n }\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n /**\n * Handler function, which is executed, when to underlying filter value changes.\n *\n * Stores the appropriate filter value as member.\n */\n const onValueChange = (newValue: string | number | boolean, filterIndex = 2) => {\n let newFilter = _cloneDeep(filter);\n newFilter[filterIndex] = newValue;\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n // TODO: implement strategy to handle FunctionFilter\n const attribute = _isString(filter[1]) ? filter[1] : undefined;\n const attributeType = attribute ? internalDataDef?.schema?.properties[attribute]?.type : undefined;\n const operator = filter[0];\n const value = filter[2];\n const valueValidation = validators.value(value, internalDataDef, attribute);\n const valueValidationHelpString = valueValidation.errorMsg;\n const allowedOperators = attributeType ? operatorsMap[attributeType] : undefined;\n const isNumberBetweenComparison = operator === '<=x<=';\n const isNumberComparison = attributeType === 'number';\n const isBooleanComparison = attributeType === 'boolean';\n const isTextComparison = !isNumberBetweenComparison && !isNumberComparison && !isBooleanComparison;\n const hasFilter = filter && Array.isArray(filter);\n\n const validateStatus: ValidationStatus = {\n attribute: hasFilter && validators.attribute(attribute) ? 'success' : 'error',\n operator: hasFilter && validators.operator(operator) ? 'success' : 'error',\n value: hasFilter && valueValidation.isValid ? 'success' : 'error'\n };\n\n function getAttributeCombo(filterIndex = 1) {\n const size = microUI ? 'small' : undefined;\n let val: string;\n if (filter) {\n val = filter[filterIndex] as string;\n }\n return <AttributeCombo\n size={size}\n value={val}\n internalDataDef={internalDataDef}\n onAttributeChange={onAttributeChange}\n attributeNameFilter={attributeNameFilter}\n attributeNameMappingFunction={attributeNameMappingFunction}\n validateStatus={validateStatus.attribute}\n hideAttributeType={hideAttributeType}\n />;\n }\n\n function getNumberField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: number;\n if (filter) {\n val = filter[filterIndex] as number;\n }\n return <NumberFilterField\n size={size}\n value={val}\n onValueChange={onValueChange}\n validateStatus={validateStatus.value}\n help={valueValidationHelpString}\n />;\n }\n\n function getTextField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: string;\n if (filter) {\n val = filter[filterIndex] as string;\n }\n return <TextFilterField\n size={size}\n value={val}\n internalDataDef={internalDataDef}\n selectedAttribute={attribute}\n onValueChange={onValueChange}\n validateStatus={validateStatus.value}\n help={valueValidationHelpString}\n />;\n }\n\n function getOperatorCombo(filterIndex = 0) {\n const size = microUI ? 'small' : undefined;\n let val: ComparisonOperator;\n if (filter) {\n val = filter[filterIndex] as ComparisonOperator;\n }\n return <OperatorCombo\n size={size}\n value={val}\n onOperatorChange={onOperatorChange}\n operators={allowedOperators}\n operatorNameMappingFunction={operatorNameMappingFunction}\n placeholder={operatorPlaceholderString}\n label={operatorLabel}\n validateStatus={validateStatus.operator}\n help={operatorValidationHelpString}\n operatorTitleMappingFunction={operatorTitleMappingFunction}\n showTitles={showOperatorTitles}\n />;\n }\n\n function getBooleanField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: boolean;\n if (filter) {\n val = filter[filterIndex] as boolean;\n }\n return <BoolFilterField\n size={size}\n value={val}\n onValueChange={onValueChange}\n />;\n }\n\n let className = 'gs-comparison-filter-ui';\n if (microUI) {\n className += ' micro';\n }\n\n if (isNumberBetweenComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getNumberField(2)}\n {getOperatorCombo()}\n {getNumberField(3)}\n </div>\n );\n }\n\n if (isNumberComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getNumberField()}\n </div>\n );\n }\n\n if (isBooleanComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getBooleanField()}\n </div>\n );\n }\n\n if (isTextComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getTextField()}\n </div>\n );\n }\n\n return (\n <div className={className}>\n Could not create ComparisonFilter.\n </div>\n );\n};\n\nexport default ComparisonFilter;\n"]}
|
|
1
|
+
{"version":3,"file":"ComparisonFilter.js","sourceRoot":"","sources":["../../../../src/Component/Filter/ComparisonFilter/ComparisonFilter.tsx"],"names":[],"mappings":";AAAA,uDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA+B;AAE/B,oFAA8D;AAC9D,iFAA2D;AAC3D,uFAAiE;AACjE,6FAAuE;AAQvE,mCAAiC;AACjC,uFAAiE;AAMjE,mDAA8B;AAC9B,+DAA0C;AAC1C,2DAAsC;AACtC,6DAAwC;AAuDjC,IAAM,gCAAgC,GAAG,UAC9C,QAAsB,EACtB,eAAqB,EACrB,iBAAyB;IAGzB,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,0BAA0B;IAC1B,IAAM,QAAQ,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,WAAQ,CAAC,CAAC;IAEvF,QAAQ,QAAQ,EAAE;QAChB,KAAK,QAAQ;YACX,+BAA+B;YAC/B,IAAM,MAAM,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,cAAW,CAAC,CAAC;YACxF,IAAM,MAAM,GAAG,IAAA,aAAI,EAAC,eAAe,EAAE,4BAAqB,iBAAiB,cAAW,CAAC,CAAC;YAExF,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBACpC,IAAI,O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,CACP,CAAC;AACJ,CAAC,CAAC;AA7NW,QAAA,gBAAgB,oBA6N3B;AAEF,kBAAe,wBAAgB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport * as React from 'react';\n\nimport AttributeCombo from '../AttributeCombo/AttributeCombo';\nimport OperatorCombo from '../OperatorCombo/OperatorCombo';\nimport TextFilterField from '../TextFilterField/TextFilterField';\nimport NumberFilterField from '../NumberFilterField/NumberFilterField';\n\nimport {\n ComparisonFilter as GsComparisonFilter,\n ComparisonOperator,\n PropertyType\n} from 'geostyler-style';\n\nimport './ComparisonFilter.less';\nimport BoolFilterField from '../BoolFilterField/BoolFilterField';\n\nimport {\n Data as Data\n} from 'geostyler-data';\n\nimport _get from 'lodash/get';\nimport _cloneDeep from 'lodash/cloneDeep';\nimport _isEmpty from 'lodash/isEmpty';\nimport _isString from 'lodash/isString';\n\ntype ValidationResult = {\n isValid: boolean;\n errorMsg: string;\n};\n\ninterface Validators {\n attribute: (attrName: string) => boolean;\n operator: (operator: string) => boolean;\n value: (value: PropertyType, internalDataDef?: Data, selectedAttribute?: string)\n => ValidationResult;\n}\n\n// default props\nexport interface ComparisonFilterProps {\n /** Initial comparison filter object */\n filter?: GsComparisonFilter;\n /** Set true to hide the attribute's type in the AttributeCombo select options */\n hideAttributeType?: boolean;\n /**\n * A custom filter function which is passed each attribute.\n * Should return true to accept each attribute or false to reject it.\n */\n attributeNameFilter?: (attributeName: string) => boolean;\n /** Mapping function for attribute names of underlying AttributeCombo */\n attributeNameMappingFunction?: (originalAttributeName: string) => string;\n /** Label for the underlying OperatorCombo */\n operatorLabel?: string;\n /** Show title of selected item in underlying OperatorCombo */\n showOperatorTitles?: boolean;\n /** Placeholder for the underlying OperatorCombo */\n operatorPlaceholderString?: string;\n /** Validation help text for the underlying OperatorCombo */\n operatorValidationHelpString?: string;\n /** Mapping function for operator names of underlying OperatorCombo */\n operatorNameMappingFunction?: (originalOperatorName: string) => string;\n /** Mapping function for operator title in underlying OperatorCombo */\n operatorTitleMappingFunction?: (originalOperatorName: string) => string;\n /** Object aggregating validation functions for attribute, operator and value */\n validators?: Validators;\n /** Show ui in micro mode. Which disables labels etc. */\n microUI?: boolean;\n /** Reference to internal data object (holding schema and example features) */\n internalDataDef?: Data;\n /** Callback function for onFilterChange */\n onFilterChange?: ((compFilter: GsComparisonFilter) => void);\n}\n\ninterface ValidationStatus {\n attribute: 'success' | 'warning' | 'error' | 'validating';\n operator: 'success' | 'warning' | 'error' | 'validating';\n value: 'success' | 'warning' | 'error' | 'validating';\n}\n\nexport const ComparisonFilterDefaultValidator = (\n newValue: PropertyType,\n internalDataDef: Data,\n selectedAttribute: string\n): ValidationResult => {\n\n let isValid = true;\n let errorMsg = '';\n // read out attribute type\n const attrType = _get(internalDataDef, `schema.properties[${selectedAttribute}].type`);\n\n switch (attrType) {\n case 'number':\n // detect min / max from schema\n const minVal = _get(internalDataDef, `schema.properties[${selectedAttribute}].minimum`);\n const maxVal = _get(internalDataDef, `schema.properties[${selectedAttribute}].maximum`);\n\n if (!isNaN(minVal) && !isNaN(maxVal)) {\n if (typeof newValue !== 'number') {\n isValid = false;\n errorMsg = 'Please enter a number';\n } else if (newValue < minVal) {\n isValid = false;\n errorMsg = 'Minimum Value is ' + minVal;\n } else if (newValue > maxVal) {\n isValid = false;\n errorMsg = 'Maximum Value is ' + maxVal;\n }\n }\n break;\n default:\n break;\n }\n\n return {\n isValid: isValid,\n errorMsg: errorMsg\n };\n};\n\nconst operatorsMap = {\n 'string': ['==', '*=', '!='],\n 'number': ['==', '!=', '<', '<=', '>', '>=', '<=x<='],\n 'boolean': ['==', '!=']\n};\n\n/**\n * UI for a ComparisonFilter consisting of\n *\n * - A combo to select the attribute\n * - A combo to select the operator\n * - An input field for the value\n */\nexport const ComparisonFilter: React.FC<ComparisonFilterProps> = ({\n attributeNameFilter = () => true,\n attributeNameMappingFunction = n => n,\n filter = ['==', '', null],\n hideAttributeType = false,\n internalDataDef,\n microUI = false,\n onFilterChange,\n operatorLabel,\n operatorNameMappingFunction = n => n,\n operatorPlaceholderString,\n operatorTitleMappingFunction = t => t,\n operatorValidationHelpString,\n showOperatorTitles = true,\n validators = {\n attribute: attributeName => !_isEmpty(attributeName),\n operator: operatorName => !_isEmpty(operatorName),\n value: ComparisonFilterDefaultValidator\n }\n}) => {\n\n /**\n * Handler function, which is executed, when to underlying filter attribute changes.\n *\n * Changes the input field for the filter value and stores the appropriate attribute name as member.\n */\n const onAttributeChange = (newAttrName: string) => {\n let newFilter = _cloneDeep(filter);\n newFilter[1] = newAttrName;\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n /**\n * Handler function, which is executed, when to underlying filter operator changes.\n *\n * Stores the appropriate operator as member.\n */\n const onOperatorChange = (newOperator: ComparisonOperator) => {\n let newFilter = _cloneDeep(filter);\n newFilter[0] = newOperator;\n if (newOperator !== '<=x<=' && newFilter.length > 3) {\n newFilter.splice(3, 1);\n }\n if (newOperator === '<=x<=' && !newFilter[3]) {\n newFilter[3] = 0;\n }\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n /**\n * Handler function, which is executed, when to underlying filter value changes.\n *\n * Stores the appropriate filter value as member.\n */\n const onValueChange = (newValue: string | number | boolean, filterIndex = 2) => {\n let newFilter = _cloneDeep(filter);\n newFilter[filterIndex] = newValue;\n if (onFilterChange) {\n onFilterChange(newFilter);\n }\n };\n\n // TODO: implement strategy to handle FunctionFilter\n const attribute = _isString(filter[1]) ? filter[1] : undefined;\n const attributeType = attribute ? internalDataDef?.schema?.properties[attribute]?.type : undefined;\n const operator = filter[0];\n const value = filter[2];\n const valueValidation = validators.value(value, internalDataDef, attribute);\n const valueValidationHelpString = valueValidation.errorMsg;\n const allowedOperators = attributeType ? operatorsMap[attributeType] : undefined;\n const isNumberBetweenComparison = operator === '<=x<=';\n const isNumberComparison = attributeType === 'number';\n const isBooleanComparison = attributeType === 'boolean';\n const isTextComparison = !isNumberBetweenComparison && !isNumberComparison && !isBooleanComparison;\n const hasFilter = filter && Array.isArray(filter);\n\n const validateStatus: ValidationStatus = {\n attribute: hasFilter && validators.attribute(attribute) ? 'success' : 'error',\n operator: hasFilter && validators.operator(operator) ? 'success' : 'error',\n value: hasFilter && valueValidation.isValid ? 'success' : 'error'\n };\n\n function getAttributeCombo(filterIndex = 1) {\n const size = microUI ? 'small' : undefined;\n let val: string;\n if (filter) {\n val = filter[filterIndex] as string;\n }\n return <AttributeCombo\n size={size}\n value={val}\n internalDataDef={internalDataDef}\n onAttributeChange={onAttributeChange}\n attributeNameFilter={attributeNameFilter}\n attributeNameMappingFunction={attributeNameMappingFunction}\n validateStatus={validateStatus.attribute}\n hideAttributeType={hideAttributeType}\n />;\n }\n\n function getNumberField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: number;\n if (filter) {\n val = filter[filterIndex] as number;\n }\n return <NumberFilterField\n size={size}\n value={val}\n onValueChange={(newValue) => onValueChange(newValue, filterIndex)}\n validateStatus={validateStatus.value}\n help={valueValidationHelpString}\n />;\n }\n\n function getTextField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: string;\n if (filter) {\n val = filter[filterIndex] as string;\n }\n return <TextFilterField\n size={size}\n value={val}\n internalDataDef={internalDataDef}\n selectedAttribute={attribute}\n onValueChange={onValueChange}\n validateStatus={validateStatus.value}\n help={valueValidationHelpString}\n />;\n }\n\n function getOperatorCombo(filterIndex = 0) {\n const size = microUI ? 'small' : undefined;\n let val: ComparisonOperator;\n if (filter) {\n val = filter[filterIndex] as ComparisonOperator;\n }\n return <OperatorCombo\n size={size}\n value={val}\n onOperatorChange={onOperatorChange}\n operators={allowedOperators}\n operatorNameMappingFunction={operatorNameMappingFunction}\n placeholder={operatorPlaceholderString}\n label={operatorLabel}\n validateStatus={validateStatus.operator}\n help={operatorValidationHelpString}\n operatorTitleMappingFunction={operatorTitleMappingFunction}\n showTitles={showOperatorTitles}\n />;\n }\n\n function getBooleanField(filterIndex = 2) {\n const size = microUI ? 'small' : undefined;\n let val: boolean;\n if (filter) {\n val = filter[filterIndex] as boolean;\n }\n return <BoolFilterField\n size={size}\n value={val}\n onValueChange={onValueChange}\n />;\n }\n\n let className = 'gs-comparison-filter-ui';\n if (microUI) {\n className += ' micro';\n }\n\n if (isNumberBetweenComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getNumberField(2)}\n {getOperatorCombo()}\n {getNumberField(3)}\n </div>\n );\n }\n\n if (isNumberComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getNumberField()}\n </div>\n );\n }\n\n if (isBooleanComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getBooleanField()}\n </div>\n );\n }\n\n if (isTextComparison) {\n return (\n <div className={className}>\n {getAttributeCombo()}\n {getOperatorCombo()}\n {getTextField()}\n </div>\n );\n }\n\n return (\n <div className={className}>\n Could not create ComparisonFilter.\n </div>\n );\n};\n\nexport default ComparisonFilter;\n"]}
|
|
@@ -62,6 +62,7 @@ var GeoJSON_1 = __importDefault(require("ol/format/GeoJSON"));
|
|
|
62
62
|
var Feature_1 = __importDefault(require("ol/Feature"));
|
|
63
63
|
var Tile_1 = __importDefault(require("ol/layer/Tile"));
|
|
64
64
|
var OSM_1 = __importDefault(require("ol/source/OSM"));
|
|
65
|
+
var extent_1 = require("ol/extent");
|
|
65
66
|
var geostyler_openlayers_parser_1 = __importDefault(require("geostyler-openlayers-parser"));
|
|
66
67
|
var GeometryUtil_1 = __importDefault(require("../../Util/GeometryUtil"));
|
|
67
68
|
require("./PreviewMap.css");
|
|
@@ -92,9 +93,10 @@ var PreviewMap = function (_a) {
|
|
|
92
93
|
var zoomToData = function () {
|
|
93
94
|
var map = mapRef.current;
|
|
94
95
|
var dataLayer = dataLayerRef.current;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
var extent = dataLayer.getSource().getExtent();
|
|
97
|
+
if (extent && !(0, extent_1.isEmpty)(extent)) {
|
|
98
|
+
map.getView().fit(extent, { maxZoom: 10 });
|
|
99
|
+
}
|
|
98
100
|
};
|
|
99
101
|
/**
|
|
100
102
|
* Add the dataLayer to the map.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewMap.js","sourceRoot":"","sources":["../../../src/Component/PreviewMap/PreviewMap.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;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M,CAAC,OAAO,CAAC,CAAC;aAC/B;SACF;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,uCACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,8BAA8B,EACxC,EAAE,EAAE,cAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAE,EACtD,KAAK,EAAE;YACL,MAAM,EAAE,SAAS;SAClB,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AA/IW,QAAA,UAAU,cA+IrB;AAEF,kBAAe,kBAAU,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport React, { useEffect, useRef } from 'react';\n\nimport OlMap from 'ol/Map';\nimport OlLayerVector from 'ol/layer/Vector';\nimport OlSourceVector from 'ol/source/Vector';\nimport OlFormatGeoJSON from 'ol/format/GeoJSON';\nimport { ProjectionLike } from 'ol/proj';\nimport OlFeature from 'ol/Feature';\nimport OlLayerTile from 'ol/layer/Tile';\nimport OlSourceOSM from 'ol/source/OSM';\n\nimport { Style } from 'geostyler-style';\nimport { Data, VectorData } from 'geostyler-data';\nimport OlStyleParser from 'geostyler-openlayers-parser';\n\nimport GeometryUtil from '../../Util/GeometryUtil';\n\nimport './PreviewMap.less';\nimport { StandardLonghandProperties } from 'csstype';\n\n// default props\nexport interface PreviewMapDefaultProps {\n /** The projection of the data to visualize */\n dataProjection: ProjectionLike;\n /** The height of the map */\n mapHeight: StandardLonghandProperties['height'];\n}\n\n// non default props\nexport interface PreviewMapProps extends Partial<PreviewMapDefaultProps> {\n /** The data to visualize */\n data?: Data;\n /** The GeoStyler Style to preview */\n style: Style;\n /** A custom map used for rendering */\n map?: OlMap;\n /** A list of layers to add to the map */\n onMapDidMount?: (map: OlMap) => void;\n}\n\n/**\n * Style preview UI.\n */\nexport const PreviewMap: React.FC<PreviewMapProps> = ({\n dataProjection = 'EPSG:4326',\n mapHeight = 267,\n data,\n style,\n map: mapProp,\n onMapDidMount\n}) => {\n\n const containerRef = useRef();\n\n /** the vector layer for the passed features */\n const dataLayerRef = useRef<OlLayerVector<any>>(new OlLayerVector({\n source: new OlSourceVector()\n }));\n\n /** the underlying OpenLayers map */\n const mapRef = useRef<OlMap>(\n mapProp ||\n new OlMap({\n controls: [],\n layers: [\n new OlLayerTile({\n source: new OlSourceOSM()\n }),\n dataLayerRef.current\n ]\n })\n );\n\n /**\n * Fits the preview extend to the data when the dataLayer changes.\n */\n const zoomToData = () => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n map.getView().fit(\n dataLayer.getSource().getExtent(),\n {\n maxZoom: 10\n }\n );\n };\n\n /**\n * Add the dataLayer to the map.\n */\n const addDataLayer = () => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (!map.getAllLayers().some(layer => layer === dataLayer)) {\n map.addLayer(dataLayer);\n }\n };\n\n /**\n * Add the containing exampleFeatures if the passed data changes.\n */\n useEffect(() => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (dataLayer && (data as VectorData)?.exampleFeatures && map) {\n dataLayer.getSource().clear();\n const format = new OlFormatGeoJSON({\n dataProjection: dataProjection,\n featureProjection: map.getView().getProjection()\n });\n const olFeatures = format.readFeatures((data as VectorData).exampleFeatures);\n dataLayer.getSource().addFeatures(olFeatures);\n zoomToData();\n }\n }, [data, dataProjection]);\n\n /**\n * Update the layerStyle if the passed style changes.\n */\n useEffect(() => {\n const dataLayer = dataLayerRef.current;\n const styleParser = new OlStyleParser();\n styleParser.writeStyle(style)\n .then(({ output: olStyles}) => {\n dataLayer.setStyle(olStyles);\n });\n }, [style]);\n\n /**\n * If no data is provided create sample geometries based on the passed style.\n */\n useEffect(() => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (!data && dataLayer && map && style) {\n const geoms = GeometryUtil.getSampleGeomFromStyle(style, map.getView().getProjection());\n geoms.forEach((geometry: any) => {\n const feature = new OlFeature({geometry});\n dataLayer.getSource().addFeature(feature);\n });\n zoomToData();\n }\n }, [style, data]);\n\n // Set the map if a mapProp is passed\n useEffect(() => {\n if (mapProp) {\n // use passed in OL map and bind it to this preview DIV\n mapRef.current = mapProp;\n }\n }, [mapProp]);\n\n /**\n * Set the target of the map if the ref is defined.\n */\n useEffect(() => {\n const map = mapRef.current;\n if (containerRef) {\n map.setTarget(containerRef.current);\n map.updateSize();\n addDataLayer();\n zoomToData();\n }\n }, []);\n\n /**\n * Call the `onMapDidMount` callback if defined.\n */\n useEffect(() => {\n if (containerRef) {\n if (onMapDidMount) {\n onMapDidMount(mapRef.current);\n }\n }\n }, [onMapDidMount]);\n\n return (\n <div\n ref={containerRef}\n className=\"gs-symbolizer-previewmap map\"\n id={`map_${Math.floor((1 + Math.random()) * 0x10000)}`}\n style={{\n height: mapHeight\n }}\n />\n );\n};\n\nexport default PreviewMap;\n"]}
|
|
1
|
+
{"version":3,"file":"PreviewMap.js","sourceRoot":"","sources":["../../../src/Component/PreviewMap/PreviewMap.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAAiD;AAEjD,+CAA2B;AAC3B,2DAA4C;AAC5C,4DAA8C;AAC9C,8DAAgD;AAEhD,uDAAmC;AACnC,uDAAwC;AACxC,sDAAwC;AACxC,oCAAoC;AAIpC,4FAAwD;AAExD,yEAAmD;AAEnD,6BAA2B;AAuB3B;;GAEG;AACI,IAAM,UAAU,GAA8B,UAAC,EAOrD;QANC,sBAA4B,EAA5B,cAAc,mBAAG,WAAW,KAAA,EAC5B,iBAAe,EAAf,SAAS,mBAAG,GAAG,KAAA,EACf,IAAI,UAAA,EACJ,KAAK,WAAA,EACA,OAAO,SAAA,EACZ,aAAa,mBAAA;IAGb,IAAM,YAAY,GAAG,IAAA,cAAM,GAAE,CAAC;IAE9B,+CAA+C;IAC/C,IAAM,YAAY,GAAG,IAAA,cAAM,EAAqB,IAAI,gBAAa,CAAC;QAChE,MAAM,EAAE,IAAI,gBAAc,EAAE;KAC7B,CAAC,CAAC,CAAC;IAEJ,oCAAoC;IACpC,IAAM,MAAM,GAAG,IAAA,cAAM,EACnB,OAAO;QACP,IAAI,aAAK,CAAC;YACR,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE;gBACN,IAAI,cAAW,CAAC;oBACd,MAAM,EAAE,IAAI,aAAW,EAAE;iBAC1B,CAAC;gBACF,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,EAAC;QACR,IAAI,OAAO,EAAE;YACX,uDAAuD;YACvD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;SAC1B;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd;;OAEG;IACH,IAAA,iBAAS,EAAC;QACR,IAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;QAC3B,IAAI,YAAY,EAAE;YAChB,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACpC,GAAG,CAAC,UAAU,EAAE,CAAC;YACjB,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;OAEG;IACH,IAAA,iBAAS,EAAC;QACR,IAAI,YAAY,EAAE;YAChB,IAAI,aAAa,EAAE;gBACjB,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aAC/B;SACF;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,uCACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,8BAA8B,EACxC,EAAE,EAAE,cAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAE,EACtD,KAAK,EAAE;YACL,MAAM,EAAE,SAAS;SAClB,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AA7IW,QAAA,UAAU,cA6IrB;AAEF,kBAAe,kBAAU,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport React, { useEffect, useRef } from 'react';\n\nimport OlMap from 'ol/Map';\nimport OlLayerVector from 'ol/layer/Vector';\nimport OlSourceVector from 'ol/source/Vector';\nimport OlFormatGeoJSON from 'ol/format/GeoJSON';\nimport { ProjectionLike } from 'ol/proj';\nimport OlFeature from 'ol/Feature';\nimport OlLayerTile from 'ol/layer/Tile';\nimport OlSourceOSM from 'ol/source/OSM';\nimport { isEmpty } from 'ol/extent';\n\nimport { Style } from 'geostyler-style';\nimport { Data, VectorData } from 'geostyler-data';\nimport OlStyleParser from 'geostyler-openlayers-parser';\n\nimport GeometryUtil from '../../Util/GeometryUtil';\n\nimport './PreviewMap.less';\nimport { StandardLonghandProperties } from 'csstype';\n\n// default props\nexport interface PreviewMapDefaultProps {\n /** The projection of the data to visualize */\n dataProjection: ProjectionLike;\n /** The height of the map */\n mapHeight: StandardLonghandProperties['height'];\n}\n\n// non default props\nexport interface PreviewMapProps extends Partial<PreviewMapDefaultProps> {\n /** The data to visualize */\n data?: Data;\n /** The GeoStyler Style to preview */\n style: Style;\n /** A custom map used for rendering */\n map?: OlMap;\n /** A list of layers to add to the map */\n onMapDidMount?: (map: OlMap) => void;\n}\n\n/**\n * Style preview UI.\n */\nexport const PreviewMap: React.FC<PreviewMapProps> = ({\n dataProjection = 'EPSG:4326',\n mapHeight = 267,\n data,\n style,\n map: mapProp,\n onMapDidMount\n}) => {\n\n const containerRef = useRef();\n\n /** the vector layer for the passed features */\n const dataLayerRef = useRef<OlLayerVector<any>>(new OlLayerVector({\n source: new OlSourceVector()\n }));\n\n /** the underlying OpenLayers map */\n const mapRef = useRef<OlMap>(\n mapProp ||\n new OlMap({\n controls: [],\n layers: [\n new OlLayerTile({\n source: new OlSourceOSM()\n }),\n dataLayerRef.current\n ]\n })\n );\n\n /**\n * Fits the preview extend to the data when the dataLayer changes.\n */\n const zoomToData = () => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n const extent = dataLayer.getSource().getExtent();\n if (extent && !isEmpty(extent)) {\n map.getView().fit(extent, { maxZoom: 10 });\n }\n };\n\n /**\n * Add the dataLayer to the map.\n */\n const addDataLayer = () => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (!map.getAllLayers().some(layer => layer === dataLayer)) {\n map.addLayer(dataLayer);\n }\n };\n\n /**\n * Add the containing exampleFeatures if the passed data changes.\n */\n useEffect(() => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (dataLayer && (data as VectorData)?.exampleFeatures && map) {\n dataLayer.getSource().clear();\n const format = new OlFormatGeoJSON({\n dataProjection: dataProjection,\n featureProjection: map.getView().getProjection()\n });\n const olFeatures = format.readFeatures((data as VectorData).exampleFeatures);\n dataLayer.getSource().addFeatures(olFeatures);\n zoomToData();\n }\n }, [data, dataProjection]);\n\n /**\n * Update the layerStyle if the passed style changes.\n */\n useEffect(() => {\n const dataLayer = dataLayerRef.current;\n const styleParser = new OlStyleParser();\n styleParser.writeStyle(style)\n .then(({ output: olStyles}) => {\n dataLayer.setStyle(olStyles);\n });\n }, [style]);\n\n /**\n * If no data is provided create sample geometries based on the passed style.\n */\n useEffect(() => {\n const map = mapRef.current;\n const dataLayer = dataLayerRef.current;\n if (!data && dataLayer && map && style) {\n const geoms = GeometryUtil.getSampleGeomFromStyle(style, map.getView().getProjection());\n geoms.forEach((geometry: any) => {\n const feature = new OlFeature({geometry});\n dataLayer.getSource().addFeature(feature);\n });\n zoomToData();\n }\n }, [style, data]);\n\n // Set the map if a mapProp is passed\n useEffect(() => {\n if (mapProp) {\n // use passed in OL map and bind it to this preview DIV\n mapRef.current = mapProp;\n }\n }, [mapProp]);\n\n /**\n * Set the target of the map if the ref is defined.\n */\n useEffect(() => {\n const map = mapRef.current;\n if (containerRef) {\n map.setTarget(containerRef.current);\n map.updateSize();\n addDataLayer();\n zoomToData();\n }\n }, []);\n\n /**\n * Call the `onMapDidMount` callback if defined.\n */\n useEffect(() => {\n if (containerRef) {\n if (onMapDidMount) {\n onMapDidMount(mapRef.current);\n }\n }\n }, [onMapDidMount]);\n\n return (\n <div\n ref={containerRef}\n className=\"gs-symbolizer-previewmap map\"\n id={`map_${Math.floor((1 + Math.random()) * 0x10000)}`}\n style={{\n height: mapHeight\n }}\n />\n );\n};\n\nexport default PreviewMap;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { UploadProps } from 'antd';
|
|
3
3
|
import { GeoStylerLocale } from '../../locale/locale';
|
|
4
4
|
export interface CustomRequest {
|
|
@@ -17,7 +17,7 @@ export interface CustomRequest {
|
|
|
17
17
|
interface UploadButtonDefaultProps {
|
|
18
18
|
locale?: GeoStylerLocale['UploadButton'];
|
|
19
19
|
}
|
|
20
|
-
export declare type UploadButtonProps = UploadButtonDefaultProps & UploadProps<any>;
|
|
20
|
+
export declare type UploadButtonProps = UploadButtonDefaultProps & Omit<UploadProps<any>, 'name' | 'action'>;
|
|
21
21
|
/**
|
|
22
22
|
* Button to upload / import geodata file.
|
|
23
23
|
*/
|
|
@@ -37,29 +37,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
37
37
|
};
|
|
38
38
|
return __assign.apply(this, arguments);
|
|
39
39
|
};
|
|
40
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
41
|
-
if (k2 === undefined) k2 = k;
|
|
42
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
43
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
44
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
45
|
-
}
|
|
46
|
-
Object.defineProperty(o, k2, desc);
|
|
47
|
-
}) : (function(o, m, k, k2) {
|
|
48
|
-
if (k2 === undefined) k2 = k;
|
|
49
|
-
o[k2] = m[k];
|
|
50
|
-
}));
|
|
51
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
52
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
53
|
-
}) : function(o, v) {
|
|
54
|
-
o["default"] = v;
|
|
55
|
-
});
|
|
56
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
57
|
-
if (mod && mod.__esModule) return mod;
|
|
58
|
-
var result = {};
|
|
59
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
60
|
-
__setModuleDefault(result, mod);
|
|
61
|
-
return result;
|
|
62
|
-
};
|
|
63
40
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
64
41
|
var t = {};
|
|
65
42
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -76,7 +53,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
76
53
|
};
|
|
77
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
55
|
exports.UploadButton = void 0;
|
|
79
|
-
var
|
|
56
|
+
var react_1 = __importDefault(require("react"));
|
|
80
57
|
var antd_1 = require("antd");
|
|
81
58
|
var en_US_1 = __importDefault(require("../../locale/en_US"));
|
|
82
59
|
var icons_1 = require("@ant-design/icons");
|
|
@@ -85,9 +62,9 @@ var icons_1 = require("@ant-design/icons");
|
|
|
85
62
|
*/
|
|
86
63
|
var UploadButton = function (_a) {
|
|
87
64
|
var _b = _a.locale, locale = _b === void 0 ? en_US_1.default.UploadButton : _b, passThroughProps = __rest(_a, ["locale"]);
|
|
88
|
-
return (
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
return (react_1.default.createElement(antd_1.Upload, __assign({ name: "file", action: "memory" }, passThroughProps),
|
|
66
|
+
react_1.default.createElement(antd_1.Button, null,
|
|
67
|
+
react_1.default.createElement(icons_1.UploadOutlined, null),
|
|
91
68
|
" ",
|
|
92
69
|
locale.upload)));
|
|
93
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadButton.js","sourceRoot":"","sources":["../../../src/Component/UploadButton/UploadButton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG
|
|
1
|
+
{"version":3,"file":"UploadButton.js","sourceRoot":"","sources":["../../../src/Component/UploadButton/UploadButton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAA0B;AAE1B,6BAIc;AACd,6DAAuC;AACvC,2CAAmD;AAuBnD;;GAEG;AACI,IAAM,YAAY,GAAgC,UAAC,EAGzD;IAFC,IAAA,cAA2B,EAA3B,MAAM,mBAAG,eAAK,CAAC,YAAY,KAAA,EACxB,gBAAgB,cAFqC,UAGzD,CADoB;IAGnB,OAAO,CACL,8BAAC,aAAM,aACL,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,QAAQ,IACX,gBAAgB;QAEpB,8BAAC,aAAM;YACL,8BAAC,sBAAc,OAAG;;YAAE,MAAM,CAAC,MAAM,CAC1B,CACF,CACV,CAAC;AAEJ,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB;AAEF,kBAAe,oBAAY,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2018-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport React from 'react';\n\nimport {\n Upload,\n Button,\n UploadProps\n} from 'antd';\nimport en_US from '../../locale/en_US';\nimport { UploadOutlined } from '@ant-design/icons';\nimport { GeoStylerLocale } from '../../locale/locale';\n\nexport interface CustomRequest {\n onProgress: (event: { percent: number }) => void;\n onError: (event: Error, body?: any) => void;\n onSuccess: (body: any, file?: File) => void;\n data: any;\n filename: string;\n file: File;\n withCredentials: boolean;\n action: string;\n headers: any;\n}\n\n// default props\ninterface UploadButtonDefaultProps {\n locale?: GeoStylerLocale['UploadButton'];\n}\n\n// non default props\nexport type UploadButtonProps = UploadButtonDefaultProps & Omit<UploadProps<any>, 'name' | 'action'>;\n\n/**\n * Button to upload / import geodata file.\n */\nexport const UploadButton: React.FC<UploadButtonProps> = ({\n locale = en_US.UploadButton,\n ...passThroughProps\n}) => {\n\n return (\n <Upload\n name=\"file\"\n action=\"memory\"\n {...passThroughProps}\n >\n <Button>\n <UploadOutlined /> {locale.upload}\n </Button>\n </Upload>\n );\n\n};\n\nexport default UploadButton;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import ColorField from './Component/Symbolizer/Field/ColorField/ColorField';
|
|
|
12
12
|
import ColorMapEditor from './Component/Symbolizer/ColorMapEditor/ColorMapEditor';
|
|
13
13
|
import ColorMapEntryField from './Component/Symbolizer/Field/ColorMapEntryField/ColorMapEntryField';
|
|
14
14
|
import ColorMapTypeField from './Component/Symbolizer/Field/ColorMapTypeField/ColorMapTypeField';
|
|
15
|
+
import ColorRampCombo from './Component/RuleGenerator/ColorRampCombo/ColorRampCombo';
|
|
15
16
|
import ComparisonFilter from './Component/Filter/ComparisonFilter/ComparisonFilter';
|
|
16
17
|
import ContrastEnhancementField from './Component/Symbolizer/Field/ContrastEnhancementField/ContrastEnhancementField';
|
|
17
18
|
import ContrastField from './Component/Symbolizer/Field/ContrastField/ContrastField';
|
|
@@ -105,4 +106,4 @@ declare const locale: {
|
|
|
105
106
|
fr_FR: GeoStylerLocale;
|
|
106
107
|
zh_CN: GeoStylerLocale;
|
|
107
108
|
};
|
|
108
|
-
export { AttributeCombo, BoolFilterField, Breadcrumb, BrightnessField, BulkEditModals, BulkEditor, CardStyle, ChannelField, ChannelSelectionField, CodeEditor, ColorField, ColorMapEditor, ColorMapEntryField, ColorMapTypeField, ComparisonFilter, CompositionContext, ConfigProvider, ContrastEnhancementField, ContrastField, DataLoader, DataProvider, DefaultValueContext, Editor, ExtendedField, FadeDurationField, FieldContainer, FieldSet, FillEditor, FilterEditorWindow, FilterOverview, FilterTree, FontPicker, GammaField, GraphicEditor, GraphicTypeField, GrayChannelField, IconEditor, IconSelector, IconSelectorWindow, ImageField, KindField, LineCapField, LineDashField, LineEditor, LineJoinField, locale, localize, MarkEditor, MaxScaleDenominator, MinScaleDenominator, MultiEditor, NameField, NumberFilterField, OffsetField, OpacityField, OperatorCombo, Preview, PreviewMap, PropTextEditor, RadiusField, RasterChannelEditor, RasterEditor, RemoveButton, Removable, RemovableItem, LegacyRenderer, Renderer, RgbChannelField, ResamplingField, RotateField, Rule, RuleCard, RuleFieldContainer, RuleGenerator, RuleGeneratorWindow, RuleOverview, Rules, RuleTable, SaturationField, ScaleDenominator, Selectable, SelectableItem, SizeField, SLDRenderer, SourceChannelNameField, Style, StyleFieldContainer, StyleLoader, StyleOverview, SymbolizerCard, SymbolizerEditorWindow, Symbolizers, TextEditor, TextFilterField, UploadButton, UnsupportedPropertiesContext, WellKnownNameEditor, WellKnownNameField, WidthField, withDefaultsContext, GeoStylerLocale };
|
|
109
|
+
export { AttributeCombo, BoolFilterField, Breadcrumb, BrightnessField, BulkEditModals, BulkEditor, CardStyle, ChannelField, ChannelSelectionField, CodeEditor, ColorField, ColorMapEditor, ColorMapEntryField, ColorMapTypeField, ColorRampCombo, ComparisonFilter, CompositionContext, ConfigProvider, ContrastEnhancementField, ContrastField, DataLoader, DataProvider, DefaultValueContext, Editor, ExtendedField, FadeDurationField, FieldContainer, FieldSet, FillEditor, FilterEditorWindow, FilterOverview, FilterTree, FontPicker, GammaField, GraphicEditor, GraphicTypeField, GrayChannelField, IconEditor, IconSelector, IconSelectorWindow, ImageField, KindField, LineCapField, LineDashField, LineEditor, LineJoinField, locale, localize, MarkEditor, MaxScaleDenominator, MinScaleDenominator, MultiEditor, NameField, NumberFilterField, OffsetField, OpacityField, OperatorCombo, Preview, PreviewMap, PropTextEditor, RadiusField, RasterChannelEditor, RasterEditor, RemoveButton, Removable, RemovableItem, LegacyRenderer, Renderer, RgbChannelField, ResamplingField, RotateField, Rule, RuleCard, RuleFieldContainer, RuleGenerator, RuleGeneratorWindow, RuleOverview, Rules, RuleTable, SaturationField, ScaleDenominator, Selectable, SelectableItem, SizeField, SLDRenderer, SourceChannelNameField, Style, StyleFieldContainer, StyleLoader, StyleOverview, SymbolizerCard, SymbolizerEditorWindow, Symbolizers, TextEditor, TextFilterField, UploadButton, UnsupportedPropertiesContext, WellKnownNameEditor, WellKnownNameField, WidthField, withDefaultsContext, GeoStylerLocale };
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.MaxScaleDenominator = exports.MarkEditor = exports.localize = exports.locale = exports.LineJoinField = exports.LineEditor = exports.LineDashField = exports.LineCapField = exports.KindField = exports.ImageField = exports.IconSelectorWindow = exports.IconSelector = exports.IconEditor = exports.GrayChannelField = exports.GraphicTypeField = exports.GraphicEditor = exports.GammaField = exports.FontPicker = exports.FilterTree = exports.FilterOverview = exports.FilterEditorWindow = exports.FillEditor = exports.FieldSet = exports.FieldContainer = exports.FadeDurationField = exports.ExtendedField = exports.Editor = exports.DefaultValueContext = exports.DataProvider = exports.DataLoader = exports.ContrastField = exports.ContrastEnhancementField = exports.ConfigProvider = exports.CompositionContext = exports.ComparisonFilter = exports.ColorRampCombo = exports.ColorMapTypeField = exports.ColorMapEntryField = exports.ColorMapEditor = exports.ColorField = exports.CodeEditor = exports.ChannelSelectionField = exports.ChannelField = exports.CardStyle = exports.BulkEditor = exports.BulkEditModals = exports.BrightnessField = exports.Breadcrumb = exports.BoolFilterField = exports.AttributeCombo = void 0;
|
|
7
|
+
exports.WidthField = exports.WellKnownNameField = exports.WellKnownNameEditor = exports.UnsupportedPropertiesContext = exports.UploadButton = exports.TextFilterField = exports.TextEditor = exports.Symbolizers = exports.SymbolizerEditorWindow = exports.SymbolizerCard = exports.StyleOverview = exports.StyleLoader = exports.StyleFieldContainer = exports.Style = exports.SourceChannelNameField = exports.SLDRenderer = exports.SizeField = exports.SelectableItem = exports.Selectable = exports.ScaleDenominator = exports.SaturationField = exports.RuleTable = exports.Rules = exports.RuleOverview = exports.RuleGeneratorWindow = exports.RuleGenerator = exports.RuleFieldContainer = exports.RuleCard = exports.Rule = exports.RotateField = exports.ResamplingField = exports.RgbChannelField = exports.Renderer = exports.LegacyRenderer = exports.RemovableItem = exports.Removable = exports.RemoveButton = exports.RasterEditor = exports.RasterChannelEditor = exports.RadiusField = exports.PropTextEditor = exports.PreviewMap = exports.Preview = exports.OperatorCombo = exports.OpacityField = exports.OffsetField = exports.NumberFilterField = exports.NameField = exports.MultiEditor = exports.MinScaleDenominator = void 0;
|
|
8
|
+
exports.withDefaultsContext = void 0;
|
|
8
9
|
/* eslint-disable camelcase */
|
|
9
10
|
/* Released under the BSD 2-Clause License
|
|
10
11
|
*
|
|
@@ -61,6 +62,8 @@ var ColorMapEntryField_1 = __importDefault(require("./Component/Symbolizer/Field
|
|
|
61
62
|
exports.ColorMapEntryField = ColorMapEntryField_1.default;
|
|
62
63
|
var ColorMapTypeField_1 = __importDefault(require("./Component/Symbolizer/Field/ColorMapTypeField/ColorMapTypeField"));
|
|
63
64
|
exports.ColorMapTypeField = ColorMapTypeField_1.default;
|
|
65
|
+
var ColorRampCombo_1 = __importDefault(require("./Component/RuleGenerator/ColorRampCombo/ColorRampCombo"));
|
|
66
|
+
exports.ColorRampCombo = ColorRampCombo_1.default;
|
|
64
67
|
var ComparisonFilter_1 = __importDefault(require("./Component/Filter/ComparisonFilter/ComparisonFilter"));
|
|
65
68
|
exports.ComparisonFilter = ComparisonFilter_1.default;
|
|
66
69
|
var ContrastEnhancementField_1 = __importDefault(require("./Component/Symbolizer/Field/ContrastEnhancementField/ContrastEnhancementField"));
|