{"id":26895352,"url":"https://github.com/saigontek/dart-vector-tile","last_synced_at":"2025-04-01T02:01:17.746Z","repository":{"id":44878522,"uuid":"337191414","full_name":"bahung1221/dart-vector-tile","owner":"bahung1221","description":"A simple Dart package to encode \u0026 decode Mapbox Vector Tile","archived":false,"fork":false,"pushed_at":"2023-12-02T05:12:00.000Z","size":294,"stargazers_count":13,"open_issues_count":3,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-18T19:31:08.460Z","etag":null,"topics":["dart-vector-tile","geojson-format","vector-tile","vector-tile-parser","vector-tile-to-geojson"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/vector_tile","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahung1221.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-02-08T19:49:16.000Z","updated_at":"2024-03-19T07:17:43.000Z","dependencies_parsed_at":"2023-12-02T06:23:58.166Z","dependency_job_id":"0fb9da97-ec6b-41c4-9514-870f1f38253d","html_url":"https://github.com/bahung1221/dart-vector-tile","commit_stats":null,"previous_names":["saigontek/dart-vector-tile"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahung1221%2Fdart-vector-tile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahung1221%2Fdart-vector-tile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahung1221%2Fdart-vector-tile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahung1221%2Fdart-vector-tile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahung1221","download_url":"https://codeload.github.com/bahung1221/dart-vector-tile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246569001,"owners_count":20798341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart-vector-tile","geojson-format","vector-tile","vector-tile-parser","vector-tile-to-geojson"],"created_at":"2025-04-01T02:00:31.585Z","updated_at":"2025-04-01T02:01:17.625Z","avatar_url":"https://github.com/bahung1221.png","language":"Dart","funding_links":[],"categories":["Uncategorized","Parsers \u0026 Generators"],"sub_categories":["Uncategorized"],"readme":"## Dart Vector Tile\nPackage to `encode \u0026 decode` vector tiles. A implementation of [Mapbox Vector Tile specification 2.1](https://github.com/mapbox/vector-tile-spec).\n\nFeatures:\n- [x] Parse `.mvt`/`.pbf` file to raw vector tile format.\n- [x] Decode raw vector tile feature to GeoJson format (only GeoJson Feature type).\n- [x] Decode raw vector tile to GeoJson FeatureCollection format.\n- [x] Encode \u0026 create vector tile file from raw format data.\n- [ ] Encode \u0026 create vector tile file from GeoJson format data. (TODO)\n\n### Parse \u0026 Decode\nParse and then decode each feature to GeoJson from a vector tile file, \neither `.pbf` or `.mvt` should work:\n\n```dart\nimport 'vector_tile/vector_tile.dart';\n\nmain() async {\n  final tileData = await File('../data/sample-12-3262-1923.pbf').readAsBytes();\n  final tile = await VectorTile.fromBytes(bytes: tileData);\n  final layer = tile.layers.firstWhere((layer) =\u003e layer.name == 'transportation');\n\n  layer.features.forEach((feature) {\n    // Geometry will be decode on-demand to avoid redundant calculating\n    feature.decodeGeometry();\n\n    // Each GeometryType will have different geometry data format\n    // So we must explicit check GeometryType and specific generic type here\n    if (feature.geometryType == GeometryType.Point) {\n      var geojson = feature.toGeoJson\u003cGeoJsonPoint\u003e(x: 3262, y: 1923, z: 12);\n\n      print(geojson?.properties);\n      print(geojson?.geometry?.coordinates);\n    }\n  })\n}\n```\n\nWe also can decode feature to GeoJson data first and explicit cast the type later, there are more examples code in [example folder](example/lib/main.dart).\n\n[Sample VectorTile fields](#sample-vectortile-raw-decoded-as-json)\n\n### Encode\nCreate VectorTile from raw data and then encode it into protobuf file:\n\n```dart\nimport 'package:vector_tile/raw/raw_vector_tile.dart';\n\nmain() async {\n  var values = [\n    createVectorTileValue(intValue: Int64(65)),\n    createVectorTileValue(stringValue: 'basketball'),\n  ];\n\n  var features = [\n      createVectorTileFeature(\n        id: Int64(31162829580),\n        tags: [0, 96, 1, 348],\n        type: VectorTile_GeomType.POINT,\n        geometry: [9, 8058, 1562],\n      ),\n  ];\n\n  var layers = [\n    createVectorTileLayer(\n      name: 'building',\n      extent: 4096,\n      version: 2,\n      keys: ['render_height', 'render_min_height'],\n      values: values,\n      features: features,\n    ),\n  ];\n\n  var tile = createVectorTile(layers: layers);\n\n  // Save to disk\n  await File('./gen/tile.pbf').writeAsBytes(tile.writeToBuffer());\n}\n```\n\n### API\n**Class VectorTile**:\n\n- `T toGeoJson\u003cT extends GeoJson\u003e({int x, int y, int z})`: Convert `VectorTile` to a `GeoJson FeatureCollection`. each Feature inside will include **lon/lat** coordinates calculating and will have generic type of [GeoJson class](lib/util/geo_json.dart) \nbecause each geometry type will have different coordinates format. So you must given an explicit GeoJson type or do a type cast here (See decode example above).\n\n\n**Class VectorTileFeature**:\n\n- `decodeGeometry()`: Decode geometry data from raw data, this data also will be used later when we call `getGeoJson` method.\n- `T toGeoJson\u003cT extends GeoJson\u003e({int x, int y, int z})`: Convert `VectorTile Feature` to `GeoJson Feature` format include **lon/lat** coordinates calculating, this method will return generic type of [GeoJson class](lib/util/geo_json.dart) \nbecause each geometry type will have different coordinates format. So you must given an explicit GeoJson type or do a type cast here (See decode example above).\n\n### Sample VectorTile (raw) decoded (as JSON)\n```json\n{\n  \"layers\": [\n    {\n      \"name\": \"poi\",\n      \"features\": {\n        \"id\": 31162829580,\n        \"tags\": [\n          0,\n          0,\n          1,\n          1\n        ],\n        \"type\": \"POINT\",\n        \"geometry\": [\n          9,\n          8058,\n          1562\n        ]\n      },\n      \"keys\": [\n        \"render_height\",\n        \"name\"\n      ],\n      \"values\": [\n        {\n          \"intValue\": 65\n        },\n        {\n          \"stringValue\": \"basketball\"\n        }\n      ],\n      \"extent\": 4096,\n      \"version\": 2\n    }\n  ]\n}\n```\n\n### Sample VectorTileFeature as GeoJson decoded\n```json\n{ \n  \"type\": \"Feature\",\n  \"geometry\": {\"type\": \"Point\", \"coordinates\": [102.0, 0.5]},\n  \"properties\": {\n    \"render_height\": {\n      \"stringValue\": null,\n      \"floatValue\": null,\n      \"doubleValue\": null,\n      \"intValue\": 65,\n      \"uintValue\": null,\n      \"sintValue\": null,\n      \"boolValue\": null\n    },\n    \"name\": {\n      \"stringValue\": \"basketball\",\n      \"floatValue\": null,\n      \"doubleValue\": null,\n      \"intValue\": null,\n      \"uintValue\": null,\n      \"sintValue\": null,\n      \"boolValue\": null\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaigontek%2Fdart-vector-tile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaigontek%2Fdart-vector-tile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaigontek%2Fdart-vector-tile/lists"}