- flatgeobuf / flatgeobuf (github)
- flatgeobuf.org
- geotools.org
- geotools / geotools
- repository内を
flatgeobufで検索- プロダクションコードも、テストコードも
modules/unsupported配下に置かれてる - (geobuf もまだ unsupported 配下に置かれてる)
- プロダクションコードも、テストコードも
- repository内を
$ brew install --cask corretto$ brew install --cask corretto17
$ git clone [email protected]:flatgeobuf/flatgeobuf.git$ cd flatgeobuf$ asdf local nodejs 20.5.1$ yarn$ cd examples/node$ asdf local nodejs 20.5.1$ yarn$ node index.jsdeserialize.jsを編集console.log(features)→console.log(JSON.stringify(features))
$ node deserialize.js > deserialize.json$ node streamtest.js > streamtest.json
- JS/TS issue RangeError: start offset of Float64Array should be a multiple of 8 #5325 (google/flatbuffers)
- feature.properties 有りの場合はこのエラーが出てjavascriptでdeserializeできない
- Update to Rust flatbuffers 2.0 #105 (flatgeobuf/flatgeobuf)
- Java/C#/Python prefixed size support #4445 (google/flatbuffers)
-
springbootで意図した通りのgeojsonを作れていることの確認
$ curl http://localhost:8080/geojson/polygon/original_geojson_no_properties_java.json > original_geojson_no_properties_java.json
-
springbootからfgbを取得
$ curl http://localhost:8080/flatgeobuf/polygon/original_geojson_no_properties_java.fgb > original_geojson_no_properties_java.fgb
-
flatgeobuf/example/node で同じgeojsonをserialize, deserializeできることを確認
-
/* eslint-disable no-undef */ import { geojson } from 'flatgeobuf' import { readFileSync, writeFileSync } from 'fs' const originalGeojson = JSON.parse(readFileSync('./original_geojson_no_properties_java.json')) console.log(JSON.stringify(originalGeojson, undefined, 1)) const serialized = geojson.serialize(originalGeojson) writeFileSync('./original_geojson_no_properties_js.fgb', serialized) const bufferJs = readFileSync('./original_geojson_no_properties_js.fgb') const deserialized = geojson.deserialize(new Uint8Array(bufferJs)) console.log(JSON.stringify(deserialized, undefined, 1))
-
-
javaで生成したfgbをjavascriptでdeserializeできることを確認
-
/* eslint-disable no-undef */ import { geojson } from 'flatgeobuf' import { readFileSync, writeFileSync } from 'fs' const bufferJs = readFileSync('./original_geojson_no_properties_java.fgb') const deserialized = geojson.deserialize(new Uint8Array(bufferJs)) console.log(JSON.stringify(deserialized, undefined, 1))
-
-
springbbootで意図した通りのgeojsonを作れていることの確認
$ curl http://localhost:8080/geojson/polygon/original_geojson_with_properties_java.json > original_geojson_with_properties_java.json
-
springbootからfgbを取得
$ curl http://localhost:8080/flatgeobuf/polygon/original_geojson_with_properties_java.fgb > original_geojson_with_properties_java.fgb
-
flatgeobuf/example/node で同じgeojsonをserialize, deserializeできることを確認
-
/* eslint-disable no-undef */ import { geojson } from 'flatgeobuf' import { readFileSync, writeFileSync } from 'fs' const originalGeojson = JSON.parse(readFileSync('./original_geojson_with_properties_java.json')) console.log(JSON.stringify(originalGeojson, undefined, 1)) const serialized = geojson.serialize(originalGeojson) writeFileSync('./original_geojson_with_properties_js.fgb', serialized) const bufferJs = readFileSync('./original_geojson_with_properties_js.fgb') const deserialized = geojson.deserialize(new Uint8Array(bufferJs)) console.log(JSON.stringify(deserialized, undefined, 1))
-
-
javaで生成したfgbをjavascriptでdeserializeしようとする
-
RangeError: start offset of Float64Array should be a multiple of 8が発生 -
/* eslint-disable no-undef */ import { geojson } from 'flatgeobuf' import { readFileSync, writeFileSync } from 'fs' const bufferJs = readFileSync('./original_geojson_with_properties_java.fgb') const deserialized = geojson.deserialize(new Uint8Array(bufferJs)) console.log(JSON.stringify(deserialized, undefined, 1))
-
- feature.properties 無しの場合でも、java, javascriptで生成したそれぞれのfgbファイルに差分がある
❯ ll
216B 9 9 15:39 original_geojson_no_properties_java.fgb
575B 9 9 15:33 original_geojson_no_properties_java.json
208B 9 9 15:53 original_geojson_no_properties_js.fgb
300B 9 9 15:35 original_geojson_with_properties_java.fgb
609B 9 9 15:31 original_geojson_with_properties_java.json
256B 9 9 15:55 original_geojson_with_properties_js.fgb-
examples/node/node_modules/flatgeobuf/lib/mjs/geojson/geometry.js-
function toGeoJsonCoordinates(geometry, type)の直後にログを仕込む-
console.log(JSON.stringify(geometry))
-
-
-
examples/node/node_modules/flatgeobuf/lib/mjs/flat-geobuf/geometry.js-
xyArray()にログを仕込む-
console.log(`offset: ${offset}`) console.log(`this.bb.bytes().buffer: ${this.bb.bytes().buffer}`) console.log(`this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset): ${this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset)}`) console.log(`this.bb.__vector_len(this.bb_pos + offset): ${this.bb.__vector_len(this.bb_pos + offset)}`)
-
-
-
original_geojson_no_properties_java.fgboriginal_geojson_no_properties_java_deserialize_log.json
-
original_geojson_no_properties_js.fgboriginal_geojson_no_properties_js_deserialize_log.json
-
original_geojson_with_properties_java.fgboriginal_geojson_with_properties_java_deserialize_log.json
-
original_geojson_with_properties_js.fgboriginal_geojson_with_properties_js_deserialize_log.json
-
javaで生成したfgbをdeserializeする際、feature.properties有りでも無しでも、offsetは12になっていた。javascriptではoffsetは8。
-
deserializeできない
original_geojson_with_properties_java.fgbは確かにnew Float64Array()に渡すoffset(第2引数)が8で割り切れない220になっていた