Skip to content

Commit 4bfc9b0

Browse files
authored
Merge pull request #29 from slub/dev-integrateImportApi
Integrate new Georef Service API
2 parents 694ce56 + bf9f2b5 commit 4bfc9b0

File tree

18 files changed

+277
-286
lines changed

18 files changed

+277
-286
lines changed

Build/src/apps/admin/Evaluation.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { transformExtent } from "ol/proj";
99
import SettingsProvider from "../../SettingsProvider";
1010
import Map2D from "../../components/Map2D/Map2D";
1111
import LoadingBar from "../../components/LoadingBar/LoadingBar";
12-
import { queryTransformationTry } from "../../util/apiGeo";
12+
import { queryTransformationPreview } from "../../util/apiGeo";
1313
import LayerRectifiedImage from "../../components/LayerRectifiedImage/LayerRectifiedImage";
1414
import SelectTransformations from "./components/SelectTransformations/SelectTransformations";
1515
import TransformationItem from "./components/TransformationItem/TransformationItem";
@@ -25,10 +25,8 @@ export const Evaluation = () => {
2525
const handleClickPreview = async (transformation) => {
2626
if (!isLoading) {
2727
setIsLoading(true);
28-
const response = await queryTransformationTry(
29-
transformation.map_id,
30-
transformation.params,
31-
transformation.clip !== undefined ? transformation.clip : undefined
28+
const response = await queryTransformationPreview(
29+
transformation.transformation_id
3230
);
3331

3432
setCurrentPreview(

Build/src/apps/admin/components/TransformationItem/TransformationItem.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function ValidationButton({ validation, onSelect }) {
2929
>
3030
{["valid", "invalid"].map((v) => (
3131
<MenuItem key={v} onClick={() => onSelect(v)}>
32-
Setze Validation auf "{v}"
32+
Setze Validation auf &quot;{v}&quot;
3333
</MenuItem>
3434
))}
3535
</DropdownButton>
@@ -78,11 +78,11 @@ export const TransformationItem = (props) => {
7878

7979
const handleSubmitNewValidation = (o) => {
8080
const newJob = {
81-
task_name:
81+
name:
8282
o.validationValue === "valid"
8383
? "transformation_set_valid"
8484
: "transformation_set_invalid",
85-
task: {
85+
description: {
8686
comment: o.comment,
8787
transformation_id: o.transformationId,
8888
},

Build/src/apps/apps/UnreferencedMaps.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export const UnreferencedMaps = () => {
9797
</span>
9898
<span className="map-meta-value">{map.map_type}</span>
9999
</p>
100+
<p>
101+
<span className="map-meta-label">ID: </span>
102+
<span className="map-meta-value">{map.map_id}</span>
103+
</p>
100104
</div>
101105
<div className="map-links">
102106
<a

Build/src/apps/georeferencer/components/Toolbar/Controller.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import VectorLayer from "ol/layer/Vector";
1313
import VectorSource from "ol/source/Vector";
1414
import round from "lodash.round";
1515
import Observer from "../../../../util/observer";
16-
import { initializeSupportedCRS } from "../../../../util/geo";
1716
import {
1817
createClipPolygonStyle,
1918
createGcpDefaultStyle,
@@ -24,6 +23,7 @@ import {
2423
activateDelGcpAction,
2524
activateDrawClipAction,
2625
} from "./actions";
26+
import { DEFAULT_PROJ } from "../../util/util.js";
2727

2828
/**
2929
* Transforms the given pixel coordinates to geo pixel coordinate system.
@@ -204,8 +204,6 @@ export class Controller extends Observer {
204204
* This function initial loads the data to the vector source
205205
*/
206206
loadData() {
207-
initializeSupportedCRS();
208-
209207
// Add ground control points to the map
210208
if (this.params_.gcps.length > 0) {
211209
for (let i = 0, l = this.params_.gcps.length; i < l; i++) {
@@ -224,7 +222,7 @@ export class Controller extends Observer {
224222
new Point(
225223
transform(
226224
this.params_.gcps[i].target,
227-
this.params_.target,
225+
DEFAULT_PROJ,
228226
this.trgMap_.getView().getProjection()
229227
)
230228
)
@@ -238,7 +236,7 @@ export class Controller extends Observer {
238236
// Add the clip polygon to the map
239237
if (this.clip_) {
240238
const newFeature = new GeoJSON().readFeature(this.clip_, {
241-
dataProjection: this.clip_.crs.properties.name,
239+
dataProjection: DEFAULT_PROJ,
242240
featureProjection: this.trgMap_.getView().getProjection(),
243241
});
244242

@@ -343,7 +341,7 @@ export class Controller extends Observer {
343341
target: transform(
344342
trgFt.getGeometry().getCoordinates(),
345343
this.trgMap_.getView().getProjection(),
346-
this.params_.target
344+
DEFAULT_PROJ
347345
),
348346
});
349347
}
@@ -363,17 +361,12 @@ export class Controller extends Observer {
363361
: undefined;
364362

365363
if (clipFeature !== undefined) {
366-
return Object.assign(
367-
new GeoJSON().writeGeometryObject(clipFeature.getGeometry(), {
368-
dataProjection: "EPSG:4326",
364+
return new GeoJSON().writeGeometryObject(
365+
clipFeature.getGeometry(),
366+
{
367+
dataProjection: DEFAULT_PROJ,
369368
featureProjection: "EPSG:3857",
370369
decimals: 9,
371-
}),
372-
{
373-
crs: {
374-
type: "name",
375-
properties: { name: "EPSG:4326" },
376-
},
377370
}
378371
);
379372
} else {

Build/src/apps/georeferencer/components/Toolbar/Toolbar.jsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useRecoilValue, useSetRecoilState, useRecoilState } from "recoil";
99
import queryString from "query-string";
1010
import {
1111
postTransformation,
12+
queryTransformationPreview,
1213
queryTransformationTry,
1314
} from "../../../../util/apiGeo";
1415
import { translate } from "../../../../util/util";
@@ -117,7 +118,13 @@ export const Toolbar = () => {
117118
// Handle get rectified image
118119
const handleClickRectifiedImage = () => {
119120
const fetchData = async (map_id, params) => {
120-
const rectifiedImageParams = await queryTransformationTry(map_id, params);
121+
const rectifiedImageParams =
122+
refController.current.hasParamsOrClipChanged() ||
123+
selectedAlgorithm !== transformation.params.algorithm ||
124+
transformation?.overwrites === undefined ||
125+
transformation.overwrites === 0
126+
? await queryTransformationTry(map_id, params)
127+
: await queryTransformationPreview(transformation.overwrites);
121128
setIsLoading(false);
122129
setRectifiedImageParams(rectifiedImageParams);
123130
};
@@ -202,15 +209,24 @@ export const Toolbar = () => {
202209
targetViewParams !== null
203210
) {
204211
refController.current = new Controller({
205-
clip: transformation.clip,
212+
clip:
213+
transformation?.clip !== undefined && transformation?.clip !== null
214+
? {
215+
type: transformation.clip.type,
216+
coordinates: transformation.clip.coordinates,
217+
}
218+
: undefined,
206219
onSetHelperMsg: (newHelperMsg) => {
207220
setNotification({
208221
id: "toolbar-info",
209222
type: "info",
210223
text: newHelperMsg,
211224
});
212225
},
213-
params: transformation.params,
226+
params: {
227+
algorithm: transformation.params.algorithm,
228+
gcps: transformation.params.gcps,
229+
},
214230
sourceMap: sourceViewParams.map,
215231
targetMap: targetViewParams.map,
216232
});
@@ -224,6 +240,9 @@ export const Toolbar = () => {
224240
() => {}
225241
)
226242
);
243+
244+
// restore algorithm setting from transformation
245+
setActiveAlgorithm(transformation.params.algorithm);
227246
}
228247
}, [
229248
transformation,

Build/src/apps/georeferencer/util/util.js

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* This file is subject to the terms and conditions defined in
55
* file 'LICENSE.txt', which is part of this source code package.
66
*/
7-
import { initializeSupportedCRS } from "../../../util/geo";
87
import { boundingExtent } from "ol/extent";
9-
import { toLonLat } from "ol/proj";
108
import GeoJSON from "ol/format/GeoJSON";
119

10+
export const DEFAULT_PROJ = "EPSG:4326";
11+
1212
/**
1313
* Extracts a extent from a given transformation. The extent is always computed in EPSG:4326
1414
* @param {{
@@ -28,28 +28,11 @@ import GeoJSON from "ol/format/GeoJSON";
2828
* @returns {[number, number, number, number]}
2929
*/
3030
export function geoJsonExtentFromTransformation(transformation) {
31-
initializeSupportedCRS();
32-
3331
const { params, clip } = transformation;
34-
let points = [];
35-
36-
// Transform gcp target points to LonLat points
37-
if (params.gcps.length > 0) {
38-
const targetSrs = params.target;
39-
points = [...params.gcps.map((gcp) => toLonLat(gcp.target, targetSrs))];
40-
}
41-
42-
// Transform clip points to LonLat Points
43-
if (clip !== null && clip !== undefined) {
44-
const targetSrs =
45-
clip.crs !== undefined ? clip.crs.properties.name : "EPSG:4326";
46-
points = [
47-
...points,
48-
clip.coordinates[0].map((c) =>
49-
targetSrs !== "EPSG:4326" ? toLonLat(c, targetSrs) : c
50-
),
51-
];
52-
}
32+
const points = [
33+
...params.gcps.map((gcp) => gcp.target),
34+
...(clip !== undefined && clip !== null ? clip.coordinates[0] : []),
35+
];
5336

5437
return points.length > 0 ? boundingExtent(points) : null;
5538
}
@@ -60,15 +43,10 @@ export function geoJsonExtentFromTransformation(transformation) {
6043
* @returns {[number, number, number, number]}
6144
*/
6245
export function geoJsonExtentFromGeoJsonPolygon(geojsonPolygon) {
63-
initializeSupportedCRS();
64-
65-
const targetSrs =
66-
geojsonPolygon.crs !== undefined
67-
? geojsonPolygon.crs.properties.name
68-
: "EPSG:4326";
6946
const polygon = new GeoJSON().readGeometry(geojsonPolygon, {
70-
dataProjection: targetSrs,
71-
featureProjection: "EPSG:4326",
47+
dataProjection: DEFAULT_PROJ,
48+
featureProjection: DEFAULT_PROJ,
7249
});
50+
7351
return polygon.getExtent();
7452
}

Build/src/apps/georeferencer/views/GeoreferenceView/GeoreferenceView.jsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ import {
2525
} from "../../util/util";
2626
import "./GeoreferenceView.scss";
2727

28+
const parseTransformation = (transformation) => {
29+
// remove all but the required properties from the clip and the transformation
30+
return {
31+
map_id: transformation.map_id,
32+
clip:
33+
transformation?.clip !== undefined && transformation.clip !== null
34+
? {
35+
type: transformation.clip.type,
36+
coordinates: transformation.clip.coordinates,
37+
}
38+
: undefined,
39+
overwrites: transformation.transformation_id,
40+
params: {
41+
algorithm: transformation?.params?.algorithm ?? "affine",
42+
gcps: transformation?.params?.gcps ?? [],
43+
},
44+
};
45+
};
46+
2847
export const GeoreferenceView = (props) => {
2948
const { urlsOsmBaseMap, urlNominatim } = props;
3049
const setTransformation = useSetRecoilState(transformationState);
@@ -41,14 +60,22 @@ export const GeoreferenceView = (props) => {
4160
const qs = queryString.parse(location.search);
4261

4362
if (qs.map_id !== undefined) {
44-
const transformationData = await queryTransformationForMapId(qs.map_id);
63+
const { transformations, additional_properties } =
64+
await queryTransformationForMapId(qs.map_id);
65+
const {
66+
active_transformation_id,
67+
extent: transf_extent,
68+
pending_jobs,
69+
} = additional_properties;
70+
4571
const metadata = await queryDocument(qs.map_id);
72+
4673
let extent =
47-
transformationData.extent !== null
48-
? geoJsonExtentFromGeoJsonPolygon(transformationData.extent)
74+
transf_extent !== null
75+
? geoJsonExtentFromGeoJsonPolygon(transf_extent)
4976
: null;
5077

51-
if (transformationData.pending_jobs) {
78+
if (pending_jobs) {
5279
setNotification({
5380
id: "georeference-view",
5481
type: "warning",
@@ -60,31 +87,22 @@ export const GeoreferenceView = (props) => {
6087
const targetTransformationId =
6188
qs.transformation_id !== undefined
6289
? parseInt(qs.transformation_id)
63-
: transformationData.active_transformation_id;
90+
: active_transformation_id;
6491

65-
if (
66-
transformationData.transformations.length > 0 &&
67-
targetTransformationId !== null
68-
) {
69-
const activeTransformation = transformationData.transformations.find(
92+
if (transformations.length > 0 && targetTransformationId !== null) {
93+
const activeTransformation = transformations.find(
7094
(t) => t.transformation_id === targetTransformationId
7195
);
96+
7297
extent = geoJsonExtentFromTransformation(activeTransformation);
7398

74-
setTransformation({
75-
map_id: activeTransformation.map_id,
76-
clip: activeTransformation.clip,
77-
overwrites: activeTransformation.transformation_id,
78-
params: activeTransformation.params,
79-
});
80-
} else if (transformationData.active_transformation_id === null) {
99+
setTransformation(parseTransformation(activeTransformation));
100+
} else if (active_transformation_id === null) {
81101
setTransformation({
82102
map_id: qs.map_id,
83103
clip: null,
84104
overwrites: 0,
85105
params: {
86-
source: "pixel",
87-
target: transformationData.default_srs,
88106
algorithm: "affine",
89107
gcps: [],
90108
},

Build/src/components/LayerRectifiedImage/LayerRectifiedImage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const LayerRectifiedImage = (props) => {
3838
// Init and add the layer
3939
const layer = new Tile({
4040
source: new TileWMS({
41-
url: wmsUrl.split("?")[0],
41+
url: wmsUrl,
4242
params: {
4343
LAYERS: layerName,
4444
VERSION: "1.1.1",

0 commit comments

Comments
 (0)