@nexgen-os/geojson 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -41,7 +41,7 @@ const open = await exportGeoJson(db, { projectId }, { open: true }); // what
41
41
  | Nexgen OS | Feature | Properties |
42
42
  |---|---|---|
43
43
  | the project (`projectId`) | its perimeter, first | `kind: "project"`, `project_kind`, `country`, `status`, `start_date`, `end_date` |
44
- | each participant with a place | its point or outline | `project_id`, `role`, `segment`, `status`, address fields with the `municipality` code, `time_zone`, `location_precision`, `location_source_code` |
44
+ | each participant with a place | its point or outline | `project_id`, `category`, `segment`, `status`, address fields with the `municipality` code, `time_zone`, `location_precision`, `location_source_code` |
45
45
  | its ground, with the `building` module | its parcel, or `null` | `kind: "site"`, `participant_id`, `use`, `area_m2`, `global_id`, `source_code` |
46
46
  | each building, with the `building` module | its footprint | `participant_id`, `site_id`, `use`, `elevation_m`, `height_m`, `year_built`, `floors_above_ground`, `floors_below_ground`, `floor_area_m2`, `energy_label`, `status`, `global_id`, `source_code` |
47
47
  | each surface, with the `building` module | its face, or `null` | `surface_kind`, `participant_id`, `site_id`, `building_id`, `azimuth_deg`, `tilt_deg`, `area_m2`, `material`, `u_value`, `is_external`, `global_id`, `source_code` |
@@ -63,6 +63,15 @@ keeps them. The export computes nothing.
63
63
  on with its licence and attribution, and how many objects were withheld.
64
64
  - The same database gives the same document: no export time inside it.
65
65
 
66
+ The document is described by a JSON Schema,
67
+ [`geojson-export.1.json`](../../core/schema/geojson-export.1.json), shipped
68
+ in `@nexgen-os/core` (`schema/`): every property of every kind of feature
69
+ with its type and what it says, the `nexgen_os` member, and what an open
70
+ export never carries. A portal, a catalogue or another program checks the
71
+ file it receives against it before showing it. The tests validate every
72
+ export against it and refuse a property it does not describe, so the export
73
+ and its schema change together; a property renamed or removed is a version 2.
74
+
66
75
  ### The open export
67
76
 
68
77
  `open: true` is the document meant for the public — a citizens' portal, a
@@ -87,4 +96,24 @@ Every refusal starts with its name: `target_required` (a `participantId` or a
87
96
  `projectId`, not both), `participant_not_found`, `project_not_found` (absent, or
88
97
  not readable under row level security).
89
98
 
90
- Not yet: importing GeoJSON places into participants, meters, series.
99
+ Not yet: importing the meters, the devices and the series of an export.
100
+
101
+ ## Participants read back
102
+
103
+ `importGeoJsonParticipants()` of `@nexgen-os/core` reads the other way: each
104
+ feature of kind `participant`, or without a kind, joins a project at its
105
+ geometry, with the properties the export writes (`name`, `category`,
106
+ `country`, the address fields, `region`, `municipality`, `time_zone`,
107
+ `location_precision`, `location_source_code`, `identifiers`). The other
108
+ kinds are left out and listed. The file is attached to the project with its
109
+ checksum and imported once (`already_imported`), whole or not at all; a
110
+ feature without a name or a country refuses the file by its index
111
+ (`name_required`, `country_required`): a country is never assumed.
112
+
113
+ ```ts
114
+ import { readGeoJson } from '@nexgen-os/geojson';
115
+ import { importGeoJsonParticipants } from '@nexgen-os/core';
116
+
117
+ const { features } = readGeoJson(text);
118
+ const { participants, skipped } = await importGeoJsonParticipants(db, projectId, features, { name, uri, checksum });
119
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexgen-os/geojson",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "description": "GeoJSON (RFC 7946) features written as a FeatureCollection with its bounding box, and read back with what could not be read reported. No database, no dependency.",
5
5
  "license": "MIT",
6
6
  "repository": {