Skip to content

Commit 9ca1d23

Browse files
committed
- adds support for TH input files
1 parent 9a24852 commit 9ca1d23

File tree

9 files changed

+2015
-5
lines changed

9 files changed

+2015
-5
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- ✅ is open source (MIT license)
88

99
This repository is **WIP**, APIs and data structures are likely to change.
10-
Currently, **8/16** federal states are supported.
10+
Currently, **9/16** federal states are supported.
1111
The following overview table displays the current state of the project:
1212

1313
| Federal state | ISO 3166-2 code | Test data available? | Supported by 'harmonie' | ToDos |
@@ -27,7 +27,7 @@ The following overview table displays the current state of the project:
2727
| Saarland | DE-SL ||| - |
2828
| Sachsen | DE-SN | ⬜️ | ⬜️ | Waiting on test data (DIANAweb Sachsen-Anhalt) |
2929
| Sachsen-Anhalt | DE-ST | ⬜️ | ⬜️ | Waiting on test data (ELAISA Sachsen) |
30-
| Thüringen | DE-TH || ⬜️ | Create property mapping |
30+
| Thüringen | DE-TH || | - |
3131

3232
## Installation
3333

@@ -123,7 +123,18 @@ the federal state:
123123
| Saarland | DE-SL | state, shp, dbf |
124124
| Sachsen | DE-SN | state, - |
125125
| Sachsen-Anhalt | DE-ST | state, - |
126-
| Thüringen | DE-TH | state, - |
126+
| Thüringen | DE-TH | state, shp, dbf |
127+
128+
## Specifics for certain federal states
129+
130+
#### DE-HE: Hessen
131+
According to the test data received from Hessen, the shape file and accompanying database
132+
does not contain information about the reference date of the files. Therefore, please expect the `referenceDate` to be undefined for this federal state.
133+
134+
#### DE-TH: Thüringen
135+
According to the test data received from Thüringen, the shape file and accompanying database
136+
does not contain information about the crop cultivation for a particular field. Therefore, expect the
137+
`Cultivation` property to be empty.
127138

128139
## Contribution
129140
Contribution is highly appreciated 👍!

dist/harmonie.cjs.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,36 @@ async function sl (query) {
502502
return helpers.groupByFLIK(subplots)
503503
}
504504

505+
async function sl$1 (query) {
506+
const incomplete = queryComplete(query, ['shp', 'dbf']);
507+
if (incomplete) throw new Error(incomplete)
508+
// parse the shape file information
509+
const geometries = await parse.shape(query.shp, query.dbf);
510+
// reproject coordinates into web mercator
511+
geometries.features = geometries.features.map(f => helpers.reprojectFeature(f));
512+
513+
const subplots = geometries.features.map((plot, count) => new Field({
514+
id: `harmonie_${count}_${plot.properties.FBI}`,
515+
referenceDate: undefined, // duh!
516+
NameOfField: '',
517+
NumberOfField: count,
518+
Area: plot.properties.FL,
519+
FieldBlockNumber: plot.properties.FBI,
520+
PartOfField: '',
521+
SpatialData: plot,
522+
Cultivation: {
523+
PrimaryCrop: {
524+
CropSpeciesCode: undefined, // duh!
525+
Name: undefined
526+
}
527+
}
528+
}));
529+
530+
// finally, group the parts of fields by their FLIK and check whether they are
531+
// actually seperate parts of fields
532+
return helpers.groupByFLIK(subplots)
533+
}
534+
505535
function harmonie (query) {
506536
const state = query.state;
507537
if (!state) {
@@ -523,6 +553,8 @@ function harmonie (query) {
523553
return nw(query)
524554
case 'DE-SL':
525555
return sl(query)
556+
case 'DE-TH':
557+
return sl$1(query)
526558
default:
527559
throw new Error(`No such state as "${state}" according to ISO 3166-2 in Germany."`)
528560
}

dist/harmonie.esm.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,36 @@ async function sl (query) {
498498
return helpers.groupByFLIK(subplots)
499499
}
500500

501+
async function sl$1 (query) {
502+
const incomplete = queryComplete(query, ['shp', 'dbf']);
503+
if (incomplete) throw new Error(incomplete)
504+
// parse the shape file information
505+
const geometries = await parse.shape(query.shp, query.dbf);
506+
// reproject coordinates into web mercator
507+
geometries.features = geometries.features.map(f => helpers.reprojectFeature(f));
508+
509+
const subplots = geometries.features.map((plot, count) => new Field({
510+
id: `harmonie_${count}_${plot.properties.FBI}`,
511+
referenceDate: undefined, // duh!
512+
NameOfField: '',
513+
NumberOfField: count,
514+
Area: plot.properties.FL,
515+
FieldBlockNumber: plot.properties.FBI,
516+
PartOfField: '',
517+
SpatialData: plot,
518+
Cultivation: {
519+
PrimaryCrop: {
520+
CropSpeciesCode: undefined, // duh!
521+
Name: undefined
522+
}
523+
}
524+
}));
525+
526+
// finally, group the parts of fields by their FLIK and check whether they are
527+
// actually seperate parts of fields
528+
return helpers.groupByFLIK(subplots)
529+
}
530+
501531
function harmonie (query) {
502532
const state = query.state;
503533
if (!state) {
@@ -519,6 +549,8 @@ function harmonie (query) {
519549
return nw(query)
520550
case 'DE-SL':
521551
return sl(query)
552+
case 'DE-TH':
553+
return sl$1(query)
522554
default:
523555
throw new Error(`No such state as "${state}" according to ISO 3166-2 in Germany."`)
524556
}

dist/harmonie.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import he from './states/DE-HE'
55
import mv from './states/DE-MV'
66
import nw from './states/DE-NW'
77
import sl from './states/DE-SL'
8+
import th from './states/DE-TH'
89

910
export default function harmonie (query) {
1011
const state = query.state
@@ -27,6 +28,8 @@ export default function harmonie (query) {
2728
return nw(query)
2829
case 'DE-SL':
2930
return sl(query)
31+
case 'DE-TH':
32+
return th(query)
3033
default:
3134
throw new Error(`No such state as "${state}" according to ISO 3166-2 in Germany."`)
3235
}

src/states/DE-TH.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import parse from '../utils/parse'
2+
import helpers from '../utils/helpers'
3+
import queryComplete from '../utils/queryComplete'
4+
import Field from '../Field'
5+
6+
export default async function sl (query) {
7+
const incomplete = queryComplete(query, ['shp', 'dbf'])
8+
if (incomplete) throw new Error(incomplete)
9+
// parse the shape file information
10+
const geometries = await parse.shape(query.shp, query.dbf)
11+
// reproject coordinates into web mercator
12+
geometries.features = geometries.features.map(f => helpers.reprojectFeature(f))
13+
14+
const subplots = geometries.features.map((plot, count) => new Field({
15+
id: `harmonie_${count}_${plot.properties.FBI}`,
16+
referenceDate: undefined, // duh!
17+
NameOfField: '',
18+
NumberOfField: count,
19+
Area: plot.properties.FL,
20+
FieldBlockNumber: plot.properties.FBI,
21+
PartOfField: '',
22+
SpatialData: plot,
23+
Cultivation: {
24+
PrimaryCrop: {
25+
CropSpeciesCode: undefined, // duh!
26+
Name: undefined
27+
}
28+
}
29+
}))
30+
31+
// finally, group the parts of fields by their FLIK and check whether they are
32+
// actually seperate parts of fields
33+
return helpers.groupByFLIK(subplots)
34+
}

0 commit comments

Comments
 (0)