koopjs / koop

Transform, query, and download geospatial data on the web.
http://koopjs.github.io
Other
667 stars 128 forks source link

Possibiblity to overwrite default maxRecordCount of 2000 for output-geoservices #511

Closed Kiachma closed 1 year ago

Kiachma commented 1 year ago

Hi,

I'd like to override the maxRecordCount of my geoservices output, but I'm unable to find any documentation describing this. It seems like https://github.com/koopjs/koop/blob/abb887489a5ab07d5d1ced7187bb5b0637d83640/packages/output-geoservices/src/index.js#L87 doesn't take into account metadata, so I'm not able to override it from the config file.

Is there any other way to handle this?

rgwozdz commented 1 year ago

maxRecordCount can be overridden on a per-provider basis. See this page: https://koopjs.github.io/docs/development/provider/model and do a text search for maxRecordCount. Essentially, you want to add a property metadata.maxRecordCount to the geojson returned by your data provider in the getData method. For example:

geojson.metadata.maxRecordCount = 10000;

But if you are using a pre-existing provider, changing the source code isn't possible (unless you fork the code, etc). In this case, you can make this change using a provider's after transform function.

An after function registered with a provider will execute after the provider’s getData method and can be used modify the provider-generated GeoJSON

So for what you want to do, you could do something like this when you register the provider:

const koop = new Koop()
const github = require('@koopjs/provider-github')

koop.register(github, {
  after: (request, geojson, callback) => {
    geojson.metadata = geojson.metadata || {};
    geojson.metadata.maxRecordCount = 10000;
    callback(null, geojson)
  }
});

Does this make sense? It will look a little different if your Koop instance was generated using the Koop CLI. I can provide an example of the after usage with Koop CLI if you need it.

rgwozdz commented 1 year ago

Inactive, closing.