forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed geosolutions-it#1263. Updated WFST functionalities.
- externalized, functionalized and tested ogc operators - improved WFS-T functions
- Loading branch information
1 parent
ea63593
commit 2b11bb8
Showing
10 changed files
with
273 additions
and
237 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,32 @@ | ||
/** | ||
* Copyright 2017, 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. | ||
*/ | ||
// Disable ESLint because some of the names to include are not in camel case | ||
const expect = require('expect'); | ||
const {ogcComparisonOperators, ogcLogicalOperators} = require('../operators'); | ||
|
||
describe('Test WFS-T request bodies generation', () => { | ||
it('ogcComparisonOperators', () => { | ||
expect(ogcComparisonOperators["="]("ogc", "TEST")).toBe("<ogc:PropertyIsEqualTo>TEST</ogc:PropertyIsEqualTo>"); | ||
expect(ogcComparisonOperators[">"]("ogc", "TEST")).toBe("<ogc:PropertyIsGreaterThan>TEST</ogc:PropertyIsGreaterThan>"); | ||
expect(ogcComparisonOperators["<"]("ogc", "TEST")).toBe("<ogc:PropertyIsLessThan>TEST</ogc:PropertyIsLessThan>"); | ||
expect(ogcComparisonOperators[">="]("ogc", "TEST")).toBe("<ogc:PropertyIsGreaterThanOrEqualTo>TEST</ogc:PropertyIsGreaterThanOrEqualTo>"); | ||
expect(ogcComparisonOperators["<="]("ogc", "TEST")).toBe("<ogc:PropertyIsLessThanOrEqualTo>TEST</ogc:PropertyIsLessThanOrEqualTo>"); | ||
expect(ogcComparisonOperators["<>"]("ogc", "TEST")).toBe("<ogc:PropertyIsNotEqualTo>TEST</ogc:PropertyIsNotEqualTo>"); | ||
expect(ogcComparisonOperators.like("ogc", "TEST")).toBe('<ogc:PropertyIsLike matchCase="true" wildCard="*" singleChar="." escapeChar="!">TEST</ogc:PropertyIsLike>'); | ||
expect(ogcComparisonOperators.ilike("ogc", "TEST")).toBe('<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">TEST</ogc:PropertyIsLike>'); | ||
expect(ogcComparisonOperators.isNull("ogc", "TEST")).toBe('<ogc:PropertyIsNull>TEST</ogc:PropertyIsNull>'); | ||
}); | ||
it('ogcLogicalOperators', () => { | ||
const AND = "AND"; | ||
const OR = "OR"; | ||
const AND_NOT = "AND NOT"; | ||
expect(ogcLogicalOperators[AND]("ogc", "TEST")).toBe("<ogc:And>TEST</ogc:And>"); | ||
expect(ogcLogicalOperators[OR]("ogc", "TEST")).toBe("<ogc:Or>TEST</ogc:Or>"); | ||
expect(ogcLogicalOperators[AND_NOT]("ogc", "TEST")).toBe("<ogc:Not>TEST</ogc:Not>"); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,15 @@ | ||
const fidFilter = (fid) => | ||
`<ogc:Filter><ogc:FeatureId fid="${fid}"/></ogc:Filter>`; | ||
/** | ||
* Copyright 2017, 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. | ||
*/ | ||
const filter = (content, ns = "ogc") => `<${ns}:Filter>${Array.isArray(content) ? content.join("") : content}</${ns}:Filter>`; | ||
const fidFilter = (fid, ns = "ogc") => | ||
filter(`<${ns}:FeatureId fid="${fid}"/>`, ns); | ||
|
||
module.exports = { | ||
fidFilter | ||
fidFilter, | ||
filter | ||
}; |
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,37 @@ | ||
/** | ||
* Copyright 2017, 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. | ||
*/ | ||
const ogcComparisonOperators = { | ||
"=": (ns, content) => `<${ns}:PropertyIsEqualTo>${content}</${ns}:PropertyIsEqualTo>`, | ||
">": (ns, content) => `<${ns}:PropertyIsGreaterThan>${content}</${ns}:PropertyIsGreaterThan>`, | ||
"<": (ns, content) => `<${ns}:PropertyIsLessThan>${content}</${ns}:PropertyIsLessThan>`, | ||
">=": (ns, content) => `<${ns}:PropertyIsGreaterThanOrEqualTo>${content}</${ns}:PropertyIsGreaterThanOrEqualTo>`, | ||
"<=": (ns, content) => `<${ns}:PropertyIsLessThanOrEqualTo>${content}</${ns}:PropertyIsLessThanOrEqualTo>`, | ||
"<>": (ns, content) => `<${ns}:PropertyIsNotEqualTo>${content}</${ns}:PropertyIsNotEqualTo>`, | ||
"><": (ns, content) => `<${ns}:PropertyIsBetween>${content}</${ns}:PropertyIsBetween>`, | ||
"like": (ns, content) => `<${ns}:PropertyIsLike matchCase="true" wildCard="*" singleChar="." escapeChar="!">${content}</${ns}:PropertyIsLike>`, | ||
"ilike": (ns, content) => `<${ns}:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">${content}</${ns}:PropertyIsLike>`, | ||
"isNull": (ns, content) => `<${ns}:PropertyIsNull>${content}</${ns}:PropertyIsNull>` | ||
}; | ||
const ogcLogicalOperators = { | ||
"AND": (ns, content) => `<${ns}:And>${content}</${ns}:And>`, | ||
"OR": (ns, content) => `<${ns}:Or>${content}</${ns}:Or>`, | ||
"AND NOT": (ns, content) => `<${ns}:Not>${content}</${ns}:Not>` | ||
}; | ||
|
||
var ogcSpatialOperators = { | ||
"INTERSECTS": (ns, content) => `<${ns}:Intersects>${content}</${ns}:Intersects>`, | ||
"BBOX": (ns, content) => `<${ns}:BBOX>${content}</${ns}:BBOX>`, | ||
"CONTAINS": (ns, content) => `<${ns}:Contains>${content}</${ns}:Contains>`, | ||
"DWITHIN": (ns, content) => `<${ns}:DWithin>${content}</${ns}:DWithin>`, | ||
"WITHIN": (ns, content) => `<${ns}:Within>${content}</${ns}:Within` | ||
}; | ||
module.exports = { | ||
ogcComparisonOperators, | ||
ogcLogicalOperators, | ||
ogcSpatialOperators | ||
}; |
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