Skip to content

Commit

Permalink
Merge pull request #934 from koopjs/p/pbf-optional
Browse files Browse the repository at this point in the history
feat: allow PBF format to be removed from layer info
  • Loading branch information
rgwozdz authored Feb 28, 2024
2 parents 4a755ba + a8a6814 commit 5d7e4d9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-cats-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@koopjs/featureserver": minor
---

- allow supportedQueryFormats to be overridden with geoservice defaults
8 changes: 7 additions & 1 deletion packages/featureserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,13 @@ If you are using FeatureServer as part of a Koop instance, FeatureServer is regi
```js
const koop = new Koop({
geoservicesDefaults: { currentVersion: 99.0 }
geoservicesDefaults: {
currentVersion: 99.0 // set your own version number
fullVersion: '99.9.9'
layer: {
supportedQueryFormats: 'JSON' // allowed values include 'JSON', 'JSON,geojson'; default is 'JSON,geojson,PBF'
}
}
});

```
5 changes: 4 additions & 1 deletion packages/featureserver/src/metadata-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const EXTENT = {
ymax: 90,
spatialReference: SPATIAL_REFERENCE,
};
const SUPPORTED_QUERY_FORMATS = 'JSON,geojson,PBF';

const defaultOverridables = {
currentVersion: CURRENT_VERSION,
Expand All @@ -38,6 +39,7 @@ const defaultOverridables = {
description: LAYER_DESCRIPTION,
copyrightText: COPYRIGHT,
extent: EXTENT,
supportedQueryFormats: SUPPORTED_QUERY_FORMATS
},
};

Expand Down Expand Up @@ -71,6 +73,7 @@ const overridablesSchema = joi.object({
description: joi.string().allow(null, ''),
copyrightText: joi.string().allow(null, ''),
extent: esriExtentSchema,
supportedQueryFormats: joi.string().allow('JSON', 'JSON,geojson')
}),
});

Expand Down Expand Up @@ -203,7 +206,7 @@ class MetadataDefaults {
},
preferredTimeReference: null,
templates: [],
supportedQueryFormats: 'JSON,geojson,PBF',
supportedQueryFormats: this.#overridables.layer.supportedQueryFormats,
supportedAppendFormats: '',
supportedExportFormats: '',
supportedSpatialRelationships: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function transformToPbfGeometry(geometry, transform) {
return transformMultipoint(geometry, transform, false, false);
}

throw new Error('Unknown geometry type');
throw new Error(`Unknown geometry type: ${JSON.stringify(geometry)}`);
}

function isMultipoint(json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('transformToPbfGeometry', () => {
const result = transformToPbfGeometry(fixture, defaultTransform);
should.equal(result, null);
} catch (error) {
error.message.should.equal('Unknown geometry type');
error.message.should.equal('Unknown geometry type: {}');
}
});
});
Expand Down
30 changes: 27 additions & 3 deletions test/geoservice-defaults.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ const VERSION = 11.2;
const FULL_VERSION = '11.2.0';

describe('Geoservices defaults settings', () => {
const koop = new Koop({ logLevel: 'error', geoservicesDefaults: { currentVersion: VERSION, fullVersion: FULL_VERSION } });
const koop = new Koop({
logLevel: 'error',
geoservicesDefaults: {
currentVersion: VERSION,
fullVersion: FULL_VERSION,
layer: { supportedQueryFormats: 'JSON' },
},
});
koop.register(provider, { dataDir: './test/provider-data' });
test('should return server metadata with expected version', async () => {
try {
const response = await request(koop.server).get('/file-geojson/rest/services/polygon/FeatureServer');
const response = await request(koop.server).get(
'/file-geojson/rest/services/polygon/FeatureServer',
);
expect(response.status).toBe(200);
expect(response.body.currentVersion).toBe(11.2);
} catch (error) {
Expand All @@ -20,12 +29,27 @@ describe('Geoservices defaults settings', () => {

test('should return layer metadata with expected version', async () => {
try {
const response = await request(koop.server).get('/file-geojson/rest/services/polygon/FeatureServer/0');
const response = await request(koop.server).get(
'/file-geojson/rest/services/polygon/FeatureServer/0',
);
expect(response.status).toBe(200);
expect(response.body.currentVersion).toBe(11.2);
} catch (error) {
console.error(error);
throw error;
}
});

test('should return layer metadata with expected "supportedQueryFormats"', async () => {
try {
const response = await request(koop.server).get(
'/file-geojson/rest/services/polygon/FeatureServer/0',
);
expect(response.status).toBe(200);
expect(response.body.supportedQueryFormats).toBe('JSON');
} catch (error) {
console.error(error);
throw error;
}
});
});

0 comments on commit 5d7e4d9

Please sign in to comment.