Skip to content

Commit

Permalink
Add info about cityjsonl + 2 test datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoledoux committed Oct 13, 2023
1 parent c22debe commit 7d58ef3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
33 changes: 23 additions & 10 deletions cityjsonl/jsonl.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ The idea is to decompose a CityJSON file into its features (eg each building, ea

## CityJSONFeature

A `CityJSONFeature` object represents **one** feature in a CityJSON object, for instance a `"Building"` with eventually its children `"BuildingPart"` and/or `"BuildingInstallation"`.
The idea is to decompose a large file into each of its features, and each feature is a `CityJSONFeature`.
A `CityJSONFeature` object represents **one** feature in a CityJSON object, for instance a `"Building"` (with eventually its children `"BuildingPart"` and/or `"BuildingInstallation"`).
The idea is to decompose a large area into each of its features, and each feature is a stored as a `CityJSONFeature`.
Each feature is independent, and has its own list of vertices (which is thus local).

See [full specifications for a CityJSONFeature](https://www.cityjson.org/specs/#text-sequences-and-streaming-with-cityjsonfeature).
See the [full specifications for a CityJSONFeature](https://www.cityjson.org/specs/#text-sequences-and-streaming-with-cityjsonfeature).

```json
{
Expand Down Expand Up @@ -54,7 +54,7 @@ See [full specifications for a CityJSONFeature](https://www.cityjson.org/specs/#
```


## Streaming with CityJSONL
## Streaming 3D cities with CityJSONL

Each CityJSON feature can become one line in a [JSON Lines text](https://jsonlines.org).
Since we want to have access to some properties, eg `"transform"` and the CRS, those need to be known by the client/software parsing the stream.
Expand All @@ -68,9 +68,10 @@ We can add one line to a JSON Lines text stream (eg the first line) with those p
{"type":"CityJSONFeature","id":"c","CityObjects":{...},"vertices":[...]}
```

## cjio can read and write CityJSONL

Starting from v0.8, cjio allows us to read/write from stdin/stdout (standard input/output streams), and it can use [CityJSONL (text sequences with CityJSONFeatures)](https://www.cityjson.org/specs/#text-sequences-and-streaming-with-cityjsonfeature).
## Reading and writing CityJSONL with cjio

The software [cjio](https://github.com/cityjson/cjio) allows us to read and write CityJSONL from stdin/stdout (standard input/output streams).

We can create a CityJSONL stream (with the first line containing the metadata) this way:

Expand All @@ -87,15 +88,27 @@ That stream can be saved to a file:
cjio --suppress_msg myfile.city.json export jsonl mystream.city.jsonl
```

And a CityJSONL stream/file can be compiled to a CityJSON file by reading it from `stdin`:
A CityJSONL stream/file can be compiled to a CityJSON file by reading it from `stdin`:

```
cat mystream.city.jsonl | cjio stdin info save myfile_2.city.json
```

## cjval can validate a stream

The official [schema-validator of CityJSON (called cjval)](https://github.com/cityjson/cjval) can also validate CityJSONL streams with its binary `cjfval`.
## Validating a stream

### With the online validator

The [official schema-validator of CityJSON](https://validator.cityjson.org) accepts CityJSONL files, if they are structure with the first line as "metadata" (as shown above, [3dbag_b2.city.jsonl](https://3d.bk.tudelft.nl/opendata/cityjson/cityjsonl/3dbag_b2.city.jsonl) and [montréal_b4.city.jsonl](https://3d.bk.tudelft.nl/opendata/cityjson/cityjsonl/montréal_b4.city.jsonl) are two examples).

You can just drop those files and the validator will indicate, *per line*, if the `CityJSONFeature` are valid, or not.

[![](validator.png)](https://validator.cityjson.org)


### Locally with cjfval

The official [schema-validator of CityJSON (called cjval)](https://github.com/cityjson/cjval) can validate CityJSONL streams with its binary `cjfval`.
Each line is individually validated and errors reported:

```bash
Expand All @@ -109,7 +122,7 @@ l.6 ✅
```


## viewcjl: a small viewer for CityJSONL files
## viewcjf: a small viewer for CityJSONL files


![](https://raw.githubusercontent.com/cityjson/viewcjl/main/demo.png)
Expand Down
Binary file added cityjsonl/validator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions datasets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ Please be aware that we simply converted the datasets, some datasets contain (ge
<i class="fas fa-exclamation-circle"></i> We performed the geometric validation with [val3dity](https://github.com/tudelft3d/val3dity) and report the overall result in the column 'validity'. To understand the errors, we suggest validating the files ([how to do this]({{ '/tutorials/validation/' | relative_url }})) yourself.


## CityJSONL (CityJSON Lines) examples

CityJSON Lines---CityJSONL for short---is a format based on [JSON Text Sequences](https://datatracker.ietf.org/doc/html/rfc7464) and CityJSON.
It involves decomposing a dataset into each of its features (which becomes a [`CityJSONFeature`](https://www.cityjson.org/specs/#text-sequences-and-streaming-with-cityjsonfeature)) and storing them in a text file: one per line.

The following 2 subsets of datasets were generated using cjio ([see details](https://www.cityjson.org/cityjsonl/#reading-and-writing-cityjsonl-with-cjio)).

| dataset | CityJSONL file | description |
| ------- | -------------- | ----------- |
| 3DBAG | [3dbag_b2.city.jsonl](https://3d.bk.tudelft.nl/opendata/cityjson/cityjsonl/3dbag_b2.city.jsonl) | 2 buildings randomly selected from the 3DBAG, LoD2.2 only |
| Montréal | [montréal_b4.city.jsonl](https://3d.bk.tudelft.nl/opendata/cityjson/cityjsonl/montréal_b4.city.jsonl) | 4 buildings randomly selected from the Montréal dataset |

## Generating automatically your own CityJSON dataset

It is possible to generate automatically a 3D city model in CityJSON with [3dfier](https://github.com/tudelft3d/3dfier), just follow that simple [tutorial](https://tudelft3d.github.io/3dfier/generate_lod1.html).
Expand Down

0 comments on commit 7d58ef3

Please sign in to comment.