Comparing version 0.0.2 to 0.1.0
@@ -0,0 +0,0 @@ module.exports = { |
25
index.js
const utils = require('./src/utils'); | ||
const fs = require('fs') | ||
@@ -27,2 +28,26 @@ module.exports = { | ||
humusContent(point) { | ||
return new Promise((resolve,reject) => { | ||
if (!point) return reject(this.invalidRequest) | ||
let geometry | ||
try { | ||
geometry = utils.createGeometry(point,reject) | ||
} catch (error) { | ||
return resolve(error) | ||
} | ||
const url = `https://services.bgr.de/wms/boden/bodeneigenschaften/?&REQUEST=GetFeatureInfo&SERVICE=WMS&CRS=EPSG%3A3857&STYLES=default&TRANSPARENT=true&VERSION=1.3.0&FORMAT=image%2Fpng&BBOX=${utils.createBBox(geometry)}&HEIGHT=880&WIDTH=514&LAYERS=1&QUERY_LAYERS=1&INFO_FORMAT=text%2Fhtml&I=452&J=371` | ||
utils.request(url) | ||
.then(res => { | ||
fs.writeFileSync('test.html', res, 'utf8') | ||
resolve(utils.soilTypeHtmlParsing(res)) | ||
}) | ||
.catch(error => { | ||
reject(error) | ||
}) | ||
}) | ||
}, | ||
sqr(point, layer) { | ||
@@ -29,0 +54,0 @@ return new Promise((resolve,reject) => { |
@@ -0,0 +0,0 @@ MIT License |
{ | ||
"name": "bgr-apis", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Soil quality API covering Germany with data from BGR", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -72,8 +72,61 @@ # BGR Soil Information | ||
Returns the soil type (string, UTF-8, german) at a given point. | ||
Possible categories are: | ||
| Soil Types | | ||
|:------------------| | ||
| Reinsande (ss) | | ||
| Lehmsande (ls) | | ||
| Schluffsande (us) | | ||
| Sandlehme (sl) | | ||
| Normallehme (ll) | | ||
| Tonlehme (tl) | | ||
| Lehmschluffe (lu) | | ||
| Tonschluffe (tu) | | ||
| Schlufftone (ut) | | ||
| Moore (mo) | | ||
| Watt | | ||
| Siedlung | | ||
| Abbauflächen | | ||
| Gewässer | | ||
`Point` can either be a GeoJSON point, an array of the form `[lng, lat]` or a GeoJSON feature (e.g. a plot). When a plot (GeoJSON feature) is entered, the centroid of the plot is used. | ||
### ```humusContent(point)``` | ||
```js | ||
bgr.humusContent({ | ||
type: 'Point', | ||
coordinates: [8.350689,52.087511] | ||
}) | ||
.then(res => { | ||
// res = '2 - <3%' | ||
}) | ||
.catch(err => { | ||
// handle errors | ||
}) | ||
``` | ||
Return the humus content (string, UTF-8, german) for a given point. | ||
Possible categories are: | ||
| Humus content | | ||
|:----------------| | ||
| 1 - <2% | | ||
| 2 - <3% | | ||
| 3 - <4% | | ||
| 4 - <6% | | ||
| 6 - <8% | | ||
| 8 - <11,5% | | ||
| 11,5 - <15% | | ||
| 15 - <30% | | ||
| ≥30% | | ||
| Wattflächen | | ||
| Gewässerflächen | | ||
| Siedlungen | | ||
| Abbauflächen | | ||
| nicht bestimmt | | ||
`Point` can either be a GeoJSON point, an array of the form `[lng, lat]` or a GeoJSON feature (e.g. a plot). When a plot (GeoJSON feature) is entered, the centroid of the plot is used. | ||
## Contribution | ||
Contribution is highly appreciated! If you have improvements in code quality and/or additional features just open a pull. |
@@ -0,0 +0,0 @@ let proj4 = require('proj4') |
@@ -36,2 +36,32 @@ const assert = require('assert') | ||
// check humus content for point | ||
bgr.humusContent({ | ||
type: 'Point', | ||
coordinates: [8.350689,52.087511] | ||
}) | ||
.then(res => { | ||
assert.deepStrictEqual(res,'2 - <3%') | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
}) | ||
// check humus content for point as array | ||
bgr.humusContent([8.350689,52.087511]) | ||
.then(res => { | ||
assert.deepStrictEqual(res,'2 - <3%') | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
}) | ||
// humusContent for point given as plot geometry | ||
bgr.humusContent(plotGeometry) | ||
.then(res => { | ||
assert.deepStrictEqual(res,'2 - <3%') | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
}) | ||
// soil type for point | ||
@@ -38,0 +68,0 @@ bgr.soilType({ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
16950
8
289
132
1