Skip to content

Commit

Permalink
refactor: fix typechecks
Browse files Browse the repository at this point in the history
Adjusts several componentes and updates the shogun-util to pass typechecks
  • Loading branch information
mholthausen committed Apr 25, 2024
1 parent 3b9423e commit 742f2ed
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 268 deletions.
326 changes: 77 additions & 249 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@terrestris/react-geo": "file:terrestris-react-geo-23.3.0.tgz",
"@terrestris/react-util": "^4.0.0-beta.4",
"@terrestris/shogun-e2e-tests": "^1.0.4",
"@terrestris/shogun-util": "^7.3.1",
"@terrestris/shogun-util": "^8.1.0",
"antd": "^5.16.0",
"color": "^4.2.3",
"dotenv": "^16.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { t } from 'i18next';
import _isEmpty from 'lodash/isEmpty';

import { isEmpty as isEmptyOlExtent } from 'ol/extent';
import OlFeature from 'ol/Feature';
import OlFormatGeoJson from 'ol/format/GeoJSON';
import OlGeometry from 'ol/geom/Geometry';
import { DrawEvent as OlDrawEvent } from 'ol/interaction/Draw';
Expand Down Expand Up @@ -78,7 +79,7 @@ export const EditFeatureGeometryToolbar: React.FC<EditFeatureGeometryToolbarProp
const map = useMap();
const dispatch = useAppDispatch();

const [editLayer, setEditLayer] = useState<OlLayerVector<OlSourceVector<OlGeometry>>>();
const [editLayer, setEditLayer] = useState<OlLayerVector<OlSourceVector<OlFeature<OlGeometry>>>>();
const [, setRevision] = useState<number>(0);

const gjFormat = useMemo(() => new OlFormatGeoJson(), []);
Expand Down Expand Up @@ -260,6 +261,7 @@ export const EditFeatureGeometryToolbar: React.FC<EditFeatureGeometryToolbarProp
{
allowedEditMode.includes('DELETE') ?
<DeleteButton
active={true}
icon={
<FontAwesomeIcon icon={faTrash} />
}
Expand Down
1 change: 0 additions & 1 deletion src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const Footer: React.FC<FooterProps> = ({
{t('Footer.scale')}:&nbsp;
<ScaleCombo
aria-label='scalecombo-dropdown'
map={map}
/>
<Divider
type="vertical"
Expand Down
2 changes: 1 addition & 1 deletion src/components/JsonModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const JsonModal: React.FC<JsonModalProps> = ({
showFoldingControls: 'always',
selectionHighlight: false,
renderLineHighlight: 'none',
occurrencesHighlight: 'off'
occurrencesHighlight: false
}}
/>
</Modal>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MultiSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ import {
import logger from '@terrestris/base-util/dist/Logger';

import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
import { NominatimPlace } from '@terrestris/react-geo/dist/Field/NominatimSearch/NominatimSearch';
import SearchResultsPanel, {
Category as ResultCategory
} from '@terrestris/react-geo/dist/Panel/SearchResultsPanel/SearchResultsPanel';
import { useMap } from '@terrestris/react-util/dist/Hooks/useMap/useMap';
import { NominatimPlace } from '@terrestris/react-util/dist/Hooks/useNominatim/useNominatim';

import {
SearchConfig
Expand Down
3 changes: 2 additions & 1 deletion src/components/PrintForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FormProps } from 'antd/lib/form/Form';
import ClientConfiguration from 'clientConfig';
import _isNil from 'lodash/isNil';

import OlFeature from 'ol/Feature';
import OlGeometry from 'ol/geom/Geometry';
import OlLayerGroup from 'ol/layer/Group';
import OlLayer from 'ol/layer/Layer';
Expand Down Expand Up @@ -66,7 +67,7 @@ export interface PrintFormProps extends Omit<FormProps, 'form'> {
outputFormats?: string[];
}

export type LayerType = OlLayer<OlSource, OlLayerRenderer<OlLayerVector<OlSourceVector<OlGeometry>>>>;
export type LayerType = OlLayer<OlSource, OlLayerRenderer<OlLayerVector<OlSourceVector<OlFeature<OlGeometry>>>>>;

export const PrintForm: React.FC<PrintFormProps> = ({
active,
Expand Down
5 changes: 3 additions & 2 deletions src/components/ToolMenu/Draw/DeleteAllButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Modal } from 'antd';
import OlFeature from 'ol/Feature';
import OlGeometry from 'ol/geom/Geometry';
import OlVectorLayer from 'ol/layer/Vector';
import OlVectorSource from 'ol/source/Vector';
Expand All @@ -26,7 +27,7 @@ interface OwnProps {
* The vector layer which will be used for digitize features.
* The standard digitizeLayer can be retrieved via `DigitizeUtil.getDigitizeLayer(map)`.
*/
digitizeLayer?: OlVectorLayer<OlVectorSource<OlGeometry>>;
digitizeLayer?: OlVectorLayer<OlVectorSource<OlFeature<OlGeometry>>>;
}

export type DeleteAllButtonProps = OwnProps & SimpleButtonProps;
Expand All @@ -41,7 +42,7 @@ export const DeleteAllButton: React.FC<DeleteAllButtonProps> = ({
digitizeLayer,
...passThroughProps
}) => {
const [layers, setLayers] = useState<[OlVectorLayer<OlVectorSource<OlGeometry>>]|null>(null);
const [layers, setLayers] = useState<[OlVectorLayer<OlVectorSource<OlFeature<OlGeometry>>>]|null>(null);

const map = useMap();

Expand Down
5 changes: 3 additions & 2 deletions src/components/ToolMenu/Draw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const Draw: React.FC<DrawProps> = ({
return (
<>
<ToggleGroup
selectedName={selectedButton}
selected={selectedButton}
onChange={onToggleChange}
>
{showDrawPoint ? (
Expand Down Expand Up @@ -305,7 +305,7 @@ export const Draw: React.FC<DrawProps> = ({
<ModifyButton
name="draw-modify"
type="link"
onToggle={onModifyButtonToggle}
onClick={() => onModifyButtonToggle}
>
<FontAwesomeIcon
icon={faPenToSquare}
Expand All @@ -321,6 +321,7 @@ export const Draw: React.FC<DrawProps> = ({
<DeleteButton
name="draw-delete"
type="link"
active={true}
>
<FontAwesomeIcon
icon={faEraser}
Expand Down
14 changes: 11 additions & 3 deletions src/components/ToolMenu/FeatureInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
FormProps, Spin, Tabs
} from 'antd';

import { Coordinate as OlCoordinate } from 'ol/coordinate';
import OlFeature from 'ol/Feature';
import OlFormatGeoJSON from 'ol/format/GeoJSON';
import OlLayerBase from 'ol/layer/Base';
import OlLayerImage from 'ol/layer/Image';
Expand All @@ -20,8 +22,7 @@ import { useTranslation } from 'react-i18next';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';

import CoordinateInfo, {
CoordinateInfoProps,
CoordinateInfoState
CoordinateInfoProps
} from '@terrestris/react-geo/dist/CoordinateInfo/CoordinateInfo';
import { useMap } from '@terrestris/react-util/dist/Hooks/useMap/useMap';
import {
Expand Down Expand Up @@ -55,6 +56,14 @@ export type FeatureInfoConfig = {

export type FeatureInfoProps = FormProps & Partial<CoordinateInfoProps>;

export interface CoordinateInfoState {
clickCoordinate: OlCoordinate | null;
features: {
[layerName: string]: OlFeature[];
};
loading: boolean;
}

type LayerIndex = {
layerName: string;
index: number;
Expand Down Expand Up @@ -273,7 +282,6 @@ export const FeatureInfo: React.FC<FeatureInfoProps> = ({
<div className='feature-info-panel'>
<CoordinateInfo
featureCount={10}
map={map}
queryLayers={queryLayers}
resultRenderer={resultRenderer}
fetchOpts={getFetchOpts}
Expand Down
2 changes: 0 additions & 2 deletions src/components/ToolMenu/Measure/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const Measure: React.FC<MeasureProps> = ({
<MeasureButton
geodesic
name="line"
map={map}
measureType="line"
type="link"
continueLineMsg={t('Measure.clicktodrawline')}
Expand All @@ -62,7 +61,6 @@ export const Measure: React.FC<MeasureProps> = ({
<MeasureButton
geodesic
name="poly"
map={map}
measureType="polygon"
type="link"
continuePolygonMsg={t('Measure.clicktodrawarea')}
Expand Down
5 changes: 3 additions & 2 deletions src/components/UploadDataModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import ClientConfiguration from 'clientConfig';

import OlLayerGroup from 'ol/layer/Group';
import TileLayer from 'ol/layer/Tile';
import TileWMSSource from 'ol/source/TileWMS';
import TileWMS from 'ol/source/TileWMS';

import {
UploadRequestOption
Expand Down Expand Up @@ -65,6 +65,7 @@ import {
} from '../../store/uploadDataModal';

import './index.less';
// eslint-disable-next-line import/order

type FeatureTypeAttribute = {
name: string;
Expand Down Expand Up @@ -120,7 +121,7 @@ export const UploadDataModal: React.FC<UploadDataModalProps> = ({
dispatch(hide());
};

const addLayer = (layer: TileLayer<TileWMSSource>) => {
const addLayer = (layer: TileLayer<TileWMS>) => {
if (!map) {
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/WmsTimeSlider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ export const WmsTimeSlider: React.FC<WmsTimeSliderProps> = ({
{t('WmsTimeSlider.title')}
</Divider>
{
marks ?
marks && min && max ?
<TimeSlider
formatString={''}
defaultValue={''}
min={min}
max={max}
marks={marks}
value={value}
onChange={onChange}
step={null}
{...passThroughProps}
/> :
<span>
Expand Down

0 comments on commit 742f2ed

Please sign in to comment.