WTF is KoopJS
Tags: koop, node, geospatial, aws
Published: 2022-01-15 16:38:02

When it comes to setting up a Geospatial backend there are generally only 3 camps:
- [ArcGIS Online/Enterprise](https://www.arcgis.com/)
- [Geoserver](http://geoserver.org/)
- Postgres/PostGIS + Server

These servers while extremely capable are difficult to manage and often come with a lot of bloat and can be difficult to configure if you are not someone inclined to work in Windows Server. 

That is until I recently found out about [KoopJS](https://koopjs.github.io/) a solution that is under the Open Source license to provide an Node backend built with Express to serve up [GeoServices](https://geoservices.github.io/) which are a standard in the industry to distribute Geospatial specific data.

## **What am I using it for**

Where it really excels is creating a custom solution (like I was looking for) for the purpose of creating a real-time data solution for transit. As of right now I am able:
- convert [GTFS-RT](https://developers.google.com/transit/gtfs-realtime) and distribute real-time updates
- backup information into a datalake
- preform scheduled tasks
- query my datalake with [AWS Athena](https://aws.amazon.com/athena) all within Koop and Node. 

## **Building your own provider**
If you are interested in building your own provider I recommend you looking at the [koop-app-example](https://github.com/koopjs/koop-app-example) and [koop-provider-example](https://github.com/koopjs/koop-provider-example/tree/master/src). 

The `koop-app-example` is the framework that I used to build my providers by configuring the files in the `src/` file and adding custom providers. In the repo it is already setup for Craigslist and GitHub providers. 

I used `koop-provider-example` as a template for all of my custom providers by configuring the `index.js` and `model.js` files. While there are an extended list this was all I needed to focus on. Below is the list of files and their purposes in the standard Koop provider.

![List of Provider files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qy6ejnntjeq5ssnm5mvq.png) 

The only requirement (that I have found) to creating a custom connection is to be able to provide a GeoJson output of the `Model.prototype.getData()`.

In the index file you just really need to update the name and that will be the name of your service. Example call for feature service would be formatted like this:

`http://localhost:8080/:name/FeatureService/0`

From here you can append `query?where=...` and input your standard where GeoService parameters

![Parts of a Provider](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9l9gkzf94kcrvtpgv1a0.png)

## **Takeaways**

Out of the box there are quite a few [different connections](https://koopjs.github.io/docs/available-plugins/providers) that you can setup including s3, PostGres, Craigslist, BigQuery and others which makes it really alluring considering there are ways to connect existing datasources that will adhere to a laundry list of url parameters. I think there is a strong case for using this type of server for real-time and big data queries as these are typically locked behind another license in the geospatial server world.