Timeline added
This commit is contained in:
+15
-15
@@ -1,7 +1,7 @@
|
||||
import { collectGeoJSON, offset, pointsFromLngLat } from "./geometry.js";
|
||||
import { getFeatureType, listFeatureTypeSchemas } from "./feature-types.js";
|
||||
|
||||
export const YARD_SCHEMA_VERSION = 1;
|
||||
export const YARD_SCHEMA_VERSION = 2;
|
||||
|
||||
class YardFeature {
|
||||
constructor(kind, geometryType, name, details = {}) {
|
||||
@@ -16,9 +16,9 @@ class YardFeature {
|
||||
this.geometryType = geometryType;
|
||||
this.name = name ?? featureType.label;
|
||||
this.id = buildFeatureId(kind, this.name);
|
||||
const { startDate = null, endDate = null, ...restDetails } = details;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
const { plantedDate = null, removedDate = null, ...restDetails } = details;
|
||||
this.plantedDate = plantedDate;
|
||||
this.removedDate = removedDate;
|
||||
this.details = { ...restDetails };
|
||||
this.coordinates = [];
|
||||
this.parentId = null;
|
||||
@@ -48,19 +48,19 @@ class YardFeature {
|
||||
return this;
|
||||
}
|
||||
|
||||
activeFrom(startDate) {
|
||||
this.startDate = startDate;
|
||||
plantedOn(plantedDate) {
|
||||
this.plantedDate = plantedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
activeUntil(endDate) {
|
||||
this.endDate = endDate;
|
||||
removedOn(removedDate) {
|
||||
this.removedDate = removedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
withDateRange(startDate, endDate = null) {
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
withLifecycleDates(plantedDate, removedDate = null) {
|
||||
this.plantedDate = plantedDate;
|
||||
this.removedDate = removedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ class YardFeature {
|
||||
kind: this.kind,
|
||||
label,
|
||||
name: this.name,
|
||||
startDate: this.startDate,
|
||||
endDate: this.endDate,
|
||||
plantedDate: this.plantedDate,
|
||||
removedDate: this.removedDate,
|
||||
parentId: this.parentId,
|
||||
groupIds: this.groupIds,
|
||||
details: this.details,
|
||||
@@ -334,8 +334,8 @@ export function collectYardData(features, groups = []) {
|
||||
const collection = collectGeoJSON(features);
|
||||
collection.schemaVersion = YARD_SCHEMA_VERSION;
|
||||
collection.lifecycleFields = {
|
||||
startDate: "date",
|
||||
endDate: "date",
|
||||
plantedDate: "date",
|
||||
removedDate: "date",
|
||||
};
|
||||
collection.featureTypes = listFeatureTypeSchemas();
|
||||
collection.groups = groups.map((group) => ({
|
||||
|
||||
Reference in New Issue
Block a user