-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77dd6ea
commit 1f872de
Showing
7 changed files
with
251 additions
and
27 deletions.
There are no files selected for viewing
46 changes: 23 additions & 23 deletions
46
docs/assets/index-BCtqdiW3.js → docs/assets/index-BN30DA_l.js
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import threedMetadata from './3d-metadata'; | ||
import coreMetadata from './core-metadata'; | ||
import coreTemporal from './core-temporal'; | ||
import typesSchemasMetadata from './types-schemas-metadata'; | ||
|
||
export default [...coreMetadata, ...coreTemporal, ...threedMetadata]; | ||
export default [...coreMetadata, ...coreTemporal, ...threedMetadata, ...typesSchemasMetadata]; |
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,122 @@ | ||
import { DocumentTypes, Feature, FeatureCollection } from '../../types'; | ||
import { applyRules } from '../ruleValidation'; | ||
import { CC_CORE_URI } from './core-metadata'; | ||
import metadata, { CC_TYPES_SCHEMAS_URI } from './types-schemas-metadata'; | ||
|
||
describe('Requirement 17A', () => { | ||
test('Fails when a feature contains a "featureType" member and does not include the Feature Types and Schemas conformance class', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE, | ||
conformsTo: [CC_CORE_URI], | ||
featureType: 'app:building', | ||
} as Feature); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
|
||
test('Fails when a feature collection contains a "featureType" member and does not include the Feature Types and Schemas conformance class', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI], | ||
featureType: 'app:building', | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
|
||
test('Fails when a feature collection member contains a "featureType" member and does not include the Feature Types and Schemas conformance class', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI], | ||
features: [ | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
featureType: 'app:building', | ||
}, | ||
], | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('Requirement 18A', () => { | ||
test('Fails when a feature conforms to the Feature Types and Schemas conformance class and does not contain a "featureType" member', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE, | ||
conformsTo: [CC_CORE_URI, CC_TYPES_SCHEMAS_URI], | ||
} as Feature); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('Requirement 18B', () => { | ||
test('Succeeds when a feature collection contains a "featureType" member', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI, CC_TYPES_SCHEMAS_URI], | ||
featureType: 'app:building', | ||
features: [ | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
}, | ||
], | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(0); | ||
}); | ||
|
||
test('Succeeds when a feature collection contains a "featureType" member in every individual feature', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI, CC_TYPES_SCHEMAS_URI], | ||
features: [ | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
featureType: 'app:building', | ||
}, | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
featureType: 'app:building', | ||
}, | ||
], | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(0); | ||
}); | ||
|
||
test('Fails when both a feature collection and individual features contain a "featureType" member', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI, CC_TYPES_SCHEMAS_URI], | ||
featureType: 'app:building', | ||
features: [ | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
featureType: 'app:building', | ||
}, | ||
], | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
|
||
test('Fails when not every individual feature contains a "featureType" member', () => { | ||
const violations = applyRules(metadata, { | ||
type: DocumentTypes.FEATURE_COLLECTION, | ||
conformsTo: [CC_CORE_URI, CC_TYPES_SCHEMAS_URI], | ||
features: [ | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
featureType: 'app:building', | ||
}, | ||
{ | ||
type: DocumentTypes.FEATURE, | ||
}, | ||
], | ||
} as FeatureCollection); | ||
|
||
expect(violations.length).toBe(1); | ||
}); | ||
}); |
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,95 @@ | ||
import { FeatureDocument } from '../../types'; | ||
import { Rule } from '../ruleValidation'; | ||
|
||
export const CC_TYPES_SCHEMAS_URI = 'http://www.opengis.net/spec/json-fg-1/0.2/conf/types-schemas'; | ||
|
||
export const CC_TYPES_SCHEMAS_CURIE = '[ogc-json-fg-1-0.2:types-schemas]'; | ||
|
||
const conformsToTypesSchemas = (doc: FeatureDocument) => | ||
doc.conformsTo !== undefined && | ||
(doc.conformsTo.includes(CC_TYPES_SCHEMAS_URI) || doc.conformsTo.includes(CC_TYPES_SCHEMAS_CURIE)); | ||
|
||
const rules: Rule[] = []; | ||
|
||
rules.push({ | ||
name: '/req/types-schemas/metadata', | ||
validateFeature: (feature, isRoot) => { | ||
if (isRoot && feature.featureType !== undefined && !conformsToTypesSchemas(feature)) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the "featureType" member is present, the "conformsTo" member of the JSON document SHALL include at ' + | ||
'least the Feature Types and Schemas conformance class.', | ||
}; | ||
} | ||
}, | ||
validateFeatureCollection: featureCollection => { | ||
if ( | ||
(featureCollection.featureType !== undefined || | ||
featureCollection.features.some(feature => feature.featureType !== undefined)) && | ||
!conformsToTypesSchemas(featureCollection) | ||
) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the "featureType" member is present, the "conformsTo" member of the JSON document SHALL include at ' + | ||
'least the Feature Types and Schemas conformance class.', | ||
}; | ||
} | ||
}, | ||
}); | ||
|
||
rules.push({ | ||
name: '/req/types-schemas/feature-type', | ||
validateFeature: (feature, isRoot) => { | ||
if (isRoot && conformsToTypesSchemas(feature) && feature.featureType === undefined) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the document conforms to the Feature Types and Schemas conformance class, the "featureType" member ' + | ||
'must be present.', | ||
}; | ||
} | ||
}, | ||
validateFeatureCollection: featureCollection => { | ||
if ( | ||
conformsToTypesSchemas(featureCollection) && | ||
featureCollection.featureType === undefined && | ||
featureCollection.features.every(feature => feature.featureType === undefined) | ||
) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the document conforms to the Feature Types and Schemas conformance class, the "featureType" member ' + | ||
'must be present in either the collection or in every individual feature.', | ||
}; | ||
} | ||
|
||
if ( | ||
conformsToTypesSchemas(featureCollection) && | ||
featureCollection.featureType !== undefined && | ||
featureCollection.features.some(feature => feature.featureType !== undefined) | ||
) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the document contains a "featureType" member, individual members may not contain a "featureType" member.', | ||
}; | ||
} | ||
|
||
if ( | ||
conformsToTypesSchemas(featureCollection) && | ||
featureCollection.featureType === undefined && | ||
featureCollection.features.some(feature => feature.featureType !== undefined) && | ||
!featureCollection.features.every(feature => feature.featureType !== undefined) | ||
) { | ||
return { | ||
pointer: '/conformsTo', | ||
message: | ||
'When the document does not contain a "featureType" member, every individual feature must contain a "featureType" member.', | ||
}; | ||
} | ||
}, | ||
}); | ||
|
||
export default rules; |