-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from alexander-fedorenko/save-selection-as-an…
…notation Exporting selected plots into annotation
- Loading branch information
Showing
10 changed files
with
285 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import expect from "expect"; | ||
import { testEpic } from "@mapstore/epics/__tests__/epicTestUtils"; | ||
import {saveAsAnnotation} from "../../actions/cadastrapp"; | ||
import {CADASTRAPP_VECTOR_LAYER_ID} from "@js/extension/constants"; | ||
import {cadastrappSaveAsAnnotation} from "@js/extension/epics/events"; | ||
import {SET_CONTROL_PROPERTY} from "@mapstore/actions/controls"; | ||
import {NEW_ANNOTATION, SET_EDITING_FEATURE} from "@mapstore/actions/annotations"; | ||
|
||
describe("download Epics", () => { | ||
const state = { | ||
cadastrapp: { | ||
configuration: | ||
{ | ||
cadastreLayerIdParcelle: 'testProp' | ||
} | ||
}, | ||
additionallayers: [ | ||
{ | ||
id: CADASTRAPP_VECTOR_LAYER_ID, | ||
options: { | ||
id: CADASTRAPP_VECTOR_LAYER_ID, | ||
features: [ | ||
{ | ||
type: 'Feature', | ||
geometry: { | ||
type: 'MultiPolygon', | ||
coordinates: [ | ||
[ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[0, 0] | ||
] | ||
] | ||
] | ||
}, | ||
properties: { | ||
testProp: 'SomeTitle' | ||
}, | ||
style: { | ||
fillColor: '#81BEF7', | ||
opacity: 0.6, | ||
fillOpacity: 0.6, | ||
color: '#111111', | ||
weight: 4 | ||
} | ||
}, | ||
{ | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Polygon', | ||
coordinates: [ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[0, 0] | ||
] | ||
] | ||
}, | ||
properties: { | ||
testProp: 'SomeTitle2' | ||
}, | ||
style: { | ||
fillColor: '#81BEF7', | ||
opacity: 0.6, | ||
fillOpacity: 0.6, | ||
color: '#111111', | ||
weight: 4 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
it("cadastrappSaveAsAnnotation", done => { | ||
testEpic( | ||
cadastrappSaveAsAnnotation, | ||
3, | ||
saveAsAnnotation(), | ||
actions => { | ||
expect(actions.length).toBe(3); | ||
actions.map(action=>{ | ||
switch (action.type) { | ||
case SET_CONTROL_PROPERTY: | ||
case NEW_ANNOTATION: | ||
break; | ||
case SET_EDITING_FEATURE: | ||
expect(action.feature.features.length).toBe(2); | ||
break; | ||
default: | ||
expect(false).toBe(true); | ||
} | ||
}); | ||
done(); | ||
}, | ||
state | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import expect from 'expect'; | ||
import {convertFeaturesToAnnotation} from "@js/extension/utils/download"; | ||
|
||
describe('download utils', () => { | ||
it("convertFeaturesToAnnotation", () => { | ||
const state = { | ||
cadastrapp: { | ||
configuration: | ||
{ | ||
cadastreLayerIdParcelle: 'testProp' | ||
} | ||
} | ||
}; | ||
|
||
const layer = { | ||
features: [ | ||
{ | ||
type: 'Feature', | ||
geometry: { | ||
type: 'MultiPolygon', | ||
coordinates: [ | ||
[ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[0, 0] | ||
] | ||
] | ||
] | ||
}, | ||
properties: { | ||
testProp: 'SomeTitle' | ||
}, | ||
style: { | ||
fillColor: '#81BEF7', | ||
opacity: 0.6, | ||
fillOpacity: 0.6, | ||
color: '#111111', | ||
weight: 4 | ||
} | ||
}, | ||
{ | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Polygon', | ||
coordinates: [ | ||
[ | ||
[0, 0], | ||
[0, 1], | ||
[1, 1], | ||
[0, 0] | ||
] | ||
] | ||
}, | ||
properties: { | ||
testProp: 'SomeTitle2' | ||
}, | ||
style: { | ||
fillColor: '#81BEF7', | ||
opacity: 0.6, | ||
fillOpacity: 0.6, | ||
color: '#111111', | ||
weight: 4 | ||
} | ||
} | ||
] | ||
}; | ||
|
||
const converted = convertFeaturesToAnnotation(layer, state); | ||
expect(converted.features[0].geometry.type).toBe('Polygon'); | ||
expect(converted.features[1].geometry.type).toBe(layer.features[1].geometry.type); | ||
expect(converted.features[0].properties.geometryTitle).toBe('SomeTitle'); | ||
expect(converted.features[1].properties.geometryTitle).toBe('SomeTitle2'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters